pub struct ServerFnAuthBuilder { /* private fields */ }Expand description
Builder for auth configuration in server_fn test contexts.
Mirrors the crate::client::APIClient auth builder API for primary auth.
Uses MockSession instead of a real AsyncSessionBackend.
Secondary auth layers (MFA, etc.) are not supported in server_fn contexts
because MockSession does not process HTTP headers. Use
crate::auth::SessionAuthBuilder with an APIClient for MFA testing.
Implementations§
Source§impl ServerFnAuthBuilder
impl ServerFnAuthBuilder
Sourcepub fn session(self, user: &impl ForceLoginUser) -> Self
pub fn session(self, user: &impl ForceLoginUser) -> Self
Authenticate as the given user via session.
No AsyncSessionBackend is required — uses MockSession internally.
Sourcepub fn jwt(self, user: &impl ForceLoginUser, _config: &JwtTestConfig) -> Self
pub fn jwt(self, user: &impl ForceLoginUser, _config: &JwtTestConfig) -> Self
Authenticate via JWT (sets identity for mock session).
Sourcepub fn with_staff(self, is_staff: bool) -> Self
pub fn with_staff(self, is_staff: bool) -> Self
Override the is_staff flag.
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 done(self) -> ServerFnTestContext
pub fn done(self) -> ServerFnTestContext
Finalize auth configuration and return the configured ServerFnTestContext.
Call .build() or .build_context() on the result to get the test environment.
Auto Trait Implementations§
impl !Freeze for ServerFnAuthBuilder
impl !RefUnwindSafe for ServerFnAuthBuilder
impl Send for ServerFnAuthBuilder
impl !Sync for ServerFnAuthBuilder
impl Unpin for ServerFnAuthBuilder
impl UnsafeUnpin for ServerFnAuthBuilder
impl !UnwindSafe for ServerFnAuthBuilder
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
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>
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>
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