forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for issue 5259: ASCII encode the username and password before pas…
…sing it to encode_base64, which requires bytes in py3k. Fix by Musashi Tamura, tests by Marcin Bachry.
- Loading branch information
Showing
4 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -284,6 +284,9 @@ def testFailingHELO(self): | |
'[email protected]':'Ruth C', | ||
} | ||
|
||
sim_auth = ('[email protected]', 'somepassword') | ||
sim_auth_b64encoded = 'AE1yLkFAc29tZXdoZXJlLmNvbQBzb21lcGFzc3dvcmQ=' | ||
|
||
sim_lists = {'list-1':['[email protected]','[email protected]'], | ||
'list-2':['[email protected]',], | ||
} | ||
|
@@ -296,6 +299,7 @@ def smtp_EHLO(self, arg): | |
'250-SIZE 20000000\r\n' \ | ||
'250-STARTTLS\r\n' \ | ||
'250-DELIVERBY\r\n' \ | ||
'250-AUTH PLAIN\r\n' \ | ||
'250 HELP' | ||
self.push(resp) | ||
|
||
|
@@ -324,6 +328,16 @@ def smtp_EXPN(self, arg): | |
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): | ||
|
@@ -372,6 +386,7 @@ def testEHLO(self): | |
'size': '20000000', | ||
'starttls': '', | ||
'deliverby': '', | ||
'auth': ' PLAIN', | ||
'help': '', | ||
} | ||
|
||
|
@@ -412,6 +427,11 @@ def testEXPN(self): | |
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): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters