From 2449c689d5915eca810cce0e42d683ab2ba18572 Mon Sep 17 00:00:00 2001 From: Alex Parlett Date: Fri, 26 Mar 2021 19:30:54 +0000 Subject: [PATCH] PR comments - styling and test fixes --- src/vault/authenticate.clj | 6 ++--- test/vault/client/http_test.clj | 48 ++++++++++++++++----------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/vault/authenticate.clj b/src/vault/authenticate.clj index 227ce11..398e375 100644 --- a/src/vault/authenticate.clj +++ b/src/vault/authenticate.clj @@ -14,8 +14,8 @@ (let [auth-info (lease/auth-lease (:auth (api-util/clean-body response)))] (when-not (:client-token auth-info) (throw (ex-info (str "No client token returned from non-error API response: " - (:status response) " " (:reason-phrase response)) - {:body (:body response)}))) + (:status response) " " (:reason-phrase response)) + {:body (:body response)}))) (log/info "Successfully authenticated to Vault as %s for policies: %s" claim (str/join ", " (:policies auth-info))) (reset! auth-ref auth-info))) @@ -31,7 +31,7 @@ (defmethod authenticate* :default [_ auth-type _] (throw (ex-info (str "Unsupported auth-type " (pr-str auth-type)) - {:auth-type auth-type}))) + {:auth-type auth-type}))) (defmethod authenticate* :token diff --git a/test/vault/client/http_test.clj b/test/vault/client/http_test.clj index ea9899b..d0a91e2 100644 --- a/test/vault/client/http_test.clj +++ b/test/vault/client/http_test.clj @@ -104,10 +104,10 @@ (swap! api-auths conj args) :api-auth!-response)] (vault/authenticate! client :aws-iam {:role "my-role" - :iam-http-request-method "POST" - :iam-request-url "fake.sts.com" - :iam-request-body "FakeAction&Version=1" - :iam-request-headers "{'foo':'bar'}"}) + :http-request-method "POST" + :request-url "fake.sts.com" + :request-body "FakeAction&Version=1" + :request-headers "{'foo':'bar'}"}) (is (= [[:post (str example-url "/v1/auth/aws/login") {:form-params {:iam_http_request_method "POST" @@ -123,7 +123,7 @@ (:auth client) :do-api-request-response]] @api-auths))))) - (testing "When no iam-http-request-method is specified" + (testing "When no http-request-method is specified" (let [client (http-client example-url) api-requests (atom []) api-auths (atom [])] @@ -133,12 +133,12 @@ (swap! api-auths conj args))] (is (thrown? IllegalArgumentException (vault/authenticate! client :aws-iam {:role "my-role" - :iam-request-url "fake.sts.com" - :iam-request-body "FakeAction&Version=1" - :iam-request-headers "{'foo':'bar'}"}))) + :request-url "fake.sts.com" + :request-body "FakeAction&Version=1" + :request-headers "{'foo':'bar'}"}))) (is (empty? @api-requests)) (is (empty? @api-auths))))) - (testing "When no iam-request-url is specified" + (testing "When no request-url is specified" (let [client (http-client example-url) api-requests (atom []) api-auths (atom [])] @@ -148,12 +148,12 @@ (swap! api-auths conj args))] (is (thrown? IllegalArgumentException (vault/authenticate! client :aws-iam {:role "my-role" - :iam-http-request-method "POST" - :iam-request-body "FakeAction&Version=1" - :iam-request-headers "{'foo':'bar'}"}))) + :http-request-method "POST" + :request-body "FakeAction&Version=1" + :request-headers "{'foo':'bar'}"}))) (is (empty? @api-requests)) (is (empty? @api-auths))))) - (testing "When no iam-request-body is specified" + (testing "When no request-body is specified" (let [client (http-client example-url) api-requests (atom []) api-auths (atom [])] @@ -163,12 +163,12 @@ (swap! api-auths conj args))] (is (thrown? IllegalArgumentException (vault/authenticate! client :aws-iam {:role "my-role" - :iam-http-request-method "POST" - :iam-request-url "fake.sts.com" - :iam-request-headers "{'foo':'bar'}"}))) + :http-request-method "POST" + :request-url "fake.sts.com" + :request-headers "{'foo':'bar'}"}))) (is (empty? @api-requests)) (is (empty? @api-auths))))) - (testing "When no iam-request-headers is specified" + (testing "When no request-headers is specified" (let [client (http-client example-url) api-requests (atom []) api-auths (atom [])] @@ -178,9 +178,9 @@ (swap! api-auths conj args))] (is (thrown? IllegalArgumentException (vault/authenticate! client :aws-iam {:role "my-role" - :iam-http-request-method "POST" - :iam-request-url "fake.sts.com" - :iam-request-body "FakeAction&Version=1"}))) + :http-request-method "POST" + :request-url "fake.sts.com" + :request-body "FakeAction&Version=1"}))) (is (empty? @api-requests)) (is (empty? @api-auths))))) (testing "When no role is specified" @@ -192,9 +192,9 @@ authenticate/api-auth! (fn [& args] (swap! api-auths conj args))] (is (thrown? IllegalArgumentException - (vault/authenticate! client :aws-iam {:iam-http-request-method "POST" - :iam-request-url "fake.sts.com" - :iam-request-body "FakeAction&Version=1" - :iam-request-headers "{'foo':'bar'}"}))) + (vault/authenticate! client :aws-iam {:http-request-method "POST" + :request-url "fake.sts.com" + :request-body "FakeAction&Version=1" + :request-headers "{'foo':'bar'}"}))) (is (empty? @api-requests)) (is (empty? @api-auths))))))