From 320eaa7f42b413cd5e5436ec92d4dc5ba150395f Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 2 Jun 2021 22:25:26 +0200 Subject: 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). --- Lib/test/test_ssl.py | 11 +++++++++-- .../next/Tests/2021-06-02-17-41-42.bpo-43921.xP7yZ4.rst | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Tests/2021-06-02-17-41-42.bpo-43921.xP7yZ4.rst diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index 0d38d77..2df6232 100644 --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -4460,11 +4460,18 @@ class TestPostHandshakeAuth(unittest.TestCase): '(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 0000000..83146c7 --- /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. -- cgit v0.12