pub struct SessionAuthBuilder<'a> { /* private fields */ }Expand description
Builder for session-based test authentication.
Created by AuthBuilder::session().
Implementations§
Source§impl<'a> SessionAuthBuilder<'a>
impl<'a> SessionAuthBuilder<'a>
Sourcepub fn with_staff(self, is_staff: bool) -> Self
pub fn with_staff(self, is_staff: bool) -> Self
Override the is_staff flag.
Use this when the user’s ForceLoginUser impl defaults is_staff to false
but the test requires staff access.
Sourcepub fn with_superuser(self, is_superuser: bool) -> Self
pub fn with_superuser(self, is_superuser: bool) -> Self
Override the is_superuser flag.
Sourcepub fn with_mfa_code(self, code: impl Into<String>) -> Self
pub fn with_mfa_code(self, code: impl Into<String>) -> Self
Add TOTP MFA as a secondary auth layer.
Uses a pre-generated TOTP code. Generate it from the user’s registered secret before calling this method.
Sourcepub fn with_secondary(self, auth: impl SecondaryAuth + 'static) -> Self
pub fn with_secondary(self, auth: impl SecondaryAuth + 'static) -> Self
Add a custom secondary auth layer.
Sourcepub async fn apply(self) -> Result<(), TestAuthError>
pub async fn apply(self) -> Result<(), TestAuthError>
Apply the authentication configuration to the client.
This creates a real session in the backend, sets the sessionid cookie,
and applies any secondary auth layers.
Auto Trait Implementations§
impl<'a> Freeze for SessionAuthBuilder<'a>
impl<'a> !RefUnwindSafe for SessionAuthBuilder<'a>
impl<'a> Send for SessionAuthBuilder<'a>
impl<'a> Sync for SessionAuthBuilder<'a>
impl<'a> Unpin for SessionAuthBuilder<'a>
impl<'a> UnsafeUnpin for SessionAuthBuilder<'a>
impl<'a> !UnwindSafe for SessionAuthBuilder<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more