diff options
author | Giampaolo RodolĂ <g.rodola@gmail.com> | 2010-08-17 16:09:53 (GMT) |
---|---|---|
committer | Giampaolo RodolĂ <g.rodola@gmail.com> | 2010-08-17 16:09:53 (GMT) |
commit | 42382fedccf1306c09055b68c0b67351118f8065 (patch) | |
tree | e92e9f677adda02bbfb194aabfe3dc0e4eabe584 /Lib/test/test_poplib.py | |
parent | ccfb91c89f9d7515356f31fff4af4c5cbd5eef7a (diff) | |
download | cpython-42382fedccf1306c09055b68c0b67351118f8065.zip cpython-42382fedccf1306c09055b68c0b67351118f8065.tar.gz cpython-42382fedccf1306c09055b68c0b67351118f8065.tar.bz2 |
fix issue #8807: adds a context parameter to POP3_SSL class.
Diffstat (limited to 'Lib/test/test_poplib.py')
-rw-r--r-- | Lib/test/test_poplib.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/Lib/test/test_poplib.py b/Lib/test/test_poplib.py index c831fb4..2adc849 100644 --- a/Lib/test/test_poplib.py +++ b/Lib/test/test_poplib.py @@ -122,6 +122,7 @@ class DummyPOP3Server(asyncore.dispatcher, threading.Thread): self.active = False self.active_lock = threading.Lock() self.host, self.port = self.socket.getsockname()[:2] + self.handler_instance = None def start(self): assert not self.active @@ -145,8 +146,7 @@ class DummyPOP3Server(asyncore.dispatcher, threading.Thread): def handle_accept(self): conn, addr = self.accept() - self.handler = self.handler(conn) - self.close() + self.handler_instance = self.handler(conn) def handle_connect(self): self.close() @@ -287,6 +287,23 @@ if hasattr(poplib, 'POP3_SSL'): def test__all__(self): self.assertIn('POP3_SSL', poplib.__all__) + def test_context(self): + ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) + self.assertRaises(ValueError, poplib.POP3_SSL, self.server.host, + self.server.port, keyfile=CERTFILE, context=ctx) + self.assertRaises(ValueError, poplib.POP3_SSL, self.server.host, + self.server.port, certfile=CERTFILE, context=ctx) + self.assertRaises(ValueError, poplib.POP3_SSL, self.server.host, + self.server.port, keyfile=CERTFILE, + certfile=CERTFILE, context=ctx) + + self.client.quit() + self.client = poplib.POP3_SSL(self.server.host, self.server.port, + context=ctx) + self.assertIsInstance(self.client.sock, ssl.SSLSocket) + self.assertIs(self.client.sock.context, ctx) + self.assertTrue(self.client.noop().startswith(b'+OK')) + class TestTimeouts(TestCase): |