Skip to content

Commit 8ae8733

Browse files
committed
gh-108303: Move all certificates to Lib/test/certdata/
1 parent 929cc4e commit 8ae8733

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+31
-27
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Lib/test/ssl_servers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
here = os.path.dirname(__file__)
1515

1616
HOST = socket_helper.HOST
17-
CERTFILE = os.path.join(here, 'keycert.pem')
17+
CERTFILE = os.path.join(here, 'certdata', 'keycert.pem')
1818

1919
# This one's based on HTTPServer, which is based on socketserver
2020

Lib/test/test_asyncio/utils.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,21 @@
3636
from test.support import threading_helper
3737

3838

39-
def data_file(filename):
39+
def data_file(*filename):
4040
if hasattr(support, 'TEST_HOME_DIR'):
41-
fullname = os.path.join(support.TEST_HOME_DIR, filename)
41+
fullname = os.path.join(support.TEST_HOME_DIR, *filename)
4242
if os.path.isfile(fullname):
4343
return fullname
44-
fullname = os.path.join(os.path.dirname(__file__), '..', filename)
44+
fullname = os.path.join(os.path.dirname(__file__), '..', *filename)
4545
if os.path.isfile(fullname):
4646
return fullname
47-
raise FileNotFoundError(filename)
47+
raise FileNotFoundError(os.path.join(filename))
4848

4949

50-
ONLYCERT = data_file('ssl_cert.pem')
51-
ONLYKEY = data_file('ssl_key.pem')
52-
SIGNED_CERTFILE = data_file('keycert3.pem')
53-
SIGNING_CA = data_file('pycacert.pem')
50+
ONLYCERT = data_file('certdata', 'ssl_cert.pem')
51+
ONLYKEY = data_file('certdata', 'ssl_key.pem')
52+
SIGNED_CERTFILE = data_file('certdata', 'keycert3.pem')
53+
SIGNING_CA = data_file('certdata', 'pycacert.pem')
5454
PEERCERT = {
5555
'OCSP': ('http://testca.pythontest.net/testca/ocsp/',),
5656
'caIssuers': ('http://testca.pythontest.net/testca/pycacert.cer',),

Lib/test/test_ftplib.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,8 @@ def handle_error(self):
325325

326326
if ssl is not None:
327327

328-
CERTFILE = os.path.join(os.path.dirname(__file__), "keycert3.pem")
329-
CAFILE = os.path.join(os.path.dirname(__file__), "pycacert.pem")
328+
CERTFILE = os.path.join(os.path.dirname(__file__), "certdata", "keycert3.pem")
329+
CAFILE = os.path.join(os.path.dirname(__file__), "certdata", "pycacert.pem")
330330

331331
class SSLConnection(asyncore.dispatcher):
332332
"""An asyncore.dispatcher subclass supporting TLS/SSL."""

Lib/test/test_httplib.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@
2121

2222
here = os.path.dirname(__file__)
2323
# Self-signed cert file for 'localhost'
24-
CERT_localhost = os.path.join(here, 'keycert.pem')
24+
CERT_localhost = os.path.join(here, 'certdata', 'keycert.pem')
2525
# Self-signed cert file for 'fakehostname'
26-
CERT_fakehostname = os.path.join(here, 'keycert2.pem')
26+
CERT_fakehostname = os.path.join(here, 'certdata', 'keycert2.pem')
2727
# Self-signed cert file for self-signed.pythontest.net
28-
CERT_selfsigned_pythontestdotnet = os.path.join(here, 'selfsigned_pythontestdotnet.pem')
28+
CERT_selfsigned_pythontestdotnet = os.path.join(
29+
here, 'certdata', 'selfsigned_pythontestdotnet.pem',
30+
)
2931

3032
# constants for testing chunked encoding
3133
chunked_start = (

Lib/test/test_imaplib.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
support.requires_working_socket(module=True)
2525

26-
CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "keycert3.pem")
27-
CAFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "pycacert.pem")
26+
CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "certdata", "keycert3.pem")
27+
CAFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "certdata", "pycacert.pem")
2828

