Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c2d542b

Browse filesBrowse files
miss-islingtonsobolevnYhg1s
authored
[3.12] pythongh-108303: Move all certificates to Lib/test/certdata/ (pythonGH-109489) (python#109682)
* pythongh-108303: Move all certificates to `Lib/test/certdata/` (pythonGH-109489) (cherry picked from commit e57ecf6) Co-authored-by: Nikita Sobolev <mail@sobolevn.me> Python 3.12 backport: update also `test_nntplib`. Co-authored-by: Nikita Sobolev <mail@sobolevn.me> Co-authored-by: T. Wouters <thomas@python.org>
1 parent 5b168fd commit c2d542b
Copy full SHA for c2d542b

Some content is hidden

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

42 files changed

+32
-29
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

Copy file name to clipboardExpand all lines: Lib/test/ssl_servers.py
+1-1Lines changed: 1 addition & 1 deletion
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

Copy file name to clipboardExpand all lines: Lib/test/test_asyncio/utils.py
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,21 @@
4242
CLOCK_RES = 0.020
4343

4444

45-
def data_file(filename):
45+
def data_file(*filename):
4646
if hasattr(support, 'TEST_HOME_DIR'):
47-
fullname = os.path.join(support.TEST_HOME_DIR, filename)
47+
fullname = os.path.join(support.TEST_HOME_DIR, *filename)
4848
if os.path.isfile(fullname):
4949
return fullname
50-
fullname = os.path.join(os.path.dirname(__file__), '..', filename)
50+
fullname = os.path.join(os.path.dirname(__file__), '..', *filename)
5151
if os.path.isfile(fullname):
5252
return fullname
53-
raise FileNotFoundError(filename)
53+
raise FileNotFoundError(os.path.join(filename))
5454

5555

56-
ONLYCERT = data_file('ssl_cert.pem')
57-
ONLYKEY = data_file('ssl_key.pem')
58-
SIGNED_CERTFILE = data_file('keycert3.pem')
59-
SIGNING_CA = data_file('pycacert.pem')
56+
ONLYCERT = data_file('certdata', 'ssl_cert.pem')
57+
ONLYKEY = data_file('certdata', 'ssl_key.pem')
58+
SIGNED_CERTFILE = data_file('certdata', 'keycert3.pem')
59+
SIGNING_CA = data_file('certdata', 'pycacert.pem')
6060
PEERCERT = {
6161
'OCSP': ('http://testca.pythontest.net/testca/ocsp/',),
6262
'caIssuers': ('http://testca.pythontest.net/testca/pycacert.cer',),

‎Lib/test/test_ftplib.py

Copy file name to clipboardExpand all lines: Lib/test/test_ftplib.py
+2-2Lines changed: 2 additions & 2 deletions
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

Copy file name to clipboardExpand all lines: Lib/test/test_httplib.py
+5-3Lines changed: 5 additions & 3 deletions
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

Copy file name to clipboardExpand all lines: Lib/test/test_imaplib.py
+2-2Lines changed: 2 additions & 2 deletions
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

Copy file name to clipboardExpand all lines: Lib/test/test_logging.py
+1-1Lines changed: 1 addition & 1 deletion
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_nntplib.py

Copy file name to clipboardExpand all lines: Lib/test/test_nntplib.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
ssl = None
2121

2222

23-
certfile = os.path.join(os.path.dirname(__file__), 'keycert3.pem')
23+
certfile = os.path.join(os.path.dirname(__file__), 'certdata', 'keycert3.pem')
2424

2525
if ssl is not None:
2626
SSLError = ssl.SSLError

‎Lib/test/test_poplib.py

Copy file name to clipboardExpand all lines: Lib/test/test_poplib.py
+2-2Lines changed: 2 additions & 2 deletions
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

Copy file name to clipboardExpand all lines: Lib/test/test_ssl.py
+6-6Lines changed: 6 additions & 6 deletions
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):
@@ -3309,12 +3309,12 @@ def test_socketserver(self):
33093309
# try to connect
33103310
if support.verbose:
33113311
sys.stdout.write('\n')
3312-
with open(CERTFILE, 'rb') as f:
3312+
# Get this test file itself:
3313+
with open(__file__, 'rb') as f:
33133314
d1 = f.read()
33143315
d2 = ''
33153316
# now fetch the same data from the HTTPS server
3316-
url = 'https://localhost:%d/%s' % (
3317-
server.port, os.path.split(CERTFILE)[1])
3317+
url = f'https://localhost:{server.port}/test_ssl.py'
33183318
context = ssl.create_default_context(cafile=SIGNING_CA)
33193319
f = urllib.request.urlopen(url, context=context)
33203320
try:

‎Lib/test/test_urllib2_localnet.py

Copy file name to clipboardExpand all lines: Lib/test/test_urllib2_localnet.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222

2323
here = os.path.dirname(__file__)
2424
# Self-signed cert file for 'localhost'
25-
CERT_localhost = os.path.join(here, 'keycert.pem')
25+
CERT_localhost = os.path.join(here, 'certdata', 'keycert.pem')
2626
# Self-signed cert file for 'fakehostname'
27-
CERT_fakehostname = os.path.join(here, 'keycert2.pem')
27+
CERT_fakehostname = os.path.join(here, 'certdata', 'keycert2.pem')
2828

2929

3030
# Loopback http server infrastructure

‎Makefile.pre.in

Copy file name to clipboardExpand all lines: Makefile.pre.in
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2117,7 +2117,8 @@ LIBSUBDIRS= asyncio \
21172117
TESTSUBDIRS= idlelib/idle_test \
21182118
test \
21192119
test/audiodata \
2120-
test/capath \
2120+
test/certdata \
2121+
test/certdata/capath \
21212122
test/cjkencodings \
21222123
test/crashers \
21232124
test/data \

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.