View Source Charon.TestHelpers (Charon v3.2.0)
Utility functions for writing tests.
Summary
Functions
Create a test session and return the session, a set of tokens for it and the response cookies.
Override configuration for an optional module.
Create a new test session and put a token (and its cookie when needed) on the conn.
This is essentially create_session/3
and put_token_for/3
combined into one
convenience function.
Put a token (and its cookie when needed) from the test session on the conn.
Use create_session/3
to create the test session.
Types
@type test_session() :: %{ session: Charon.Models.Session.t(), tokens: Charon.Models.Tokens.t(), cookies: Plug.Conn.resp_cookies() }
Functions
@spec create_session(Charon.Config.t(), Charon.SessionPlugs.upsert_session_opts()) :: test_session()
Create a test session and return the session, a set of tokens for it and the response cookies.
Options
:upsert_session_opts
(default[]
) as defined inCharon.SessionPlugs.upsert_session_opts/0
@spec override_opt_mod_conf(Charon.Config.t(), atom() | binary(), map() | keyword()) :: Charon.Config.t()
Override configuration for an optional module.
@spec put_token(Plug.Conn.t(), Charon.Config.t(), keyword()) :: Plug.Conn.t()
Create a new test session and put a token (and its cookie when needed) on the conn.
This is essentially create_session/3
and put_token_for/3
combined into one
convenience function.
Options
The upsert_session_opts defined in Charon.SessionPlugs.upsert_session_opts/0
AND
:token
is either:access
(default) or:refresh
@spec put_token_for(Plug.Conn.t(), test_session(), [{:token, :access | :refresh}]) :: Plug.Conn.t()
Put a token (and its cookie when needed) from the test session on the conn.
Use create_session/3
to create the test session.
Options
:token
is either:access
(default) or:refresh