Skip to content

Commit

Permalink
add tests for generate_jwt!/2 for #9
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Apr 24, 2020
1 parent a41ee7d commit e197283
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/token_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
defmodule AuthPlugTokenTest do
use ExUnit.Case, async: true
import AuthPlug.Token

test "generate_jwt!/2 creates a JWT with the given data and secret" do
secret = "secretcanbeanystringyouwant"
data = %{email: "[email protected]", name: "Alex"}
jwt = generate_jwt!(data, secret)
assert Enum.count(String.split(jwt, ".")) == 3

decoded = verify_jwt!(jwt, secret)
assert data.email == Map.get(decoded, "email")
end
end

0 comments on commit e197283

Please sign in to comment.