Skip to content

Commit

Permalink
PR comments - styling and test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexparlett committed Mar 26, 2021
1 parent 50735e5 commit 2449c68
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
6 changes: 3 additions & 3 deletions src/vault/authenticate.clj
Expand Up @@ -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)))
Expand All @@ -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
Expand Down
48 changes: 24 additions & 24 deletions test/vault/client/http_test.clj
Expand Up @@ -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"
Expand All @@ -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 [])]
Expand All @@ -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 [])]
Expand All @@ -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 [])]
Expand All @@ -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 [])]
Expand All @@ -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"
Expand All @@ -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))))))

0 comments on commit 2449c68

Please sign in to comment.