Closes #6683: add a test that exercises multiple authentication.

The SMTP server advertises four different authentication methods, and
the code will try CRAM-MD5 first, which will fail, but LOGIN succeeds.
This commit is contained in:
Andrew Kuchling 2013-11-11 14:03:23 -05:00
parent fc0cad8b04
commit 785918250f
1 changed files with 9 additions and 0 deletions

View File

@ -819,6 +819,15 @@ class SMTPSimTests(unittest.TestCase):
self.assertIn(sim_auth_credentials['cram-md5'], str(err))
smtp.close()
def testAUTH_multiple(self):
# Test that multiple authentication methods are tried.
self.serv.add_feature("AUTH BOGUS PLAIN LOGIN CRAM-MD5")
smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
try: smtp.login(sim_auth[0], sim_auth[1])
except smtplib.SMTPAuthenticationError as err:
self.assertIn(sim_auth_login_password, str(err))
smtp.close()
def test_with_statement(self):
with smtplib.SMTP(HOST, self.port) as smtp:
code, message = smtp.noop()