]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-95280: Fix test_get_ciphers on systems without RSA key exchange (GH-95282) (GH...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 29 Jul 2022 15:20:06 +0000 (08:20 -0700)
committerGitHub <noreply@github.com>
Fri, 29 Jul 2022 15:20:06 +0000 (17:20 +0200)
(cherry picked from commit 565403038b75eb64ea483b2757ba30769246d853)

Co-authored-by: Christian Heimes <christian@python.org>
Lib/test/test_ssl.py
Misc/NEWS.d/next/Tests/2022-07-26-15-22-19.gh-issue-95280.h8HvbP.rst [new file with mode: 0644]

index 1f8c30c51aa8763ad8c9e0d41ba26d396a861765..6faa2ee0bbe6b5054ccf6754d3ff40ee2e422f30 100644 (file)
@@ -1169,8 +1169,20 @@ class ContextTests(unittest.TestCase):
         ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
         ctx.set_ciphers('AESGCM')
         names = set(d['name'] for d in ctx.get_ciphers())
-        self.assertIn('AES256-GCM-SHA384', names)
-        self.assertIn('AES128-GCM-SHA256', names)
+        expected = {
+            'AES128-GCM-SHA256',
+            'ECDHE-ECDSA-AES128-GCM-SHA256',
+            'ECDHE-RSA-AES128-GCM-SHA256',
+            'DHE-RSA-AES128-GCM-SHA256',
+            'AES256-GCM-SHA384',
+            'ECDHE-ECDSA-AES256-GCM-SHA384',
+            'ECDHE-RSA-AES256-GCM-SHA384',
+            'DHE-RSA-AES256-GCM-SHA384',
+        }
+        intersection = names.intersection(expected)
+        self.assertGreaterEqual(
+            len(intersection), 2, f"\ngot: {sorted(names)}\nexpected: {sorted(expected)}"
+        )
 
     def test_options(self):
         ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
diff --git a/Misc/NEWS.d/next/Tests/2022-07-26-15-22-19.gh-issue-95280.h8HvbP.rst b/Misc/NEWS.d/next/Tests/2022-07-26-15-22-19.gh-issue-95280.h8HvbP.rst
new file mode 100644 (file)
index 0000000..523d9d5
--- /dev/null
@@ -0,0 +1,2 @@
+Fix problem with ``test_ssl`` ``test_get_ciphers`` on systems that require
+perfect forward secrecy (PFS) ciphers.