Add tests for signing functionality

Signed-off-by: Snorre Magnus Davøen's avatarSnorre Magnus Davøen <snorre.davoen@nsd.no>
parent 4689c59f
Pipeline #19304 passed with stage
in 39 seconds
......@@ -85,3 +85,12 @@ vLu9XxKFHYlWPccluz3pqDfaGNPO12968DAldwvAV6hTGgx7oMaNPu0UltgD/aaj
(is (thrown? Exception
(with-redefs [clj-jwt/keystore (atom {})]
(clj-jwt/unsign (resource "jwks-other.json") signed-jwt))))))
(deftest sign-claims
(testing "Signs claims and return a valid jwt"
(is (= (with-redefs [clj-jwt/keystore (atom {"test-key" {:private-key ec-privkey}})]
(clj-jwt/sign (resource "jwks.json") "test-key" {:sub "foo"}))
"eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJmb28ifQ.PuYhFdk67n-DQHFjgMYeL2WBq1bLQ9yo-9CZulTIWjc_GqN66YuyM6kv1-aKlamH6ZPE3I4W20SgjQWpx84Fl9OuTG9YE6bKsbPCSDRb6w_fY8uWVh6vZpEj6yGL2_fpqdvg3cNK1qfD0x8V-dD24766LMKH1DzawPENer9WB-A")))
(testing "Fails if given key-id not in jwks resource"
(is (thrown? Exception (with-redefs [clj-jwt/keystore (atom {"test-key" {:private-key ec-privkey}})]
(clj-jwt/sign (resource "jwks.json") "no-such-key" {:sub "foo"}))))))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment