]> granicus.if.org Git - python/commitdiff
Issue #23779: imaplib raises TypeError if authenticator tries to abort.
authorRobert Collins <rbtcollins@hp.com>
Thu, 30 Jul 2015 20:59:02 +0000 (08:59 +1200)
committerRobert Collins <rbtcollins@hp.com>
Thu, 30 Jul 2015 20:59:02 +0000 (08:59 +1200)
Patch from Craig Holmquist.

Lib/imaplib.py
Lib/test/test_imaplib.py
Misc/ACKS
Misc/NEWS

index 4d9df55dc3c3ce8b008bf42c88d2afe5dc6afca2..eb05dcb4f1909fbc639ea22a286f3c3f7a860cb9 100644 (file)
@@ -1306,7 +1306,7 @@ class _Authenticator:
     def process(self, data):
         ret = self.mech(self.decode(data))
         if ret is None:
-            return '*'      # Abort conversation
+            return b'*'     # Abort conversation
         return self.encode(ret)
 
     def encode(self, inp):
index b34e652347fcad871dc5eea97014b3921b4bdf3d..96b4f32316c713bad0d478edc5f49eb806a1901d 100644 (file)
@@ -325,6 +325,25 @@ class BaseThreadedNetworkedTests(unittest.TestCase):
             self.assertEqual(ret, "OK")
 
 
+
+    @reap_threads
+    def test_aborted_authentication(self):
+
+        class MyServer(SimpleIMAPHandler):
+
+            def cmd_AUTHENTICATE(self, tag, args):
+                self._send_textline('+')
+                self.response = yield
+
+                if self.response == b'*\r\n':
+                    self._send_tagged(tag, 'NO', '[AUTHENTICATIONFAILED] aborted')
+                else:
+                    self._send_tagged(tag, 'OK', 'MYAUTH successful')
+
+        with self.reaped_pair(MyServer) as (server, client):
+            with self.assertRaises(imaplib.IMAP4.error):
+                code, data = client.authenticate('MYAUTH', lambda x: None)
+
     def test_linetoolong(self):
         class TooLongHandler(SimpleIMAPHandler):
             def handle(self):
index f31249e702504bf382508f44d32836b2ee495e35..de33df13785dfa5cbc436aa2462d19073b6836a0 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -592,6 +592,7 @@ Gerrit Holl
 Shane Holloway
 Rune Holm
 Thomas Holmes
+Craig Holmquist
 Philip Homburg
 Naofumi Honda
 Jeffrey Honig
index 38bdccba3d40b9218f38bd24b295df27c015d58d..6798182a9900f3ee13b880151e25353cef4e1d08 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -66,6 +66,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #23779: imaplib raises TypeError if authenticator tries to abort.
+  Patch from Craig Holmquist.
+
 - Issue #23319: Fix ctypes.BigEndianStructure, swap correctly bytes. Patch
   written by Matthieu Gautier.