From 63de8047ce51f2da0ff181035afb330097017355 Mon Sep 17 00:00:00 2001 From: Ronald Moesbergen Date: Wed, 27 Feb 2019 09:38:25 +0100 Subject: [PATCH] Return 'already deleted' instead of 'not found' when cert has already been deleted --- lemur/certificates/views.py | 5 ++++- lemur/tests/test_certificates.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lemur/certificates/views.py b/lemur/certificates/views.py index b464b3ed..e77160b2 100644 --- a/lemur/certificates/views.py +++ b/lemur/certificates/views.py @@ -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) diff --git a/lemur/tests/test_certificates.py b/lemur/tests/test_certificates.py index 75a29e16..a020ac6b 100644 --- a/lemur/tests/test_certificates.py +++ b/lemur/tests/test_certificates.py @@ -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):