Skip to content

Commit bb30b61

Browse files
Merge pull request #442 from element-hq/gaelg/pytest-ca-cache
pytest: fix CA cache was regenerated every run
2 parents d4deec3 + 2ae1710 commit bb30b61

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

newsfragments/442.internal.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix pytest CA was re-generated on every pytest run, preventing tests in local browsers.

tests/integration/artifacts/certs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ def get_ca(name, root_ca=None) -> CertKey:
6969
os.makedirs(ca_filename.parent, exist_ok=True)
7070
certkey = None
7171

72-
if os.path.exists(cert_path) and os.path.exists(key_path):
72+
if cert_path.exists() and key_path.exists():
7373
with open(key_path, "rb") as pem_in:
7474
private_key = load_pem_private_key(pem_in.read(), None, default_backend())
7575
with open(cert_path, "rb") as pem_in:
7676
cert = x509.load_pem_x509_certificate(pem_in.read(), default_backend())
77-
if cert.not_valid_after_utc < pytz.UTC.localize(datetime.datetime.now()):
77+
if cert.not_valid_after_utc > pytz.UTC.localize(datetime.datetime.now()):
7878
certkey = CertKey(ca=root_ca, cert=cert, key=private_key)
7979
if not certkey:
8080
certkey = generate_ca(name, root_ca)

0 commit comments

Comments
 (0)