mirror of
https://github.com/laurivosandi/certidude
synced 2024-11-16 18:06:44 +00:00
Add tests for certificate revocation via API
This commit is contained in:
parent
316fe7aba0
commit
1517b902d6
@ -45,6 +45,7 @@ def test_cli_setup_authority():
|
|||||||
assert authority.ca_cert.not_valid_before < datetime.now()
|
assert authority.ca_cert.not_valid_before < datetime.now()
|
||||||
assert authority.ca_cert.not_valid_after > datetime.now() + timedelta(days=7000)
|
assert authority.ca_cert.not_valid_after > datetime.now() + timedelta(days=7000)
|
||||||
|
|
||||||
|
# Password is bot, users created by Travis
|
||||||
usertoken = "Basic dXNlcmJvdDpib3Q="
|
usertoken = "Basic dXNlcmJvdDpib3Q="
|
||||||
admintoken = "Basic YWRtaW5ib3Q6Ym90"
|
admintoken = "Basic YWRtaW5ib3Q6Ym90"
|
||||||
|
|
||||||
@ -159,7 +160,6 @@ def test_cli_setup_authority():
|
|||||||
r = client().simulate_get("/api/signed/test2/", headers={"Accept":"text/plain"})
|
r = client().simulate_get("/api/signed/test2/", headers={"Accept":"text/plain"})
|
||||||
assert r.status_code == 415
|
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/")
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
@ -198,10 +198,15 @@ def test_cli_setup_authority():
|
|||||||
r = client().simulate_get("/api/signed/test2/tag/", headers={"Authorization":admintoken})
|
r = client().simulate_get("/api/signed/test2/tag/", headers={"Authorization":admintoken})
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
|
|
||||||
|
# Test revocation
|
||||||
|
r = client().simulate_delete("/api/signed/test2/")
|
||||||
|
assert r.status_code == 401
|
||||||
|
|
||||||
# Revoke all valid ones
|
r = client().simulate_delete("/api/signed/test2/", headers={"Authorization":usertoken})
|
||||||
result = runner.invoke(cli, ['revoke', 'test2'])
|
assert r.status_code == 403
|
||||||
assert not result.exception
|
|
||||||
|
r = client().simulate_delete("/api/signed/test2/", headers={"Authorization":admintoken})
|
||||||
|
assert r.status_code == 200
|
||||||
|
|
||||||
result = runner.invoke(cli, ['revoke', 'test3'])
|
result = runner.invoke(cli, ['revoke', 'test3'])
|
||||||
assert not result.exception
|
assert not result.exception
|
||||||
|
Loading…
Reference in New Issue
Block a user