From b57d54569d7f518779f94e344191d9d820e54133 Mon Sep 17 00:00:00 2001 From: nelsonic Date: Fri, 24 Apr 2020 10:46:58 +0100 Subject: [PATCH] create test for virify_jwt/2 #9 --- test/token_test.exs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/token_test.exs b/test/token_test.exs index 417e7ef..ebdbcef 100644 --- a/test/token_test.exs +++ b/test/token_test.exs @@ -11,4 +11,14 @@ defmodule AuthPlugTokenTest do decoded = verify_jwt!(jwt, secret) assert data.email == Map.get(decoded, "email") end + + + test "verify_jwt/2 verifies a JWT with the given secret" do + secret = "secretcanbeanystringyouwant" + data = %{email: "alex@dwyl.com", name: "Alex"} + jwt = generate_jwt!(data, secret) + + {:ok, decoded} = verify_jwt(jwt, secret) + assert data.email == Map.get(decoded, "email") + end end