From 2da7c9b3816c1509237464ea18efb0f5b9e8e998 Mon Sep 17 00:00:00 2001 From: Arthur Lawson Date: Mon, 31 Jul 2023 11:15:16 -0700 Subject: [PATCH] (PE-36076) Remove content type from certificate reject Previously, when a `DELETE` request was sent to `puppet-ca/v1/certificate_status/` a 204 response was sent with a malformed content-type header. This commit removes the header. --- .../services/ca/certificate_authority_core.clj | 9 ++++++--- .../services/ca/certificate_authority_core_test.clj | 2 -- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/clj/puppetlabs/services/ca/certificate_authority_core.clj b/src/clj/puppetlabs/services/ca/certificate_authority_core.clj index ac8b86906..81a2cce91 100644 --- a/src/clj/puppetlabs/services/ca/certificate_authority_core.clj +++ b/src/clj/puppetlabs/services/ca/certificate_authority_core.clj @@ -132,9 +132,12 @@ ca-settings :- ca/CaSettings] (let [response (ca/delete-certificate-request! ca-settings subject) outcomes->codes {:success 204 :not-found 404 :error 500}] - (-> (rr/response (:message response)) - (rr/status ((response :outcome) outcomes->codes)) - (rr/content-type "text/plain")))) + (if (= (response :outcome) :error) + (-> (rr/content-type ("text/plain")) + (rr/response (:message response)) + (rr/status ((response :outcome) outcomes->codes))) + (-> (rr/response (:message response)) + (rr/status ((response :outcome) outcomes->codes)))))) (schema/defn handle-get-ca-expirations [ca-settings :- ca/CaSettings] diff --git a/test/unit/puppetlabs/services/ca/certificate_authority_core_test.clj b/test/unit/puppetlabs/services/ca/certificate_authority_core_test.clj index 6bb71fe28..30fdca993 100644 --- a/test/unit/puppetlabs/services/ca/certificate_authority_core_test.clj +++ b/test/unit/puppetlabs/services/ca/certificate_authority_core_test.clj @@ -321,7 +321,6 @@ (is (false? (fs/exists? expected-path))) (is (= 204 (:status response))) (is (re-matches msg-matcher (:body response))) - (is (= "text/plain" (get-in response [:headers "Content-Type"]))) (is (logged? msg-matcher :debug))) (finally (fs/delete expected-path)))))) @@ -335,7 +334,6 @@ (is (false? (fs/exists? expected-path))) (is (= 404 (:status response))) (is (re-matches msg-matcher (:body response))) - (is (= "text/plain" (get-in response [:headers "Content-Type"]))) (is (logged? msg-matcher :warn))))) (testing "Error during deletion of a CSR" (logutils/with-test-logging