Macaw.Auth.Conformance.Fixtures behaviour (macaw_auth v0.4.1)

Copy Markdown View Source

What a backend gives the conformance kit.

Summary

Callbacks

Deletes a user from the backend's store, as an administrator would, after they signed in: the kit then asks for a session for them.

Disables a user.

Enrolls user in the backend's second factor, the way a user would (begin, then confirm with a valid code), and returns a function that gives a code the backend accepts at the moment it is called and has not yet accepted: a fresh device's current code. (A fixture that confirmed with the current step's code should have confirmed with the previous step's, so the current one is still unspent.)

How long a session may idle before it expires, in seconds.

Resets the backend's store before each test.

Every value the backend stores for sessions (to prove no token is stored as is).

Makes a user; attrs may set :second_factor (:none | :enrolled | :required). Returns the user and credentials that sign it in.

Callbacks

delete!(t)

@callback delete!(Macaw.Auth.User.t()) :: :ok

Deletes a user from the backend's store, as an administrator would, after they signed in: the kit then asks for a session for them.

disable!(t)

@callback disable!(Macaw.Auth.User.t()) :: :ok

Disables a user.

enroll_second_factor!(t)

@callback enroll_second_factor!(Macaw.Auth.User.t()) :: (-> String.t())

Enrolls user in the backend's second factor, the way a user would (begin, then confirm with a valid code), and returns a function that gives a code the backend accepts at the moment it is called and has not yet accepted: a fresh device's current code. (A fixture that confirmed with the current step's code should have confirmed with the previous step's, so the current one is still unspent.)

idle_seconds()

@callback idle_seconds() :: pos_integer()

How long a session may idle before it expires, in seconds.

reset!()

@callback reset!() :: :ok

Resets the backend's store before each test.

stored_session_values()

@callback stored_session_values() :: [binary()]

Every value the backend stores for sessions (to prove no token is stored as is).

user!(map)

@callback user!(map()) :: {Macaw.Auth.User.t(), map()}

Makes a user; attrs may set :second_factor (:none | :enrolled | :required). Returns the user and credentials that sign it in.