Skip to content

Commit

Permalink
Adjust PSK tests to use testing_context()
Browse files Browse the repository at this point in the history
  • Loading branch information
WillChilds-Klein committed Apr 11, 2024
1 parent cd1df26 commit 8b9a9b7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Lib/test/test_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -4364,14 +4364,14 @@ def test_session_handling(self):
def test_psk(self):
psk = bytes.fromhex('deadbeef')

client_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
client_context, server_context, _ = testing_context()

client_context.check_hostname = False
client_context.verify_mode = ssl.CERT_NONE
client_context.maximum_version = ssl.TLSVersion.TLSv1_2
client_context.set_ciphers('PSK')
client_context.set_psk_client_callback(lambda hint: (None, psk))

server_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
server_context.maximum_version = ssl.TLSVersion.TLSv1_2
server_context.set_ciphers('PSK')
server_context.set_psk_server_callback(lambda identity: psk)
Expand Down Expand Up @@ -4443,14 +4443,14 @@ def server_callback(identity):
self.assertEqual(identity, client_identity)
return psk

client_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
client_context, server_context, _ = testing_context()

client_context.check_hostname = False
client_context.verify_mode = ssl.CERT_NONE
client_context.minimum_version = ssl.TLSVersion.TLSv1_3
client_context.set_ciphers('PSK')
client_context.set_psk_client_callback(client_callback)

server_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
server_context.minimum_version = ssl.TLSVersion.TLSv1_3
server_context.set_ciphers('PSK')
server_context.set_psk_server_callback(server_callback, identity_hint)
Expand Down

0 comments on commit 8b9a9b7

Please sign in to comment.