Skip to content

Commit ba0d542

Browse files
committed
Add some type annotations
1 parent 9f5a6a0 commit ba0d542

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

tests/ssl_client_test.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
# TODO(AD): Switch to legacy server and add a TODO; skip tests for TLS 1.3
3333
@pytest.mark.parametrize("ssl_client_cls", [SslClient, LegacySslClient])
3434
class TestSslClientClientAuthentication:
35-
def test_client_authentication_no_certificate_supplied(self, ssl_client_cls):
35+
def test_client_authentication_no_certificate_supplied(self, ssl_client_cls) -> None:
3636
# Given a server that requires client authentication
3737
with LegacyOpenSslServer(client_auth_config=ClientAuthConfigEnum.REQUIRED) as server:
3838
# And the client does NOT provide a client certificate
@@ -51,7 +51,7 @@ def test_client_authentication_no_certificate_supplied(self, ssl_client_cls):
5151

5252
ssl_client.shutdown()
5353

54-
def test_client_authentication_no_certificate_supplied_but_ignore(self, ssl_client_cls):
54+
def test_client_authentication_no_certificate_supplied_but_ignore(self, ssl_client_cls) -> None:
5555
# Given a server that accepts optional client authentication
5656
with LegacyOpenSslServer(client_auth_config=ClientAuthConfigEnum.OPTIONAL) as server:
5757
# And the client does NOT provide a client cert but is configured to ignore the client auth request
@@ -71,7 +71,7 @@ def test_client_authentication_no_certificate_supplied_but_ignore(self, ssl_clie
7171
finally:
7272
ssl_client.shutdown()
7373

74-
def test_client_authentication_succeeds(self, ssl_client_cls):
74+
def test_client_authentication_succeeds(self, ssl_client_cls) -> None:
7575
# Given a server that requires client authentication
7676
with LegacyOpenSslServer(client_auth_config=ClientAuthConfigEnum.REQUIRED) as server:
7777
# And the client provides a client certificate
@@ -96,7 +96,7 @@ def test_client_authentication_succeeds(self, ssl_client_cls):
9696

9797
@pytest.mark.parametrize("ssl_client_cls", [SslClient, LegacySslClient])
9898
class TestSslClientOnline:
99-
def test(self, ssl_client_cls):
99+
def test(self, ssl_client_cls) -> None:
100100
# Given an SslClient connecting to Google
101101
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
102102
sock.settimeout(5)
@@ -123,7 +123,7 @@ def test(self, ssl_client_cls):
123123
finally:
124124
ssl_client.shutdown()
125125

126-
def test_get_dh_info_ecdh(self, ssl_client_cls):
126+
def test_get_dh_info_ecdh(self, ssl_client_cls) -> None:
127127
with LegacyOpenSslServer(cipher="ECDHE-RSA-AES256-SHA") as server:
128128
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
129129
sock.settimeout(5)
@@ -149,7 +149,7 @@ def test_get_dh_info_ecdh(self, ssl_client_cls):
149149
assert len(dh_info.x) > 0
150150
assert len(dh_info.y) > 0
151151

152-
def test_get_dh_info_dh(self, ssl_client_cls):
152+
def test_get_dh_info_dh(self, ssl_client_cls) -> None:
153153
with LegacyOpenSslServer(cipher="DHE-RSA-AES256-SHA") as server:
154154
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
155155
sock.settimeout(5)
@@ -175,7 +175,7 @@ def test_get_dh_info_dh(self, ssl_client_cls):
175175
assert len(dh_info.prime) > 0
176176
assert len(dh_info.generator) > 0
177177

178-
def test_get_dh_info_no_dh(self, ssl_client_cls):
178+
def test_get_dh_info_no_dh(self, ssl_client_cls) -> None:
179179
with LegacyOpenSslServer(cipher="AES256-SHA") as server:
180180
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
181181
sock.settimeout(5)
@@ -198,7 +198,7 @@ def test_get_dh_info_no_dh(self, ssl_client_cls):
198198

199199

200200
class TestModernSslClientOnline:
201-
def test_get_verified_chain(self):
201+
def test_get_verified_chain(self) -> None:
202202
# Given an SslClient connecting to Google
203203
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
204204
sock.settimeout(5)
@@ -221,7 +221,7 @@ def test_get_verified_chain(self):
221221
finally:
222222
ssl_client.shutdown()
223223

224-
def test_get_verified_chain_but_validation_failed(self):
224+
def test_get_verified_chain_but_validation_failed(self) -> None:
225225
# Given an SslClient connecting to Google
226226
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
227227
sock.settimeout(5)
@@ -245,7 +245,7 @@ def test_get_verified_chain_but_validation_failed(self):
245245
finally:
246246
ssl_client.shutdown()
247247

248-
def test_get_dh_info_ecdh_p256(self):
248+
def test_get_dh_info_ecdh_p256(self) -> None:
249249
with ModernOpenSslServer(cipher="ECDHE-RSA-AES256-SHA", groups="P-256") as server:
250250
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
251251
sock.settimeout(5)
@@ -272,7 +272,7 @@ def test_get_dh_info_ecdh_p256(self):
272272
assert len(dh_info.x) == 32
273273
assert len(dh_info.y) == 32
274274

275-
def test_get_dh_info_ecdh_x25519(self):
275+
def test_get_dh_info_ecdh_x25519(self) -> None:
276276
with ModernOpenSslServer(cipher="ECDHE-RSA-AES256-SHA", groups="X25519") as server:
277277
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
278278
sock.settimeout(5)
@@ -297,7 +297,7 @@ def test_get_dh_info_ecdh_x25519(self):
297297
assert dh_info.curve == OpenSslEcNidEnum.X25519
298298
assert len(dh_info.public_bytes) == 32
299299

300-
def test_set_groups_curve_secp192k1(self):
300+
def test_set_groups_curve_secp192k1(self) -> None:
301301
# Given a server that supports a bunch of curves
302302
with ModernOpenSslServer(
303303
cipher="ECDHE-RSA-AES256-SHA",
@@ -327,7 +327,7 @@ def test_set_groups_curve_secp192k1(self):
327327
assert isinstance(dh_info, EcDhEphemeralKeyInfo)
328328
assert dh_info.curve == configured_curve
329329

330-
def test_set_groups_curve_x448(self):
330+
def test_set_groups_curve_x448(self) -> None:
331331
# Given a server that supports a bunch of curves
332332
with ModernOpenSslServer(
333333
cipher="ECDHE-RSA-AES256-SHA",
@@ -360,7 +360,7 @@ def test_set_groups_curve_x448(self):
360360
assert dh_info.size == 448
361361
assert len(dh_info.public_bytes) == 56
362362

363-
def test_get_extended_master_secret_not_used(self):
363+
def test_get_extended_master_secret_not_used(self) -> None:
364364
with LegacyOpenSslServer() as server:
365365
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
366366
sock.settimeout(5)
@@ -382,7 +382,7 @@ def test_get_extended_master_secret_not_used(self):
382382
exms_support = ssl_client.get_extended_master_secret_support()
383383
assert exms_support == ExtendedMasterSecretSupportEnum.NOT_USED_IN_CURRENT_SESSION
384384

385-
def test_get_extended_master_secret_used(self):
385+
def test_get_extended_master_secret_used(self) -> None:
386386
with ModernOpenSslServer() as server:
387387
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
388388
sock.settimeout(5)
@@ -404,7 +404,7 @@ def test_get_extended_master_secret_used(self):
404404

405405

406406
class TestLegacySslClientOnline:
407-
def test_ssl_2(self):
407+
def test_ssl_2(self) -> None:
408408
# Given a server that supports SSL 2.0
409409
with LegacyOpenSslServer() as server:
410410
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@@ -425,7 +425,7 @@ def test_ssl_2(self):
425425

426426

427427
class TestModernSslClientOnlineTls13:
428-
def test(self):
428+
def test(self) -> None:
429429
# Given a server that supports TLS 1.3
430430
with ModernOpenSslServer() as server:
431431
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@@ -443,7 +443,7 @@ def test(self):
443443
finally:
444444
ssl_client.shutdown()
445445

446-
def test_set_ciphersuites(self):
446+
def test_set_ciphersuites(self) -> None:
447447
# Given a server that supports TLS 1.3
448448
with ModernOpenSslServer() as server:
449449
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@@ -489,7 +489,7 @@ def _create_tls_1_3_session(server_host: str, server_port: int) -> _nassl.SSL_SE
489489
ssl_client.shutdown()
490490
return session
491491

492-
def test_write_early_data_does_not_finish_handshake(self):
492+
def test_write_early_data_does_not_finish_handshake(self) -> None:
493493
# Given a server that supports TLS 1.3 and early data
494494
with ModernOpenSslServer(max_early_data=512) as server:
495495
# That has a previous TLS 1.3 session with the server
@@ -528,7 +528,7 @@ def test_write_early_data_does_not_finish_handshake(self):
528528

529529
ssl_client_early_data.shutdown()
530530

531-
def test_write_early_data_fail_when_used_on_non_reused_session(self):
531+
def test_write_early_data_fail_when_used_on_non_reused_session(self) -> None:
532532
# Given a server that supports TLS 1.3 and early data
533533
with ModernOpenSslServer(max_early_data=512) as server:
534534
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@@ -549,7 +549,7 @@ def test_write_early_data_fail_when_used_on_non_reused_session(self):
549549

550550
ssl_client.shutdown()
551551

552-
def test_write_early_data_fail_when_trying_to_send_more_than_max_early_data(self):
552+
def test_write_early_data_fail_when_trying_to_send_more_than_max_early_data(self) -> None:
553553
# Given a server that supports TLS 1.3 and early data
554554
with ModernOpenSslServer(max_early_data=1) as server:
555555
# That has a previous TLS 1.3 session with the server
@@ -584,7 +584,7 @@ def test_write_early_data_fail_when_trying_to_send_more_than_max_early_data(self
584584

585585
ssl_client_early_data.shutdown()
586586

587-
def test_client_authentication(self):
587+
def test_client_authentication(self) -> None:
588588
# Given a server that requires client authentication
589589
with ModernOpenSslServer(client_auth_config=ClientAuthConfigEnum.REQUIRED) as server:
590590
# And the client provides an invalid client certificate (actually the server cert)

0 commit comments

Comments
 (0)