1
0
mirror of https://github.com/laurivosandi/certidude synced 2024-12-23 00:25:18 +00:00

Add tests for non-existant certificate

This commit is contained in:
Lauri Võsandi 2017-04-25 13:58:21 +03:00
parent 108b6ebfaf
commit 4eb3c4146f
2 changed files with 7 additions and 1 deletions

View File

@ -18,7 +18,7 @@ class SignedCertificateDetailResource(object):
except EnvironmentError: except EnvironmentError:
logger.warning(u"Failed to serve non-existant certificate %s to %s", logger.warning(u"Failed to serve non-existant certificate %s to %s",
cn, req.context.get("remote_addr")) cn, req.context.get("remote_addr"))
raise falcon.HTTPNotFound("No certificate CN=%s found" % cn) raise falcon.HTTPNotFound()
else: else:
if preferred_type == "application/x-pem-file": if preferred_type == "application/x-pem-file":
resp.set_header("Content-Type", "application/x-pem-file") resp.set_header("Content-Type", "application/x-pem-file")

View File

@ -77,6 +77,9 @@ def test_cli_setup_authority():
# Test signed certificate API call # Test signed certificate API call
r = client().simulate_get("/api/signed/nonexistant")
assert r.status_code == 404
r = client().simulate_get("/api/signed/test2") r = client().simulate_get("/api/signed/test2")
assert r.status_code == 200 assert r.status_code == 200
assert r.headers.get('content-type') == "application/x-pem-file" assert r.headers.get('content-type') == "application/x-pem-file"
@ -85,6 +88,9 @@ def test_cli_setup_authority():
assert r.status_code == 200 assert r.status_code == 200
assert r.headers.get('content-type') == "application/json" assert r.headers.get('content-type') == "application/json"
r = client().simulate_get("/api/signed/test2", headers={"Accept":"text/plain"})
assert r.status_code == 415
# Test revocations API call # Test revocations API call
r = client().simulate_get("/api/revoked") r = client().simulate_get("/api/revoked")