1
0
mirror of https://github.com/laurivosandi/certidude synced 2024-12-22 16:25:17 +00:00

tests: More API call tests

This commit is contained in:
Lauri Võsandi 2017-05-01 20:15:45 +00:00
parent 451e2b2ad8
commit a754c1275d

View File

@ -81,6 +81,8 @@ def test_cli_setup_authority():
result = runner.invoke(cli, ['serve', '-f'])
assert not result.exception, result.output
import requests
# Password is bot, users created by Travis
usertoken = "Basic dXNlcmJvdDpib3Q="
admintoken = "Basic YWRtaW5ib3Q6Ym90"
@ -102,6 +104,10 @@ def test_cli_setup_authority():
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 request submission
buf = generate_csr(cn=u"test")
@ -197,11 +203,20 @@ def test_cli_setup_authority():
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
assert r.headers.get('content-type') == "application/x-pem-file"
r = requests.get("http://ca.example.lan/api/revoked/",
headers={"Accept":"application/x-pem-file"})
assert r.status_code == 200
assert r.headers.get('content-type') == "application/x-pem-file"
r = client().simulate_get("/api/revoked/",
headers={"Accept":"text/plain"})
assert r.status_code == 415