summaryrefslogtreecommitdiff
path: root/Lib/test/test_ssl.py
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2013-12-05 07:41:08 +0100
committerChristian Heimes <christian@cheimes.de>2013-12-05 07:41:08 +0100
commit8e7f394282e783ab98353f718812f7fe437492bb (patch)
treebdc91132093a1d0100037a2052ebaaf53e32789e /Lib/test/test_ssl.py
parent647f120850bd60205c3daaa2352237d53b828218 (diff)
downloadcpython-git-8e7f394282e783ab98353f718812f7fe437492bb.tar.gz
Test SSLSock's context getter and setter
Diffstat (limited to 'Lib/test/test_ssl.py')
-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 4da31e1108..92dc31afa9 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: