mirror of
https://github.com/laurivosandi/certidude
synced 2024-12-23 00:25:18 +00:00
tests: Better CA cert checks
This commit is contained in:
parent
1484ad7826
commit
3c8aef4fd2
@ -81,10 +81,22 @@ def test_cli_setup_authority():
|
|||||||
result = runner.invoke(cli, ['serve', '-f'])
|
result = runner.invoke(cli, ['serve', '-f'])
|
||||||
assert not result.exception, result.output
|
assert not result.exception, result.output
|
||||||
|
|
||||||
assert authority.export_crl(), "Failed to export CRL"
|
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
# Test CA certificate fetch
|
||||||
|
buf = open("/var/lib/certidude/ca.example.lan/ca_crt.pem").read()
|
||||||
|
|
||||||
|
r = client().simulate_get("/api/certificate")
|
||||||
|
assert r.status_code == 200
|
||||||
|
assert r.headers.get('content-type') == "application/x-x509-ca-cert"
|
||||||
|
assert r.text == buf
|
||||||
|
|
||||||
|
r = requests.get("http://ca.example.lan/api/certificate")
|
||||||
|
assert r.status_code == 200
|
||||||
|
assert r.headers.get('content-type') == "application/x-x509-ca-cert"
|
||||||
|
assert r.text == buf
|
||||||
|
|
||||||
|
|
||||||
# Password is bot, users created by Travis
|
# Password is bot, users created by Travis
|
||||||
usertoken = "Basic dXNlcmJvdDpib3Q="
|
usertoken = "Basic dXNlcmJvdDpib3Q="
|
||||||
admintoken = "Basic YWRtaW5ib3Q6Ym90"
|
admintoken = "Basic YWRtaW5ib3Q6Ym90"
|
||||||
@ -93,6 +105,7 @@ def test_cli_setup_authority():
|
|||||||
assert not result.exception, result.output
|
assert not result.exception, result.output
|
||||||
|
|
||||||
# Check that we can retrieve empty CRL
|
# Check that we can retrieve empty CRL
|
||||||
|
assert authority.export_crl(), "Failed to export CRL"
|
||||||
r = client().simulate_get("/api/revoked/")
|
r = client().simulate_get("/api/revoked/")
|
||||||
assert r.status_code == 200, r.text
|
assert r.status_code == 200, r.text
|
||||||
|
|
||||||
@ -101,15 +114,6 @@ def test_cli_setup_authority():
|
|||||||
result = runner.invoke(cli, ['list', '-srv'])
|
result = runner.invoke(cli, ['list', '-srv'])
|
||||||
assert not result.exception, result.output
|
assert not result.exception, result.output
|
||||||
|
|
||||||
# Test CA certificate fetch
|
|
||||||
r = client().simulate_get("/api/certificate")
|
|
||||||
assert r.status_code == 200
|
|
||||||
assert r.headers.get('content-type') == "application/x-x509-ca-cert"
|
|
||||||
|
|
||||||
r = requests.get("http://ca.example.lan/api/certificate")
|
|
||||||
assert r.status_code == 200
|
|
||||||
assert r.headers.get('content-type') == "application/x-x509-ca-cert"
|
|
||||||
|
|
||||||
# Test static
|
# Test static
|
||||||
r = client().simulate_get("/nonexistant.html")
|
r = client().simulate_get("/nonexistant.html")
|
||||||
assert r.status_code == 404, r.text
|
assert r.status_code == 404, r.text
|
||||||
|
Loading…
Reference in New Issue
Block a user