2929

3030
class TestImaplib(unittest.TestCase):

Lib/test/test_logging.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2170,7 +2170,7 @@ def test_output(self):
21702170
sslctx = None
21712171
else:
21722172
here = os.path.dirname(__file__)
2173-
localhost_cert = os.path.join(here, "keycert.pem")
2173+
localhost_cert = os.path.join(here, "certdata", "keycert.pem")
21742174
sslctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
21752175
sslctx.load_cert_chain(localhost_cert)
21762176

Lib/test/test_poplib.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
import ssl
3030

3131
SUPPORTS_SSL = True
32-
CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "keycert3.pem")
33-
CAFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "pycacert.pem")
32+
CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "certdata", "keycert3.pem")
33+
CAFILE = os.path.join(os.path.dirname(__file__) or os.curdir, "certdata", "pycacert.pem")
3434

3535
requires_ssl = skipUnless(SUPPORTS_SSL, 'SSL not supported')
3636

Lib/test/test_ssl.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@
6060
PROTOCOL_TO_TLS_VERSION[proto] = ver
6161

6262
def data_file(*name):
63-
return os.path.join(os.path.dirname(__file__), *name)
63+
return os.path.join(os.path.dirname(__file__), "certdata", *name)
6464

6565
# The custom key and certificate files used in test_ssl are generated
66-
# using Lib/test/make_ssl_certs.py.
66+
# using Lib/test/certdata/make_ssl_certs.py.
6767
# Other certificates are simply fetched from the internet servers they
6868
# are meant to authenticate.
6969

@@ -641,7 +641,7 @@ def test_openssl111_deprecations(self):
641641
def bad_cert_test(self, certfile):
642642
"""Check that trying to use the given client certificate fails"""
643643
certfile = os.path.join(os.path.dirname(__file__) or os.curdir,
644-
certfile)
644+
"certdata", certfile)
645645
sock = socket.socket()
646646
self.addCleanup(sock.close)
647647
with self.assertRaises(ssl.SSLError):
@@ -3313,8 +3313,9 @@ def test_socketserver(self):
33133313
d1 = f.read()
33143314
d2 = ''
33153315
# now fetch the same data from the HTTPS server
3316-
url = 'https://localhost:%d/%s' % (
3317-
server.port, os.path.split(CERTFILE)[1])
3316+
dirname, filename = os.path.split(CERTFILE)
3317+
basename = os.path.basename(dirname)
3318+
url = 'https://localhost:%d/%s/%s' % (server.port, basename, filename)
33183319
context = ssl.create_default_context(cafile=SIGNING_CA)
33193320
f = urllib.request.urlopen(url, context=context)
33203321
try:

Lib/test/test_urllib2_localnet.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121

2222
here = os.path.dirname(__file__)
2323
# Self-signed cert file for 'localhost'
24-
CERT_localhost = os.path.join(here, 'keycert.pem')
24+
CERT_localhost = os.path.join(here, 'certdata', 'keycert.pem')
2525
# Self-signed cert file for 'fakehostname'
26-
CERT_fakehostname = os.path.join(here, 'keycert2.pem')
26+
CERT_fakehostname = os.path.join(here, 'certdata', 'keycert2.pem')
2727

2828

2929
# Loopback http server infrastructure

Makefile.pre.in

+2-1
Original file line numberDiff line numberDiff line change
@@ -2141,7 +2141,8 @@ LIBSUBDIRS= asyncio \
21412141
TESTSUBDIRS= idlelib/idle_test \
21422142
test \
21432143
test/audiodata \
2144-
test/capath \
2144+
test/certdata \
2145+
test/certdata/capath \
21452146
test/cjkencodings \
21462147
test/crashers \
21472148
test/data \

0 commit comments

Comments
 (0)