Skip to content

Commit dca899d

Browse files
committed
Add test for bpo-27820 fix
And in the process also fix a longstanding bug in the SimSMTPChannel.found_terminator() method that causes inability to test SMTP AUTH with initial_response_ok=False.
1 parent be73188 commit dca899d

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

Lib/test/test_smtplib.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ def found_terminator(self):
785785
except ResponseException as e:
786786
self.smtp_state = self.COMMAND
787787
self.push('%s %s' % (e.smtp_code, e.smtp_error))
788-
return
788+
return
789789
super().found_terminator()
790790

791791

@@ -1069,6 +1069,24 @@ def testAUTH_LOGIN(self):
10691069
self.assertEqual(resp, (235, b'Authentication Succeeded'))
10701070
smtp.close()
10711071

1072+
def testAUTH_LOGIN_initial_response_ok(self):
1073+
self.serv.add_feature("AUTH LOGIN")
1074+
with smtplib.SMTP(HOST, self.port, local_hostname='localhost',
1075+
timeout=support.LOOPBACK_TIMEOUT) as smtp:
1076+
smtp.user, smtp.password = sim_auth
1077+
smtp.ehlo("test_auth_login")
1078+
resp = smtp.auth("LOGIN", smtp.auth_login, initial_response_ok=True)
1079+
self.assertEqual(resp, (235, b'Authentication Succeeded'))
1080+
1081+
def testAUTH_LOGIN_initial_response_notok(self):
1082+
self.serv.add_feature("AUTH LOGIN")
1083+
with smtplib.SMTP(HOST, self.port, local_hostname='localhost',
1084+
timeout=support.LOOPBACK_TIMEOUT) as smtp:
1085+
smtp.user, smtp.password = sim_auth
1086+
smtp.ehlo("test_auth_login")
1087+
resp = smtp.auth("LOGIN", smtp.auth_login, initial_response_ok=False)
1088+
self.assertEqual(resp, (235, b'Authentication Succeeded'))
1089+
10721090
@hashlib_helper.requires_hashdigest('md5')
10731091
def testAUTH_CRAM_MD5(self):
10741092
self.serv.add_feature("AUTH CRAM-MD5")

0 commit comments

Comments
 (0)