mirror of
https://github.com/python/cpython.git
synced 2025-07-13 06:15:17 +00:00
bpo-37322: ssl test_pha_required_nocert() ignores expected SSLError (GH-14670)
test_ssl.test_pha_required_nocert() now uses support.catch_threading_exception() to ignore the expected SSLError in ConnectionHandler of ThreadedEchoServer (it is only raised sometimes on Windows).
This commit is contained in:
parent
430a9f44fe
commit
73ea54620a
1 changed files with 18 additions and 15 deletions
|
@ -4326,21 +4326,24 @@ class TestPostHandshakeAuth(unittest.TestCase):
|
||||||
server_context.verify_mode = ssl.CERT_REQUIRED
|
server_context.verify_mode = ssl.CERT_REQUIRED
|
||||||
client_context.post_handshake_auth = True
|
client_context.post_handshake_auth = True
|
||||||
|
|
||||||
server = ThreadedEchoServer(context=server_context, chatty=False)
|
# Ignore expected SSLError in ConnectionHandler of ThreadedEchoServer
|
||||||
with server:
|
# (it is only raised sometimes on Windows)
|
||||||
with client_context.wrap_socket(socket.socket(),
|
with support.catch_threading_exception() as cm:
|
||||||
server_hostname=hostname) as s:
|
server = ThreadedEchoServer(context=server_context, chatty=False)
|
||||||
s.connect((HOST, server.port))
|
with server:
|
||||||
s.write(b'PHA')
|
with client_context.wrap_socket(socket.socket(),
|
||||||
# receive CertificateRequest
|
server_hostname=hostname) as s:
|
||||||
self.assertEqual(s.recv(1024), b'OK\n')
|
s.connect((HOST, server.port))
|
||||||
# send empty Certificate + Finish
|
s.write(b'PHA')
|
||||||
s.write(b'HASCERT')
|
# receive CertificateRequest
|
||||||
# receive alert
|
self.assertEqual(s.recv(1024), b'OK\n')
|
||||||
with self.assertRaisesRegex(
|
# send empty Certificate + Finish
|
||||||
ssl.SSLError,
|
s.write(b'HASCERT')
|
||||||
'tlsv13 alert certificate required'):
|
# receive alert
|
||||||
s.recv(1024)
|
with self.assertRaisesRegex(
|
||||||
|
ssl.SSLError,
|
||||||
|
'tlsv13 alert certificate required'):
|
||||||
|
s.recv(1024)
|
||||||
|
|
||||||
def test_pha_optional(self):
|
def test_pha_optional(self):
|
||||||
if support.verbose:
|
if support.verbose:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue