-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test for api_key/0 with DWYL_API_KEY #14 💯
- Loading branch information
Showing
2 changed files
with
20 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
defmodule AuthPlugTokenTest do | ||
use ExUnit.Case, async: true | ||
use ExUnit.Case, async: false | ||
import AuthPlug.Token | ||
|
||
test "api_key/0 with AUTH_API_KEY" do | ||
assert api_key() == System.get_env("AUTH_API_KEY") | ||
end | ||
|
||
|
||
test "generate_jwt!/2 creates a JWT with the given data and secret" do | ||
secret = "secretcanbeanystringyouwant" | ||
data = %{email: "[email protected]", name: "Alex"} | ||
|
@@ -21,4 +26,10 @@ defmodule AuthPlugTokenTest do | |
{:ok, decoded} = verify_jwt(jwt, secret) | ||
assert data.email == Map.get(decoded, "email") | ||
end | ||
|
||
test "api_key/0 with DWYL_API_KEY" do | ||
System.put_env("DWYL_API_KEY", System.get_env("AUTH_API_KEY")) | ||
assert api_key() == System.get_env("AUTH_API_KEY") | ||
# System.put_env("DWYL_API_KEY", nil) | ||
end | ||
end |