File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -10,15 +10,22 @@ defmodule JwtTestUtils.AuthConnCase do
1010 @ fake_user_id "user@fake.is"
1111 @ auth_header "authorization"
1212
13+ alias JwtTestUtils.JwtMocker
14+
1315 @ doc """
1416 Returns a Plug.Conn with a injected header with a JWT token injected.
1517
1618 By default returns always the same token in the "authorization" header.
1719 """
18- @ spec get_claim ( String . t ( ) , String . t ( ) ) :: { Plug.Conn . t ( ) }
20+ @ spec build_authed_conn ( String . t ( ) , String . t ( ) ) :: { Plug.Conn . t ( ) }
1921 def build_authed_conn ( user_id \\ @ fake_user_id , auth_header \\ @ auth_header ) do
2022 jwt = JwtMocker . generate_json_token ( user_id )
21- conn = Plug.Adapters.Test.Conn . conn ( % Conn { } , :get , "/" , nil )
23+
24+ conn =
25+ Plug.Adapters.Test.Conn . conn ( % Plug.Conn { } , :get , "/" , nil )
26+ |> Plug.Conn . put_private ( :plug_skip_csrf_protection , true )
27+ |> Plug.Conn . put_private ( :phoenix_recycled , true )
28+
2229 Plug.Conn . put_req_header ( conn , auth_header , jwt )
2330 end
2431 end
You can’t perform that action at this time.
0 commit comments