Skip to content

Commit 516cda6

Browse files
committed
pythongh-94208: Add more TLS version/protocol checks for FreeBSD
Three test cases were failing on FreeBSD with latest OpenSSL.
1 parent e6391e0 commit 516cda6

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

Lib/test/test_ssl.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,8 @@ def test_openssl111_deprecations(self):
610610
)
611611

612612
for protocol in protocols:
613+
if not has_tls_protocol(protocol):
614+
continue
613615
with self.subTest(protocol=protocol):
614616
with self.assertWarns(DeprecationWarning) as cm:
615617
ssl.SSLContext(protocol)
@@ -619,6 +621,8 @@ def test_openssl111_deprecations(self):
619621
)
620622

621623
for version in versions:
624+
if not has_tls_version(version):
625+
continue
622626
with self.subTest(version=version):
623627
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
624628
with self.assertWarns(DeprecationWarning) as cm:
@@ -934,9 +938,10 @@ class ContextTests(unittest.TestCase):
934938

935939
def test_constructor(self):
936940
for protocol in PROTOCOLS:
937-
with warnings_helper.check_warnings():
938-
ctx = ssl.SSLContext(protocol)
939-
self.assertEqual(ctx.protocol, protocol)
941+
if has_tls_protocol(protocol):
942+
with warnings_helper.check_warnings():
943+
ctx = ssl.SSLContext(protocol)
944+
self.assertEqual(ctx.protocol, protocol)
940945
with warnings_helper.check_warnings():
941946
ctx = ssl.SSLContext()
942947
self.assertEqual(ctx.protocol, ssl.PROTOCOL_TLS)
@@ -1502,20 +1507,19 @@ def test_create_default_context(self):
15021507
self.assertEqual(ctx.verify_mode, ssl.CERT_NONE)
15031508
self._assert_context_options(ctx)
15041509

1505-
1506-
15071510
def test__create_stdlib_context(self):
15081511
ctx = ssl._create_stdlib_context()
15091512
self.assertEqual(ctx.protocol, ssl.PROTOCOL_TLS_CLIENT)
15101513
self.assertEqual(ctx.verify_mode, ssl.CERT_NONE)
15111514
self.assertFalse(ctx.check_hostname)
15121515
self._assert_context_options(ctx)
15131516

1514-
with warnings_helper.check_warnings():
1515-
ctx = ssl._create_stdlib_context(ssl.PROTOCOL_TLSv1)
1516-
self.assertEqual(ctx.protocol, ssl.PROTOCOL_TLSv1)
1517-
self.assertEqual(ctx.verify_mode, ssl.CERT_NONE)
1518-
self._assert_context_options(ctx)
1517+
if has_tls_protocol(ssl.PROTOCOL_TLSv1):
1518+
with warnings_helper.check_warnings():
1519+
ctx = ssl._create_stdlib_context(ssl.PROTOCOL_TLSv1)
1520+
self.assertEqual(ctx.protocol, ssl.PROTOCOL_TLSv1)
1521+
self.assertEqual(ctx.verify_mode, ssl.CERT_NONE)
1522+
self._assert_context_options(ctx)
15191523

15201524
with warnings_helper.check_warnings():
15211525
ctx = ssl._create_stdlib_context(
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
``test_ssl`` is now checking for supported TLS version and protocols in more
2+
tests.

0 commit comments

Comments
 (0)