]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Closes #6683: add a test that exercises multiple authentication.
authorAndrew Kuchling <amk@amk.ca>
Mon, 11 Nov 2013 19:03:23 +0000 (14:03 -0500)
committerAndrew Kuchling <amk@amk.ca>
Mon, 11 Nov 2013 19:03:23 +0000 (14:03 -0500)
The SMTP server advertises four different authentication methods, and
the code will try CRAM-MD5 first, which will fail, but LOGIN succeeds.

Lib/test/test_smtplib.py

index a501f40b567d9e3cc85c24b8ab41954c383e07cc..e6f39dec77390154d36737fa6595305b5dd98e67 100644 (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()