Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(34)

Unified Diff: Lib/test/test_ssl.py

Issue 19689: ssl.create_default_context()
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/ssl.py ('k') | Lib/urllib/request.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_ssl.py Fri Nov 22 16:20:53 2013 +0100
+++ b/Lib/test/test_ssl.py Fri Nov 22 18:04:20 2013 +0100
@@ -607,6 +607,29 @@
with self.assertRaisesRegex(ValueError, "unknown object 'serverauth'"):
ssl._ASN1Object.fromname('serverauth')
+ def test_create_default_context(self):
+ ctx = ssl.create_default_context()
+ self.assertEqual(ctx.protocol, ssl.PROTOCOL_SSLv23)
+ self.assertEqual(ctx.verify_mode, ssl.CERT_NONE)
+ self.assertEqual(ctx.options & ssl.OP_NO_SSLv2, ssl.OP_NO_SSLv2)
+
+ ctx = ssl.create_default_context(ssl.PROTOCOL_TLSv1)
+ self.assertEqual(ctx.protocol, ssl.PROTOCOL_TLSv1)
+ self.assertEqual(ctx.verify_mode, ssl.CERT_NONE)
+ self.assertEqual(ctx.options & ssl.OP_NO_SSLv2, ssl.OP_NO_SSLv2)
+
+ ctx = ssl.create_default_context(ssl.PROTOCOL_TLSv1_1,
+ cert_reqs=ssl.CERT_REQUIRED)
+ self.assertEqual(ctx.protocol, ssl.PROTOCOL_TLSv1_1)
+ self.assertEqual(ctx.verify_mode, ssl.CERT_REQUIRED)
+ self.assertEqual(ctx.options & ssl.OP_NO_SSLv2, ssl.OP_NO_SSLv2)
+
+ ctx = ssl.create_default_context(certfile=CERTFILE)
+ ctx = ssl.create_default_context(certfile=ONLYCERT,
+ keyfile=ONLYKEY)
+ with self.assertRaises(FileNotFoundError):
+ ssl.create_default_context(certfile=WRONGCERT)
+
class ContextTests(unittest.TestCase):
« no previous file with comments | « Lib/ssl.py ('k') | Lib/urllib/request.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+