Return 'already deleted' instead of 'not found' when cert has already been deleted

This commit is contained in:
Ronald Moesbergen 2019-02-27 09:38:25 +01:00
parent a9735e129c
commit 63de8047ce
2 changed files with 5 additions and 2 deletions

View File

@ -691,9 +691,12 @@ class Certificates(AuthenticatedResource):
cert = service.get(certificate_id)
if not cert or cert.deleted:
if not cert:
return dict(message="Cannot find specified certificate"), 404
if cert.deleted:
return dict(message="Certificate is already deleted"), 412
# allow creators
if g.current_user != cert.user:
owner_role = role_service.get_by_name(cert.owner)

View File

@ -738,7 +738,7 @@ def test_certificate_put_with_data(client, certificate, issuer_plugin):
@pytest.mark.parametrize("token,status", [
(VALID_USER_HEADER_TOKEN, 403),
(VALID_ADMIN_HEADER_TOKEN, 204),
(VALID_ADMIN_API_TOKEN, 404),
(VALID_ADMIN_API_TOKEN, 412),
('', 401)
])
def test_certificate_delete(client, token, status):