]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-43921: Fix test_ssl.test_pha_required_nocert() (GH-26489)
authorVictor Stinner <vstinner@python.org>
Wed, 2 Jun 2021 20:25:26 +0000 (22:25 +0200)
committerGitHub <noreply@github.com>
Wed, 2 Jun 2021 20:25:26 +0000 (22:25 +0200)
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
Misc/NEWS.d/next/Tests/2021-06-02-17-41-42.bpo-43921.xP7yZ4.rst [new file with mode: 0644]

index 0d38d7756fdc72b7d8fdfd630baed9e92489827e..2df62329411889bc5d2d1e6d8177844048e42af6 100644 (file)
@@ -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 (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.