[Python-checkins] r72886 - in python/branches/release26-maint: Lib/test/test_smtplib.py

r.david.murray python-checkins at python.org
Sun May 24 16:48:53 CEST 2009


Author: r.david.murray
Date: Sun May 24 16:48:53 2009
New Revision: 72886
Log:
Merged revisions 72878 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk
........
 r72878 | r.david.murray | 2009年05月23日 17:48:06 -0400 (2009年5月23日) | 2 lines
 
 Add smtplib test from issue 5259.
........
Modified:
 python/branches/release26-maint/ (props changed)
 python/branches/release26-maint/Lib/test/test_smtplib.py
Modified: python/branches/release26-maint/Lib/test/test_smtplib.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_smtplib.py	(original)
+++ python/branches/release26-maint/Lib/test/test_smtplib.py	Sun May 24 16:48:53 2009
@@ -276,6 +276,9 @@
 'Mrs.C at somewhereesle.com':'Ruth C',
 }
 
+sim_auth = ('Mr.A at somewhere.com', 'somepassword')
+sim_auth_b64encoded = 'AE1yLkFAc29tZXdoZXJlLmNvbQBzb21lcGFzc3dvcmQ='
+
 sim_lists = {'list-1':['Mr.A at somewhere.com','Mrs.C at somewhereesle.com'],
 'list-2':['Ms.B at somewhere.com',],
 }
@@ -288,6 +291,7 @@
 '250-SIZE 20000000\r\n' \
 '250-STARTTLS\r\n' \
 '250-DELIVERBY\r\n' \
+ '250-AUTH PLAIN\r\n' \
 '250 HELP'
 self.push(resp)
 
@@ -316,6 +320,16 @@
 else:
 self.push('550 No access for you!')
 
+ def smtp_AUTH(self, arg):
+ mech, auth = arg.split()
+ if mech.lower() == 'plain':
+ if auth == sim_auth_b64encoded:
+ self.push('235 ok, go ahead')
+ else:
+ self.push('550 No access for you!')
+ else:
+ self.push('504 auth type unimplemented')
+
 
 class SimSMTPServer(smtpd.SMTPServer):
 def handle_accept(self):
@@ -364,6 +378,7 @@
 'size': '20000000',
 'starttls': '',
 'deliverby': '',
+ 'auth': ' PLAIN',
 'help': '',
 }
 
@@ -401,6 +416,11 @@
 self.assertEqual(smtp.expn(u), expected_unknown)
 smtp.quit()
 
+ def testAUTH(self):
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
+
+ expected_auth_ok = (235, b'ok, go ahead')
+ self.assertEqual(smtp.login(sim_auth[0], sim_auth[1]), expected_auth_ok)
 
 
 def test_main(verbose=None):


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /