pub struct TestUtilsApi<'a, S: AuthSchema> { /* private fields */ }Expand description
Native helpers bound to one initialized authentication instance.
Implementations§
Source§impl<'a, S: AuthSchema> TestUtilsApi<'a, S>
impl<'a, S: AuthSchema> TestUtilsApi<'a, S>
Sourcepub fn from_context(auth: &'a AuthContext<S>) -> AuthResult<Self>
pub fn from_context(auth: &'a AuthContext<S>) -> AuthResult<Self>
Access helpers only when TestUtilsPlugin is installed on this instance.
Sourcepub fn from_endpoint(endpoint: &'a EndpointContext<'a, S>) -> AuthResult<Self>
pub fn from_endpoint(endpoint: &'a EndpointContext<'a, S>) -> AuthResult<Self>
Preserve the active transaction when invoking helpers from an endpoint callback.
Sourcepub fn create_user(&self, overrides: CreateUser) -> AuthResult<CreateUser>
pub fn create_user(&self, overrides: CreateUser) -> AuthResult<CreateUser>
Build a user without persisting it. The configured ID generator still runs for explicit IDs.
Sourcepub async fn save_user(&self, user: CreateUser) -> AuthResult<Option<UserView>>
pub async fn save_user(&self, user: CreateUser) -> AuthResult<Option<UserView>>
Persist a user through admission and database hooks. A cancelled before hook returns None.
Sourcepub async fn delete_user(&self, id: &str) -> AuthResult<()>
pub async fn delete_user(&self, id: &str) -> AuthResult<()>
Delete the user through the internal adapter’s session and account cleanup.
Sourcepub fn organization(&self) -> Option<TestOrganizationApi<'_, S>>
pub fn organization(&self) -> Option<TestOrganizationApi<'_, S>>
Organization factories are available only when the organization plugin is installed.
Sourcepub fn otps(&self) -> Option<&OtpCapture>
pub fn otps(&self) -> Option<&OtpCapture>
OTP capture is absent unless explicitly enabled for this instance.
Sourcepub async fn login(&self, options: TestAuthOptions) -> AuthResult<TestLogin>
pub async fn login(&self, options: TestAuthOptions) -> AuthResult<TestLogin>
Create one session after confirming that the user exists.
Sourcepub async fn get_auth_headers(
&self,
options: TestAuthOptions,
) -> AuthResult<HashMap<String, String>>
pub async fn get_auth_headers( &self, options: TestAuthOptions, ) -> AuthResult<HashMap<String, String>>
Create a fresh session and its raw signed Cookie request header without a user lookup.
Create a fresh session and browser-cookie attributes without a user lookup.