diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-07-09 12:33:49 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-09 12:33:49 (GMT) |
commit | 73ea54620a6f91c3f2e53880373dd47813691a21 (patch) | |
tree | e2c29b81ebc31d25b0eb3103bbe1d3f42a5ca67c | |
parent | 430a9f44fe22f029ae8cfeecb46621d7e199414b (diff) | |
download | cpython-73ea54620a6f91c3f2e53880373dd47813691a21.zip cpython-73ea54620a6f91c3f2e53880373dd47813691a21.tar.gz cpython-73ea54620a6f91c3f2e53880373dd47813691a21.tar.bz2 |
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).
-rw-r--r-- | Lib/test/test_ssl.py | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index d2b9e20..afc5be9 100644 --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -4326,21 +4326,24 @@ class TestPostHandshakeAuth(unittest.TestCase): server_context.verify_mode = ssl.CERT_REQUIRED client_context.post_handshake_auth = True - server = ThreadedEchoServer(context=server_context, chatty=False) - with server: - with client_context.wrap_socket(socket.socket(), - server_hostname=hostname) as s: - s.connect((HOST, server.port)) - s.write(b'PHA') - # receive CertificateRequest - self.assertEqual(s.recv(1024), b'OK\n') - # send empty Certificate + Finish - s.write(b'HASCERT') - # receive alert - with self.assertRaisesRegex( - ssl.SSLError, - 'tlsv13 alert certificate required'): - s.recv(1024) + # Ignore expected SSLError in ConnectionHandler of ThreadedEchoServer + # (it is only raised sometimes on Windows) + with support.catch_threading_exception() as cm: + server = ThreadedEchoServer(context=server_context, chatty=False) + with server: + with client_context.wrap_socket(socket.socket(), + server_hostname=hostname) as s: + s.connect((HOST, server.port)) + s.write(b'PHA') + # receive CertificateRequest + self.assertEqual(s.recv(1024), b'OK\n') + # send empty Certificate + Finish + s.write(b'HASCERT') + # receive alert + with self.assertRaisesRegex( + ssl.SSLError, + 'tlsv13 alert certificate required'): + s.recv(1024) def test_pha_optional(self): if support.verbose: |