Issue #23779: imaplib raises TypeError if authenticator tries to abort.

Patch from Craig Holmquist.
This commit is contained in:
Robert Collins 2015-07-31 09:01:38 +12:00
commit 78378e8939
4 changed files with 25 additions and 1 deletions

View File

@ -1353,7 +1353,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):

View File

@ -419,6 +419,26 @@ class ThreadedNetworkedTests(unittest.TestCase):
ret, data = client.login_cram_md5("tim", b"tanstaaftanstaaf")
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):

View File

@ -603,6 +603,7 @@ Gerrit Holl
Shane Holloway
Rune Holm
Thomas Holmes
Craig Holmquist
Philip Homburg
Naofumi Honda
Jeffrey Honig

View File

@ -13,6 +13,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.