pub struct TestSessionValidator;Expand description
Test session validator that accepts simple cookie formats
This validator is intended for E2E testing without requiring Keycloak. It accepts two cookie formats:
-
Simple format:
session=<user_id>- Creates AuthContext with user_id and default tenant/roles
- Example:
session=alice→ user_id=“alice”, tenant=“test-tenant”, roles=[“user”]
-
Advanced format:
test_user=<user_id>|tenant=<tenant>|roles=<role1>,<role2>- Allows specifying tenant and roles for testing multi-tenancy and RBAC
- Example:
test_user=bob|tenant=acme|roles=admin,user
§Security
WARNING: This validator should NEVER be used in production. It accepts any user_id without verification. Use feature flags or environment variables to ensure it’s only available in test/dev builds.
Implementations§
Source§impl TestSessionValidator
impl TestSessionValidator
pub fn new() -> TestSessionValidator
Trait Implementations§
Source§impl Default for TestSessionValidator
impl Default for TestSessionValidator
Source§fn default() -> TestSessionValidator
fn default() -> TestSessionValidator
Returns the “default value” for a type. Read more
Source§impl SessionValidator for TestSessionValidator
impl SessionValidator for TestSessionValidator
Source§fn validate<'life0, 'life1, 'async_trait>(
&'life0 self,
cookie: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<AuthContext>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
TestSessionValidator: 'async_trait,
fn validate<'life0, 'life1, 'async_trait>(
&'life0 self,
cookie: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<AuthContext>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
TestSessionValidator: 'async_trait,
Validate a cookie header value and return an AuthContext if valid. Read more
Auto Trait Implementations§
impl Freeze for TestSessionValidator
impl RefUnwindSafe for TestSessionValidator
impl Send for TestSessionValidator
impl Sync for TestSessionValidator
impl Unpin for TestSessionValidator
impl UnsafeUnpin for TestSessionValidator
impl UnwindSafe for TestSessionValidator
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