summaryrefslogtreecommitdiff
path: root/Lib/test/test_imaplib.py
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2011-10-19 11:06:26 +0300
committerEzio Melotti <ezio.melotti@gmail.com>2011-10-19 11:06:26 +0300
commit2b4338c5e090fa94a32d5cd7154aef5dfe25e6da (patch)
tree665a409563a70f93da9fb962f7a7da81aee8b93f /Lib/test/test_imaplib.py
parent0ab6fc6fe33837bc950d2cb0a5cf2a25579f8f3e (diff)
parent22388c044ed1680554f5c8b1ef9dc1deaa84ad08 (diff)
downloadcpython-2b4338c5e090fa94a32d5cd7154aef5dfe25e6da.tar.gz
Merge with 3.2.
Diffstat (limited to 'Lib/test/test_imaplib.py')
-rw-r--r--Lib/test/test_imaplib.py55
1 files changed, 51 insertions, 4 deletions
diff --git a/Lib/test/test_imaplib.py b/Lib/test/test_imaplib.py
index 80340004d7..c4c7eccb00 100644
--- a/Lib/test/test_imaplib.py
+++ b/Lib/test/test_imaplib.py
@@ -258,11 +258,58 @@ class RemoteIMAP_SSLTest(RemoteIMAPTest):
port = 993
imap_class = IMAP4_SSL
+ def setUp(self):
+ pass
+
+ def tearDown(self):
+ pass
+
+ def create_ssl_context(self):
+ ssl_context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ ssl_context.load_cert_chain(CERTFILE)
+ return ssl_context
+
+ def check_logincapa(self, server):
+ try:
+ for cap in server.capabilities:
+ self.assertIsInstance(cap, str)
+ self.assertFalse('LOGINDISABLED' in server.capabilities)
+ self.assertTrue('AUTH=PLAIN' in server.capabilities)
+ rs = server.login(self.username, self.password)
+ self.assertEqual(rs[0], 'OK')
+ finally:
+ server.logout()
+
def test_logincapa(self):
- for cap in self.server.capabilities:
- self.assertIsInstance(cap, str)
- self.assertFalse('LOGINDISABLED' in self.server.capabilities)
- self.assertTrue('AUTH=PLAIN' in self.server.capabilities)
+ with transient_internet(self.host):
+ _server = self.imap_class(self.host, self.port)
+ self.check_logincapa(_server)
+
+ def test_logincapa_with_client_certfile(self):
+ with transient_internet(self.host):
+ _server = self.imap_class(self.host, self.port, certfile=CERTFILE)
+ self.check_logincapa(_server)
+
+ def test_logincapa_with_client_ssl_context(self):
+ with transient_internet(self.host):
+ _server = self.imap_class(self.host, self.port, ssl_context=self.create_ssl_context())
+ self.check_logincapa(_server)
+
+ def test_logout(self):
+ with transient_internet(self.host):
+ _server = self.imap_class(self.host, self.port)
+ rs = _server.logout()
+ self.assertEqual(rs[0], 'BYE')
+
+ def test_ssl_context_certfile_exclusive(self):
+ with transient_internet(self.host):
+ self.assertRaises(ValueError, self.imap_class, self.host, self.port,
+ certfile=CERTFILE, ssl_context=self.create_ssl_context())
+
+ def test_ssl_context_keyfile_exclusive(self):
+ with transient_internet(self.host):
+ self.assertRaises(ValueError, self.imap_class, self.host, self.port,
+ keyfile=CERTFILE, ssl_context=self.create_ssl_context())
def test_main():