Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAML 2 azure ad compatibility two: revenge of codecov #84

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/saml20_clj/sp/request.clj
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@
(assert (non-blank-string? idp-url) "idp-url is required")
(assert (non-blank-string? issuer) "issuer is required")
(assert (non-blank-string? user-email) "user-email is required")
[:samlp:LogoutRequest {:xmlns:samlp "urn:oasis:names:tc:SAML:2.0:protocol"
[:samlp:LogoutRequest {:xmlns "urn:oasis:names:tc:SAML:2.0:protocol"
:xmlns:samlp "urn:oasis:names:tc:SAML:2.0:protocol"
:xmlns:saml "urn:oasis:names:tc:SAML:2.0:assertion"
:Version "2.0"
:ID (or request-id (str "id" (random-uuid)))
:IssueInstant instant
:Destination idp-url}
[:saml:Issuer issuer]
[:saml:NameID {:Format "urn:oasis:names:tc:SAML:2.0:nameid-format:emailAddress"} user-email]
[:samlp:SessionIndex "SessionIndex_From_Authentication_Assertion"]])
[:Issuer issuer]
[:NameID {:Format "urn:oasis:names:tc:SAML:2.0:nameid-format:emailAddress"} user-email]])

(defn logout-redirect-location
"This returns a url that you'd want to redirect a client to. Either using
Expand Down
25 changes: 6 additions & 19 deletions test/saml20_clj/sp/request_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@
(doseq [v [nil "" " " false true 100]]
(testing (format "\n%s = %s" k (pr-str v))
(let [request (assoc request k v)]
(is (thrown-with-msg?
java.lang.AssertionError
(is (thrown-with-msg? java.lang.AssertionError
(re-pattern (format "%s is required" (name k)))
(request/request request))))))))))

Expand All @@ -202,28 +201,16 @@
:idp-url "http://idp.example.com/SSOService.php"
:issuer "http://sp.example.com/demo1/metadata.php"}))]
(is (= [:samlp:LogoutRequest
{:xmlns:samlp "urn:oasis:names:tc:SAML:2.0:protocol"
{:xmlns "urn:oasis:names:tc:SAML:2.0:protocol"
:xmlns:samlp "urn:oasis:names:tc:SAML:2.0:protocol"
:xmlns:saml "urn:oasis:names:tc:SAML:2.0:assertion"
:Version "2.0"
:ID "ONELOGIN_109707f0030a5d00620c9d9df97f627afe9dcc24"
:IssueInstant "2020-09-24T22:51:00Z"
:Destination "http://idp.example.com/SSOService.php"}
[:saml:Issuer "http://sp.example.com/demo1/metadata.php"]
[:saml:NameID {:Format "urn:oasis:names:tc:SAML:2.0:nameid-format:emailAddress"} "[email protected]"]
[:samlp:SessionIndex "SessionIndex_From_Authentication_Assertion"]]
logout-xml))
(is (= (str "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" "\n"
"<samlp:LogoutRequest Destination=\"http://idp.example.com/SSOService.php\" "
"ID=\"ONELOGIN_109707f0030a5d00620c9d9df97f627afe9dcc24\" "
"IssueInstant=\"2020-09-24T22:51:00Z\" "
"Version=\"2.0\" "
"xmlns:saml=\"urn:oasis:names:tc:SAML:2.0:assertion\" "
"xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\">"
"<saml:Issuer>http://sp.example.com/demo1/metadata.php</saml:Issuer>"
"<saml:NameID Format=\"urn:oasis:names:tc:SAML:2.0:nameid-format:emailAddress\">[email protected]</saml:NameID>"
"<samlp:SessionIndex>SessionIndex_From_Authentication_Assertion</samlp:SessionIndex>"
"</samlp:LogoutRequest>")
(coerce/->xml-string logout-xml)))))
[:Issuer "http://sp.example.com/demo1/metadata.php"]
[:NameID {:Format "urn:oasis:names:tc:SAML:2.0:nameid-format:emailAddress"} "[email protected]"]]
logout-xml))))

(t/with-clock (t/mock-clock (t/instant "2020-09-24T22:51:00.000Z"))
(request/logout-redirect-location
Expand Down
2 changes: 1 addition & 1 deletion test/saml20_clj/sp/response_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
(testing (str "\noriginal =\n" (coerce/->xml-string original))
(testing (str "decrypted =\n" (coerce/->xml-string decrypted))
(prn :original (coerce/->xml-string original))
(prn :descrypted (coerce/->xml-string decrypted))
(prn :decrypted (coerce/->xml-string decrypted))
(is (= 0
(count (.getEncryptedAssertions decrypted))))
(is (= 1
Expand Down
Loading