Issue #4471: Add the IMAP.starttls() method to enable encryption on

standard IMAP4 connections.  Original patch by Lorenzo M. Catucci.
This commit is contained in:
Antoine Pitrou 2010-11-12 18:49:16 +00:00
parent e0bf419ae7
commit f3b001f966
4 changed files with 63 additions and 8 deletions

View file

@ -209,8 +209,6 @@ class RemoteIMAPTest(unittest.TestCase):
def test_logincapa(self):
self.assertTrue('LOGINDISABLED' in self.server.capabilities)
def test_anonlogin(self):
self.assertTrue('AUTH=ANONYMOUS' in self.server.capabilities)
rs = self.server.login(self.username, self.password)
self.assertEqual(rs[0], 'OK')
@ -221,6 +219,18 @@ class RemoteIMAPTest(unittest.TestCase):
self.assertEqual(rs[0], 'BYE')
@unittest.skipUnless(ssl, "SSL not available")
class RemoteIMAP_STARTTLSTest(RemoteIMAPTest):
def setUp(self):
super().setUp()
rs = self.server.starttls()
self.assertEqual(rs[0], 'OK')
def test_logincapa(self):
self.assertFalse('LOGINDISABLED' in self.server.capabilities)
@unittest.skipUnless(ssl, "SSL not available")
class RemoteIMAP_SSLTest(RemoteIMAPTest):
port = 993
@ -243,7 +253,7 @@ def test_main():
raise support.TestFailed("Can't read certificate files!")
tests.extend([
ThreadedNetworkedTests, ThreadedNetworkedTestsSSL,
RemoteIMAPTest, RemoteIMAP_SSLTest,
RemoteIMAPTest, RemoteIMAP_SSLTest, RemoteIMAP_STARTTLSTest,
])
support.run_unittest(*tests)