Skip to main content

Module testing

Module testing 

Source
Expand description

Test helpers and in-memory fakes for auth integration tests.

Re-exports§

pub use crate::jwt::JwtStrategy as TestJwtStrategy;
pub use crate::session::SessionStrategy as TestSessionStrategy;

Structs§

AuthTestGuard
Holds the auth test lock for the duration of a test (serialises global auth state).
TestResponse
The status + body captured from a test request.
TestUser
Simple in-memory user for auth tests.

Functions§

create_test_user
Create a user in the in-memory store.
hash_test_password
Hash a password at the low test cost.
init_test_auth
Initialise in-memory auth state for tests.
jwt_for_user
Issue a signed JWT access token for a test user id.
reset_store
Reset the in-memory user store between tests.
send
Send a request to router in-process and capture the response.
send_with_headers
Send a request with extra headers.
session_for_user
Sign a user into a fresh session (helper for session strategy tests).
test_auth_config
Build a default auth config for tests (cookie strategy only).
test_jwt_auth_config
Build auth config with JWT enabled.