Skip to content

Commit 7a8375a

Browse files
Extract supports_kx_aliases test util
1 parent 57317e2 commit 7a8375a

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

Lib/test/test_ssl.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2782,6 +2782,14 @@ def try_protocol_combo(server_protocol, client_protocol, expect_success,
27822782
% (expect_success, stats['version']))
27832783

27842784

2785+
def supports_kx_alias(ctx, aliases):
2786+
for cipher in ctx.get_ciphers():
2787+
for alias in aliases:
2788+
if f"Kx={alias}" in cipher['description']:
2789+
return True
2790+
return False
2791+
2792+
27852793
class ThreadedTests(unittest.TestCase):
27862794

27872795
@support.requires_resource('walltime')
@@ -4042,17 +4050,12 @@ def test_no_legacy_server_connect(self):
40424050
sni_name=hostname)
40434051

40444052
def test_dh_params(self):
4045-
# Check we can get a connection with ephemeral finite-field Diffie-
4046-
# Hellman (if supported).
4053+
# Check we can get a connection with ephemeral finite-field
4054+
# Diffie-Hellman (if supported).
40474055
client_context, server_context, hostname = testing_context()
40484056
dhe_aliases = {"ADH", "EDH", "DHE"}
4049-
def supports_dhe(ctx) -> bool:
4050-
for cipher in ctx.get_ciphers():
4051-
for alias in dhe_aliases:
4052-
if f"Kx={alias}" in cipher['description']:
4053-
return True
4054-
return False
4055-
if not (supports_dhe(client_context) and supports_dhe(server_context)):
4057+
if not (supports_kx_alias(client_context, dhe_aliases) and
4058+
supports_kx_alias(server_context, dhe_aliases)):
40564059
self.skipTest("libssl doesn't support ephemeral DH")
40574060
# test scenario needs TLS <= 1.2
40584061
client_context.maximum_version = ssl.TLSVersion.TLSv1_2

0 commit comments

Comments
 (0)