diff options
| author | R. David Murray <rdmurray@bitdance.com> | 2009-05-24 14:48:53 (GMT) |
|---|---|---|
| committer | R. David Murray <rdmurray@bitdance.com> | 2009-05-24 14:48:53 (GMT) |
| commit | 7a458e8f64720991f7bf1cb0fee115aa14c5a3ee (patch) | |
| tree | 4d05f613be103e10d1fae3d5773809c66d2c9b49 | |
| parent | 6c95acb120243c4b9d4aafd2871f4250696eb7c9 (diff) | |
| download | cpython-7a458e8f64720991f7bf1cb0fee115aa14c5a3ee.zip cpython-7a458e8f64720991f7bf1cb0fee115aa14c5a3ee.tar.gz cpython-7a458e8f64720991f7bf1cb0fee115aa14c5a3ee.tar.bz2 | |
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 (Sat, 23 May 2009) | 2 lines
Add smtplib test from issue 5259.
........
| -rw-r--r-- | Lib/test/test_smtplib.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py index 719c488..623b16d 100644 --- a/Lib/test/test_smtplib.py +++ b/Lib/test/test_smtplib.py @@ -276,6 +276,9 @@ sim_users = {'Mr.A@somewhere.com':'John A', 'Mrs.C@somewhereesle.com':'Ruth C', } +sim_auth = ('Mr.A@somewhere.com', 'somepassword') +sim_auth_b64encoded = 'AE1yLkFAc29tZXdoZXJlLmNvbQBzb21lcGFzc3dvcmQ=' + sim_lists = {'list-1':['Mr.A@somewhere.com','Mrs.C@somewhereesle.com'], 'list-2':['Ms.B@somewhere.com',], } @@ -288,6 +291,7 @@ class SimSMTPChannel(smtpd.SMTPChannel): '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 @@ class SimSMTPChannel(smtpd.SMTPChannel): 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 @@ class SMTPSimTests(TestCase): 'size': '20000000', 'starttls': '', 'deliverby': '', + 'auth': ' PLAIN', 'help': '', } @@ -401,6 +416,11 @@ class SMTPSimTests(TestCase): 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): |
