[Python-checkins] bpo-37322: ssl test_pha_required_nocert() ignores expected SSLError (GH-14670)
Miss Islington (bot)
webhook-mailer at python.org
Tue Jul 9 08:55:14 EDT 2019
https://github.com/python/cpython/commit/4c403b8ca2d0ef44b691cceaeeac9e110fd3f05a
commit: 4c403b8ca2d0ef44b691cceaeeac9e110fd3f05a
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019-07-09T05:55:08-07:00
summary:
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).
(cherry picked from commit 73ea54620a6f91c3f2e53880373dd47813691a21)
Co-authored-by: Victor Stinner <vstinner at redhat.com>
files:
M Lib/test/test_ssl.py
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index f1b7aa731e9a..879d944f327e 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -4320,21 +4320,24 @@ def test_pha_required_nocert(self):
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:
More information about the Python-checkins
mailing list