Skip to content

Commit ee6041e

Browse files
committed
avoid interference with other tests
1 parent 334e456 commit ee6041e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tests/hazmat/primitives/test_pkcs7.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,21 @@ def test_load_pkcs7_empty_certificates(self):
133133
pkcs7.load_der_pkcs7_certificates(der)
134134

135135

136-
def _load_cert_key():
136+
def _load_cert_key(ca_directory: str | None = None):
137+
if ca_directory is not None:
138+
_ca_directory = ca_directory
139+
else:
140+
_ca_directory = os.path.join("x509", "custom", "ca")
141+
137142
key = load_vectors_from_file(
138-
os.path.join("pkcs7", "ca_key.pem"),
143+
os.path.join(_ca_directory, "ca_key.pem"),
139144
lambda pemfile: serialization.load_pem_private_key(
140145
pemfile.read(), None, unsafe_skip_rsa_key_validation=True
141146
),
142147
mode="rb",
143148
)
144149
cert = load_vectors_from_file(
145-
os.path.join("pkcs7", "ca.pem"),
150+
os.path.join(_ca_directory, "ca.pem"),
146151
loader=lambda pemfile: x509.load_pem_x509_certificate(pemfile.read()),
147152
mode="rb",
148153
)
@@ -161,7 +166,7 @@ def build_pkcs7_certificate(
161166
to test all cases in PKCS#7 certificate verification.
162167
"""
163168
# Load the standard certificate and private key
164-
certificate, private_key = _load_cert_key()
169+
certificate, private_key = _load_cert_key("pkcs7")
165170

166171
# Basic certificate builder
167172
certificate_builder = (

0 commit comments

Comments
 (0)