diff options
author | Giampaolo RodolĂ <g.rodola@gmail.com> | 2010-05-26 18:06:04 (GMT) |
---|---|---|
committer | Giampaolo RodolĂ <g.rodola@gmail.com> | 2010-05-26 18:06:04 (GMT) |
commit | a67299e757b69660ec932e4da0a7dd4bfc680f08 (patch) | |
tree | 8ed4df6f8163b832625b232b19c46ac12bd26899 /Lib/test | |
parent | 60853211da1d3c450b6371ebfaedade04a908f21 (diff) | |
download | cpython-a67299e757b69660ec932e4da0a7dd4bfc680f08.zip cpython-a67299e757b69660ec932e4da0a7dd4bfc680f08.tar.gz cpython-a67299e757b69660ec932e4da0a7dd4bfc680f08.tar.bz2 |
Fix issue #8806: add SSL contexts support to ftplib
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_ftplib.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_ftplib.py b/Lib/test/test_ftplib.py index eb33526..9dc06cd 100644 --- a/Lib/test/test_ftplib.py +++ b/Lib/test/test_ftplib.py @@ -719,6 +719,29 @@ class TestTLS_FTPClass(TestCase): finally: self.client.ssl_version = ssl.PROTOCOL_TLSv1 + def test_context(self): + self.client.quit() + ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) + self.assertRaises(ValueError, ftplib.FTP_TLS, keyfile=CERTFILE, + context=ctx) + self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE, + context=ctx) + self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE, + keyfile=CERTFILE, context=ctx) + + self.client = ftplib.FTP_TLS(context=ctx, timeout=2) + self.client.connect(self.server.host, self.server.port) + self.assertNotIsInstance(self.client.sock, ssl.SSLSocket) + self.client.auth() + self.assertIs(self.client.sock.context, ctx) + self.assertIsInstance(self.client.sock, ssl.SSLSocket) + + self.client.prot_p() + sock = self.client.transfercmd('list') + self.assertIs(self.client.sock.context, ctx) + self.assertIsInstance(sock, ssl.SSLSocket) + sock.close() + class TestTimeouts(TestCase): |