From 3ddfc5c179e26263bcf834e9a760372aa91685d9 Mon Sep 17 00:00:00 2001 From: dandds Date: Thu, 14 Nov 2019 14:12:07 -0500 Subject: [PATCH] Fix bug in static CRL test. A CRL test that relies on fixtures files was not getting a working copy of the relevant CRL list it needed. This also adds a setup function to the relevant test module so that we can clear and rebuild the CRL location cache for the fixtures. --- tests/domain/authnid/test_crl.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/domain/authnid/test_crl.py b/tests/domain/authnid/test_crl.py index 37686150..222bb9a3 100644 --- a/tests/domain/authnid/test_crl.py +++ b/tests/domain/authnid/test_crl.py @@ -126,8 +126,25 @@ def test_throws_error_for_missing_issuer(app): assert DOD_CN in message +FIXTURE_CRL_CACHE = "tests/fixtures/chain/crl_locations.json" + + +def setup_function(test_multistep_certificate_chain): + if os.path.isfile(FIXTURE_CRL_CACHE): + os.remove(FIXTURE_CRL_CACHE) + + def test_multistep_certificate_chain(): - cache = CRLCache("tests/fixtures/chain/ca-chain.pem", "tests/fixtures/chain/") + issuer = None + fixture_crl = "tests/fixtures/chain/intermediate.crl" + with open(fixture_crl, "rb") as crl_file: + crl = crypto.load_crl(crypto.FILETYPE_ASN1, crl_file.read()) + issuer = crl.get_issuer().der() + + crl_list = [(fixture_crl, issuer.hex())] + cache = CRLCache( + "tests/fixtures/chain/ca-chain.pem", "tests/fixtures/chain/", crl_list=crl_list + ) cert = open("tests/fixtures/chain/client.crt", "rb").read() assert cache.crl_check(cert)