summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_ssl.py
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2021-05-02 07:47:45 (GMT)
committerGitHub <noreply@github.com>2021-05-02 07:47:45 (GMT)
commit91554e4c5ca3c762998296522f854a7166ba84f0 (patch)
treeaa6e08eedef59c4a4d5c750ed60e5d463f05a4ad /Lib/test/test_ssl.py
parentfd0bc7e7f4f2c7de98a1ebc7ad1ef65b8f8f7ad6 (diff)
downloadcpython-91554e4c5ca3c762998296522f854a7166ba84f0.zip
cpython-91554e4c5ca3c762998296522f854a7166ba84f0.tar.gz
cpython-91554e4c5ca3c762998296522f854a7166ba84f0.tar.bz2
bpo-43908: Mark ssl, hash, and hmac types as immutable (GH-25792)
Signed-off-by: Christian Heimes <christian@python.org>
Diffstat (limited to 'Lib/test/test_ssl.py')
-rw-r--r--Lib/test/test_ssl.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index f2b26c4..acb64f1 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -345,6 +345,25 @@ class BasicSocketTests(unittest.TestCase):
ssl.OP_NO_TLSv1_2
self.assertEqual(ssl.PROTOCOL_TLS, ssl.PROTOCOL_SSLv23)
+ def test_ssl_types(self):
+ ssl_types = [
+ _ssl._SSLContext,
+ _ssl._SSLSocket,
+ _ssl.MemoryBIO,
+ _ssl.Certificate,
+ _ssl.SSLSession,
+ _ssl.SSLError,
+ ]
+ for ssl_type in ssl_types:
+ with self.subTest(ssl_type=ssl_type):
+ with self.assertRaisesRegex(TypeError, "immutable type"):
+ ssl_type.value = None
+ with self.assertRaisesRegex(
+ TypeError,
+ "cannot create '_ssl.Certificate' instances"
+ ):
+ _ssl.Certificate()
+
def test_private_init(self):
with self.assertRaisesRegex(TypeError, "public constructor"):
with socket.socket() as s: