[Python-checkins] bpo-43921: Fix test_ssl.test_pha_required_nocert() (GH-26489)
miss-islington
webhook-mailer at python.org
Wed Jun 2 19:48:44 EDT 2021
https://github.com/python/cpython/commit/e5e93e6145090a636e67766a53b758d7ac78e3ad
commit: e5e93e6145090a636e67766a53b758d7ac78e3ad
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2021-06-02T16:48:40-07:00
summary:
bpo-43921: Fix test_ssl.test_pha_required_nocert() (GH-26489)
Fix test_pha_required_nocert() of test_ssl: catch two more EOF cases
(when the recv() method returns an empty string).
(cherry picked from commit 320eaa7f42b413cd5e5436ec92d4dc5ba150395f)
Co-authored-by: Victor Stinner <vstinner at python.org>
files:
A Misc/NEWS.d/next/Tests/2021-06-02-17-41-42.bpo-43921.xP7yZ4.rst
M Lib/test/test_ssl.py
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index 00d5eff81537d1..fbd0131ea4f410 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -4464,11 +4464,18 @@ def msg_cb(conn, direction, version, content_type, msg_type, data):
'(certificate required|EOF occurred)'
):
# receive CertificateRequest
- self.assertEqual(s.recv(1024), b'OK\n')
+ data = s.recv(1024)
+ if not data:
+ raise ssl.SSLError(1, "EOF occurred")
+ self.assertEqual(data, b'OK\n')
+
# send empty Certificate + Finish
s.write(b'HASCERT')
+
# receive alert
- s.recv(1024)
+ data = s.recv(1024)
+ if not data:
+ raise ssl.SSLError(1, "EOF occurred")
def test_pha_optional(self):
if support.verbose:
diff --git a/Misc/NEWS.d/next/Tests/2021-06-02-17-41-42.bpo-43921.xP7yZ4.rst b/Misc/NEWS.d/next/Tests/2021-06-02-17-41-42.bpo-43921.xP7yZ4.rst
new file mode 100644
index 00000000000000..83146c78524671
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2021-06-02-17-41-42.bpo-43921.xP7yZ4.rst
@@ -0,0 +1,2 @@
+Fix test_pha_required_nocert() of test_ssl: catch two more EOF cases (when
+the ``recv()`` method returns an empty string). Patch by Victor Stinner.
More information about the Python-checkins
mailing list