From ffdcbcc41ae18232ab2a26cbd68a204017c3ca52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauri=20V=C3=B5sandi?= Date: Mon, 1 May 2017 20:40:22 +0000 Subject: [PATCH] tests: Attempt to catch CRL export errors --- certidude/api/revoked.py | 6 +++++- tests/test_cli.py | 16 ++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/certidude/api/revoked.py b/certidude/api/revoked.py index 1522c65..a622f39 100644 --- a/certidude/api/revoked.py +++ b/certidude/api/revoked.py @@ -37,7 +37,11 @@ class RevocationListResource(object): "Content-Disposition", ("attachment; filename=%s-crl.pem" % const.HOSTNAME).encode("ascii")) logger.debug(u"Serving revocation list to %s in PEM format", req.context.get("remote_addr")) - resp.body = export_crl() + try: + resp.body = export_crl() + except: + logger.debug(u"Failed to export CRL, are you sure signer is running?") + raise else: logger.debug(u"Client %s asked revocation list in unsupported format" % req.context.get("remote_addr")) raise falcon.HTTPUnsupportedMediaType( diff --git a/tests/test_cli.py b/tests/test_cli.py index 6196598..65c3067 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -199,14 +199,6 @@ def test_cli_setup_authority(): assert r.status_code == 415 # Test revocations API call - r = client().simulate_get("/api/revoked/") - assert r.status_code == 200 - assert r.headers.get('content-type') == "application/x-pkcs7-crl" - - r = requests.get("http://ca.example.lan/api/revoked/") - assert r.status_code == 200 - assert r.headers.get('content-type') == "application/x-pkcs7-crl" - r = client().simulate_get("/api/revoked/", headers={"Accept":"application/x-pem-file"}) assert r.status_code == 200 @@ -217,6 +209,14 @@ def test_cli_setup_authority(): assert r.status_code == 200 assert r.headers.get('content-type') == "application/x-pem-file" + r = client().simulate_get("/api/revoked/") + assert r.status_code == 200 + assert r.headers.get('content-type') == "application/x-pkcs7-crl" + + r = requests.get("http://ca.example.lan/api/revoked/") + assert r.status_code == 200 + assert r.headers.get('content-type') == "application/x-pkcs7-crl" + r = client().simulate_get("/api/revoked/", headers={"Accept":"text/plain"}) assert r.status_code == 415