diff --git a/README.md b/README.md index cd67d50..7b89eb2 100644 --- a/README.md +++ b/README.md @@ -141,6 +141,14 @@ echo ".env" >> .gitignore ### 3. Protect a Route +Open your project's `router.ex` file. e.g: + + + + +### (Optional) Update `endpoint.ex` + + diff --git a/test/token_test.exs b/test/token_test.exs index ebdbcef..2fdf11c 100644 --- a/test/token_test.exs +++ b/test/token_test.exs @@ -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: "alex@dwyl.com", 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