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