]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-108303: Move all certificates to `Lib/test/certdata/` (#109489)
authorNikita Sobolev <mail@sobolevn.me>
Sat, 16 Sep 2023 16:47:18 +0000 (19:47 +0300)
committerGitHub <noreply@github.com>
Sat, 16 Sep 2023 16:47:18 +0000 (18:47 +0200)
41 files changed:
Lib/test/certdata/allsans.pem [moved from Lib/test/allsans.pem with 100% similarity]
Lib/test/certdata/badcert.pem [moved from Lib/test/badcert.pem with 100% similarity]
Lib/test/certdata/badkey.pem [moved from Lib/test/badkey.pem with 100% similarity]
Lib/test/certdata/capath/4e1295a3.0 [moved from Lib/test/capath/4e1295a3.0 with 100% similarity]
Lib/test/certdata/capath/5ed36f99.0 [moved from Lib/test/capath/5ed36f99.0 with 100% similarity]
Lib/test/certdata/capath/6e88d7b8.0 [moved from Lib/test/capath/6e88d7b8.0 with 100% similarity]
Lib/test/certdata/capath/99d0fa06.0 [moved from Lib/test/capath/99d0fa06.0 with 100% similarity]
Lib/test/certdata/capath/b1930218.0 [moved from Lib/test/capath/b1930218.0 with 100% similarity]
Lib/test/certdata/capath/ceff1710.0 [moved from Lib/test/capath/ceff1710.0 with 100% similarity]
Lib/test/certdata/ffdh3072.pem [moved from Lib/test/ffdh3072.pem with 100% similarity]
Lib/test/certdata/idnsans.pem [moved from Lib/test/idnsans.pem with 100% similarity]
Lib/test/certdata/keycert.passwd.pem [moved from Lib/test/keycert.passwd.pem with 100% similarity]
Lib/test/certdata/keycert.pem [moved from Lib/test/keycert.pem with 100% similarity]
Lib/test/certdata/keycert2.pem [moved from Lib/test/keycert2.pem with 100% similarity]
Lib/test/certdata/keycert3.pem [moved from Lib/test/keycert3.pem with 100% similarity]
Lib/test/certdata/keycert4.pem [moved from Lib/test/keycert4.pem with 100% similarity]
Lib/test/certdata/keycertecc.pem [moved from Lib/test/keycertecc.pem with 100% similarity]
Lib/test/certdata/make_ssl_certs.py [moved from Lib/test/make_ssl_certs.py with 100% similarity]
Lib/test/certdata/nokia.pem [moved from Lib/test/nokia.pem with 100% similarity]
Lib/test/certdata/nosan.pem [moved from Lib/test/nosan.pem with 100% similarity]
Lib/test/certdata/nullbytecert.pem [moved from Lib/test/nullbytecert.pem with 100% similarity]
Lib/test/certdata/nullcert.pem [moved from Lib/test/nullcert.pem with 100% similarity]
Lib/test/certdata/pycacert.pem [moved from Lib/test/pycacert.pem with 100% similarity]
Lib/test/certdata/pycakey.pem [moved from Lib/test/pycakey.pem with 100% similarity]
Lib/test/certdata/revocation.crl [moved from Lib/test/revocation.crl with 100% similarity]
Lib/test/certdata/secp384r1.pem [moved from Lib/test/secp384r1.pem with 100% similarity]
Lib/test/certdata/selfsigned_pythontestdotnet.pem [moved from Lib/test/selfsigned_pythontestdotnet.pem with 100% similarity]
Lib/test/certdata/ssl_cert.pem [moved from Lib/test/ssl_cert.pem with 100% similarity]
Lib/test/certdata/ssl_key.passwd.pem [moved from Lib/test/ssl_key.passwd.pem with 100% similarity]
Lib/test/certdata/ssl_key.pem [moved from Lib/test/ssl_key.pem with 100% similarity]
Lib/test/certdata/talos-2019-0758.pem [moved from Lib/test/talos-2019-0758.pem with 100% similarity]
Lib/test/ssl_servers.py
Lib/test/test_asyncio/utils.py
Lib/test/test_ftplib.py
Lib/test/test_httplib.py
Lib/test/test_imaplib.py
Lib/test/test_logging.py
Lib/test/test_poplib.py
Lib/test/test_ssl.py
Lib/test/test_urllib2_localnet.py
Makefile.pre.in

index a4bd7455d47e76dab1b692dc1e3c491ac2409d89..15b071e04dda1f33629bf7ed6186dc46847cb15c 100644 (file)
@@ -14,7 +14,7 @@ from test.support import socket_helper
 here = os.path.dirname(__file__)
 
 HOST = socket_helper.HOST
-CERTFILE = os.path.join(here, 'keycert.pem')
+CERTFILE = os.path.join(here, 'certdata', 'keycert.pem')
 
 # This one's based on HTTPServer, which is based on socketserver
 
index 6dee5bb33b256071bd6aa52727cbe1cfbc40f856..64eb4410bfb5dcd0146ab65e05cb34cbb7ace251 100644 (file)
@@ -36,21 +36,21 @@ from test.support import socket_helper
 from test.support import threading_helper
 
 
-def data_file(filename):
+def data_file(*filename):
     if hasattr(support, 'TEST_HOME_DIR'):
-        fullname = os.path.join(support.TEST_HOME_DIR, filename)
+        fullname = os.path.join(support.TEST_HOME_DIR, *filename)
         if os.path.isfile(fullname):
             return fullname
-    fullname = os.path.join(os.path.dirname(__file__), '..', filename)
+    fullname = os.path.join(os.path.dirname(__file__), '..', *filename)
     if os.path.isfile(fullname):
         return fullname
-    raise FileNotFoundError(filename)
+    raise FileNotFoundError(os.path.join(filename))
 
 
-ONLYCERT = data_file('ssl_cert.pem')
-ONLYKEY = data_file('ssl_key.pem')
-SIGNED_CERTFILE = data_file('keycert3.pem')
-SIGNING_CA = data_file('pycacert.pem')
+ONLYCERT = data_file('certdata', 'ssl_cert.pem')
+ONLYKEY = data_file('certdata', 'ssl_key.pem')
+SIGNED_CERTFILE = data_file('certdata', 'keycert3.pem')
+SIGNING_CA = data_file('certdata', 'pycacert.pem')
 PEERCERT = {
     'OCSP': ('http://testca.pythontest.net/testca/ocsp/',),
     'caIssuers': ('http://testca.pythontest.net/testca/pycacert.cer',),
index 544228e3bab47ba66b8b070ddf2b3e2fb07c36b8..bebd1bbb9e27032aa283ff70d7d4adb61f85461f 100644 (file)
@@ -325,8 +325,8 @@ class DummyFTPServer(asyncore.dispatcher, threading.Thread):
 
 if ssl is not None:
 
-    CERTFILE = os.path.join(os.path.dirname(__file__), "keycert3.pem")
-    CAFILE = os.path.join(os.path.dirname(__file__), "pycacert.pem")
+    CERTFILE = os.path.join(os.path.dirname(__file__), "certdata", "keycert3.pem")
+    CAFILE = os.path.join(os.path.dirname(__file__), "certdata", "pycacert.pem")
 
     class SSLConnection(asyncore.dispatcher):
         """An asyncore.dispatcher subclass supporting TLS/SSL."""
index 676725c46ec694153c0d43b8d907daa74084ec0d..5d5832b62b2f9438e52b0cc983d3524a9d781e7d 100644 (file)
@@ -21,11 +21,13 @@ support.requires_working_socket(module=True)
 
 here = os.path.dirname(__file__)
 # Self-signed cert file for 'localhost'
-CERT_localhost = os.path.join(here, 'keycert.pem')
+CERT_localhost = os.path.join(here, 'certdata', 'keycert.pem')
 # Self-signed cert file for 'fakehostname'
-CERT_fakehostname = os.path.join(here, 'keycert2.pem')
+CERT_fakehostname = os.path.join(here, 'certdata', 'keycert2.pem')
 # Self-signed cert file for self-signed.pythontest.net
-CERT_selfsigned_pythontestdotnet = os.path.join(here, 'selfsigned_pythontestdotnet.pem')
+CERT_selfsigned_pythontestdotnet = os.path.join(
+    here, 'certdata', 'selfsigned_pythontestdotnet.pem',
+)
 
 # constants for testing chunked encoding
 chunked_start = (
index a1eaf2169fe22729fa22639fb99ca0428e245501..b97474acca370f2c28be55b23881c07eb807a73b 100644 (file)
@@ -23,8 +23,8 @@ except ImportError:
 
 support.requires_working_socket(module=True)
 
-CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "keycert3.pem")
-CAFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "pycacert.pem")
+CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "certdata", "keycert3.pem")
+CAFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "certdata", "pycacert.pem")
 
 
 class TestImaplib(unittest.TestCase):
