Skip to main content

reinhardt_testkit/
auth.rs

1//! Test authentication utilities.
2//!
3//! Provides a builder-based API for setting up authentication state in tests.
4//!
5//! # Architecture
6//!
7//! - **`ForceLoginUser`**: Trait for extracting session identity from any user type.
8//!   Blanket-implemented for all `AuthIdentity` types (available on native targets).
9//! - **`SessionIdentity`**: Type-erased identity struct matching `CookieSessionAuthMiddleware` fields.
10//! - **`AuthBuilder`**: Entry point returned by `APIClient::auth()`.
11//! - **`SecondaryAuth`**: Open trait for secondary auth layers (MFA, PassKey, etc.).
12//!
13//! # Platform Support
14//!
15//! Session/JWT builders, TOTP secondary auth, and `AuthIdentity` blanket impl are
16//! available unconditionally on native targets (non-wasm).
17
18mod error;
19mod identity;
20mod secondary;
21mod traits;
22
23pub use error::TestAuthError;
24pub use identity::SessionIdentity;
25pub use secondary::SecondaryAuth;
26pub use traits::ForceLoginUser;
27
28#[cfg(native)]
29pub use secondary::TotpSecondaryAuth;
30
31#[cfg(native)]
32mod builder;
33#[cfg(native)]
34pub use builder::{AuthBuilder, JwtAuthBuilder, JwtTestConfig, SessionAuthBuilder};
35
36#[cfg(native)]
37mod server_fn_builder;
38#[cfg(native)]
39pub use server_fn_builder::ServerFnAuthBuilder;