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§
Trait Implementations§
Source§impl Default for TestSessionValidator
impl Default for TestSessionValidator
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
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn validate<'life0, 'life1, 'async_trait>(
&'life0 self,
cookie: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<AuthContext>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: '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