index 2305e5162f901e042174ae65d38ef2e89bf112c8..375f65f9d16182f765fcb38730c86283f3d27e08 100644 (file)
@@ -2170,7 +2170,7 @@ class HTTPHandlerTest(BaseTest):
                     sslctx = None
                 else:
                     here = os.path.dirname(__file__)
-                    localhost_cert = os.path.join(here, "keycert.pem")
+                    localhost_cert = os.path.join(here, "certdata", "keycert.pem")
                     sslctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
                     sslctx.load_cert_chain(localhost_cert)
 
index fa41ba0b6e46376b037fddaa583f296a85760522..869f9431b928bb6bdc16e74f8700bc59a42836ee 100644 (file)
@@ -29,8 +29,8 @@ if hasattr(poplib, 'POP3_SSL'):
     import ssl
 
     SUPPORTS_SSL = True
-    CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "keycert3.pem")
-    CAFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "pycacert.pem")
+    CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "certdata", "keycert3.pem")
+    CAFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "certdata", "pycacert.pem")
 
 requires_ssl = skipUnless(SUPPORTS_SSL, 'SSL not supported')
 
index 2c32fec5104c2348d660e5f71f89a614c59d554a..06304dcb4ec7b853fc6f35c61c7e51679abee7f1 100644 (file)
@@ -60,10 +60,10 @@ for proto, ver in (
     PROTOCOL_TO_TLS_VERSION[proto] = ver
 
 def data_file(*name):
-    return os.path.join(os.path.dirname(__file__), *name)
+    return os.path.join(os.path.dirname(__file__), "certdata", *name)
 
 # The custom key and certificate files used in test_ssl are generated
-# using Lib/test/make_ssl_certs.py.
+# using Lib/test/certdata/make_ssl_certs.py.
 # Other certificates are simply fetched from the internet servers they
 # are meant to authenticate.
 
@@ -641,7 +641,7 @@ class BasicSocketTests(unittest.TestCase):
     def bad_cert_test(self, certfile):
         """Check that trying to use the given client certificate fails"""
         certfile = os.path.join(os.path.dirname(__file__) or os.curdir,
-                                   certfile)
+                                "certdata", certfile)
         sock = socket.socket()
         self.addCleanup(sock.close)
         with self.assertRaises(ssl.SSLError):
