summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2013-12-05 06:41:08 (GMT)
committerChristian Heimes <christian@cheimes.de>2013-12-05 06:41:08 (GMT)
commit8e7f394282e783ab98353f718812f7fe437492bb (patch)
treebdc91132093a1d0100037a2052ebaaf53e32789e
parent647f120850bd60205c3daaa2352237d53b828218 (diff)
downloadcpython-8e7f394282e783ab98353f718812f7fe437492bb.zip
cpython-8e7f394282e783ab98353f718812f7fe437492bb.tar.gz
cpython-8e7f394282e783ab98353f718812f7fe437492bb.tar.bz2
Test SSLSock's context getter and setter
-rw-r--r--Lib/test/test_ssl.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index 4da31e1..92dc31a 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -1419,6 +1419,20 @@ class NetworkedTests(unittest.TestCase):
s.close()
self.assertEqual(len(ctx.get_ca_certs()), 1)
+ def test_context_setget(self):
+ # Check that the context of a connected socket can be replaced.
+ with support.transient_internet("svn.python.org"):
+ ctx1 = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ ctx2 = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ s = socket.socket(socket.AF_INET)
+ with ctx1.wrap_socket(s) as ss:
+ ss.connect(("svn.python.org", 443))
+ self.assertIs(ss.context, ctx1)
+ self.assertIs(ss._sslobj.context, ctx1)
+ ss.context = ctx2
+ self.assertIs(ss.context, ctx2)
+ self.assertIs(ss._sslobj.context, ctx2)
+
try:
import threading
except ImportError: