@@ -26,11 +26,11 @@ def test_tls_disabled(host: str, protocol_name: str):
26
26
27
27
with pytest .raises (ssl .SSLError ):
28
28
context = ssl .SSLContext (protocol )
29
- with socket .create_connection ((str (host ), PORT ), timeout = 10 ) as sock :
30
- with context .wrap_socket (sock , server_hostname = str (host )) as ssock :
31
- ssock .do_handshake ()
32
- # If we reach this point, the protocol is enabled (test should fail)
33
- pytest .fail (f"Protocol { protocol } should be disabled but connection succeeded" )
29
+ with socket .create_connection ((str (host ), PORT ), timeout = 10 ) as sock , \
30
+ context .wrap_socket (sock , server_hostname = str (host )) as ssock :
31
+ ssock .do_handshake ()
32
+ # If we reach this point, the protocol is enabled (test should fail)
33
+ pytest .fail (f"Protocol { protocol } should be disabled but connection succeeded" )
34
34
35
35
@pytest .mark .parametrize ("protocol_name" , ["TLSv1.2" ])
36
36
def test_enabled (host : str , protocol_name : str ):
@@ -48,9 +48,9 @@ def test_enabled(host: str, protocol_name: str):
48
48
49
49
try :
50
50
context = ssl .SSLContext (protocol )
51
- with socket .create_connection ((str (host ), PORT ), timeout = 10 ) as sock :
52
- with context .wrap_socket (sock , server_hostname = str (host )) as ssock :
53
- ssock .do_handshake ()
54
- assert ssock .version ()
51
+ with socket .create_connection ((str (host ), PORT ), timeout = 10 ) as sock , \
52
+ context .wrap_socket (sock , server_hostname = str (host )) as ssock :
53
+ ssock .do_handshake ()
54
+ assert ssock .version ()
55
55
except ssl .SSLError as e :
56
56
pytest .fail (f"{ protocol_name } should be enabled, but got SSLError: { e } " )
0 commit comments