]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-43921: Fix test_ssl.test_pha_required_nocert() (GH-26489)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 2 Jun 2021 23:48:40 +0000 (16:48 -0700)
committerGitHub <noreply@github.com>
Wed, 2 Jun 2021 23:48:40 +0000 (16:48 -0700)
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@python.org>
Lib/test/test_ssl.py
Misc/NEWS.d/next/Tests/2021-06-02-17-41-42.bpo-43921.xP7yZ4.rst [new file with mode: 0644]

index 00d5eff81537d16285708428ff510c35b822ae82..fbd0131ea4f4108a4077e6fdc23875fab558c6ab 100644 (file)
@@ -4464,11 +4464,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 (file)
index 0000000..83146c7
--- /dev/null
@@ -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.