Revize 8a5e37dd
Přidáno uživatelem Stanislav Král před téměř 4 roky(ů)
tests/integration_tests/rest_api/certificates_test.py | ||
---|---|---|
2 | 2 |
# 1->10 |
3 | 3 |
# 2->3->4->5->6->7 |
4 | 4 |
# 2->8->9 |
5 |
from src.controllers.certificates_controller import E_IDENTITY_NAME_NOT_SPECIFIED, E_IDENTITY_PASSWORD_NOT_SPECIFIED, \ |
|
6 |
E_NO_CERTIFICATES_FOUND |
|
5 | 7 |
|
6 | 8 |
|
7 | 9 |
def make_root_ca(server, title="Root CA s.r.o."): |
... | ... | |
958 | 960 |
assert identity_ret.status_code == 200 |
959 | 961 |
assert identity_ret.content_type == "application/x-pkcs12" |
960 | 962 |
|
963 |
|
|
964 |
def test_generate_identity_non_well_formed(server): |
|
965 |
# non integer ID |
|
966 |
identity_ret = server.get(f"/api/certificates/foo/identity", content_type="application/json", |
|
967 |
json={}) |
|
968 |
assert identity_ret.status_code == 400 |
|
969 |
|
|
970 |
# required fields not passed |
|
971 |
identity_ret = server.get(f"/api/certificates/0/identity", content_type="application/json", |
|
972 |
json={}) |
|
973 |
assert identity_ret.status_code == 400 |
|
974 |
assert identity_ret.json == E_IDENTITY_NAME_NOT_SPECIFIED |
|
975 |
|
|
976 |
# passphrase not passed |
|
977 |
identity_ret = server.get(f"/api/certificates/0/identity", content_type="application/json", |
|
978 |
json={"name": "Foo"}) |
|
979 |
assert identity_ret.status_code == 400 |
|
980 |
assert identity_ret.json == E_IDENTITY_PASSWORD_NOT_SPECIFIED |
|
981 |
|
|
982 |
# name not passed |
|
983 |
identity_ret = server.get(f"/api/certificates/0/identity", content_type="application/json", |
|
984 |
json={"password": "foopass"}) |
|
985 |
assert identity_ret.status_code == 400 |
|
986 |
assert identity_ret.json == E_IDENTITY_NAME_NOT_SPECIFIED |
|
987 |
|
|
988 |
# certificate not existing |
|
989 |
identity_ret = server.get(f"/api/certificates/0/identity", content_type="application/json", |
|
990 |
json={"password": "foopass", "name": "Foo"}) |
|
991 |
assert identity_ret.status_code == 404 |
|
992 |
assert identity_ret.json == E_NO_CERTIFICATES_FOUND |
Také k dispozici: Unified diff
Re #8708 - Improved /api/certificate/{id}/identity test coverage by testing to send non well formed requests