@@ -3309,12 +3309,12 @@ class ThreadedTests(unittest.TestCase):
         # try to connect
         if support.verbose:
             sys.stdout.write('\n')
-        with open(CERTFILE, 'rb') as f:
+        # Get this test file itself:
+        with open(__file__, 'rb') as f:
             d1 = f.read()
         d2 = ''
         # now fetch the same data from the HTTPS server
-        url = 'https://localhost:%d/%s' % (
-            server.port, os.path.split(CERTFILE)[1])
+        url = f'https://localhost:{server.port}/test_ssl.py'
         context = ssl.create_default_context(cafile=SIGNING_CA)
         f = urllib.request.urlopen(url, context=context)
         try:
index 0dcdbac76b50f2fe1b516e002441a8e3c594e356..50c491a3cfd3d0c45491b89e14d71f268f94e5c4 100644 (file)
@@ -21,9 +21,9 @@ support.requires_working_socket(module=True)
 
 here = os.path.dirname(__file__)
 # Self-signed cert file for 'localhost'
-CERT_localhost = os.path.join(here, 'keycert.pem')
+CERT_localhost = os.path.join(here, 'certdata', 'keycert.pem')
 # Self-signed cert file for 'fakehostname'
-CERT_fakehostname = os.path.join(here, 'keycert2.pem')
+CERT_fakehostname = os.path.join(here, 'certdata', 'keycert2.pem')
 
 
 # Loopback http server infrastructure
index ba35e1b563ce269fcf8c659db35f6b4939f2c7c6..35f254508579bf05d1ce59b983ee5ce7eea895d4 100644 (file)
@@ -2141,7 +2141,8 @@ LIBSUBDIRS=       asyncio \
 TESTSUBDIRS=   idlelib/idle_test \
                test \
                test/audiodata \
-               test/capath \
+               test/certdata \
+               test/certdata/capath \
                test/cjkencodings \
                test/crashers \
                test/data \