def test_authenticationChallengeDecodingException(self):
        """
        When decoding a base64 encoded authentication message from the server,
        decoding errors are logged and then the client closes the connection.
        """
        transport = StringTransportWithDisconnection()
        protocol = imap4.IMAP4Client()
        transport.protocol = protocol

        protocol.makeConnection(transport)
        protocol.lineReceived(
            b'* OK [CAPABILITY IMAP4rev1 IDLE NAMESPACE AUTH=CRAM-MD5] '
            b'Twisted IMAP4rev1 Ready')
        cAuth = imap4.CramMD5ClientAuthenticator(b'testuser')
        protocol.registerAuthenticator(cAuth)

        d = protocol.authenticate('secret')
        # Should really be something describing the base64 decode error.  See
        # #6021.
        self.assertFailure(d, error.ConnectionDone)

        protocol.dataReceived(b'+ Something bad! and bad\r\n')

        # This should not really be logged.  See #6021.
        logged = self.flushLoggedErrors(imap4.IllegalServerResponse)
        self.assertEqual(len(logged), 1)
        self.assertEqual(logged[0].value.args[0], b"Something bad! and bad")
        return d

        When decoding a base64 encoded authentication message from the server,
        decoding errors are logged and then the client closes the connection.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/mail/test/test_imap.py