Skip to content

Commit

Permalink
Missing module fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrián Quintás committed Mar 6, 2018
1 parent 517d9d6 commit 086e519
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/auth_conn_case.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,22 @@ defmodule JwtTestUtils.AuthConnCase do
@fake_user_id "[email protected]"
@auth_header "authorization"

alias JwtTestUtils.JwtMocker

@doc """
Returns a Plug.Conn with a injected header with a JWT token injected.
By default returns always the same token in the "authorization" header.
"""
@spec get_claim(String.t(), String.t()) :: {Plug.Conn.t()}
@spec build_authed_conn(String.t(), String.t()) :: {Plug.Conn.t()}
def build_authed_conn(user_id \\ @fake_user_id, auth_header \\ @auth_header) do
jwt = JwtMocker.generate_json_token(user_id)
conn = Plug.Adapters.Test.Conn.conn(%Conn{}, :get, "/", nil)

conn =
Plug.Adapters.Test.Conn.conn(%Plug.Conn{}, :get, "/", nil)
|> Plug.Conn.put_private(:plug_skip_csrf_protection, true)
|> Plug.Conn.put_private(:phoenix_recycled, true)

Plug.Conn.put_req_header(conn, auth_header, jwt)
end
end
Expand Down

0 comments on commit 086e519

Please sign in to comment.