pub trait AuthSessionTestExt {
// Required methods
fn set_authenticated(
&self,
user_id: UserId,
tenant_id: TenantId,
authn_time: DateTime<Utc>,
) -> impl Future<Output = ()> + Send;
fn begin_authenticating(
&self,
user_id: UserId,
tenant_id: TenantId,
method_name: Arc<str>,
factors: Vec<FactorKind>,
) -> impl Future<Output = ()> + Send;
fn advance_factor(
&self,
kind: &FactorKind,
authn_time: DateTime<Utc>,
) -> impl Future<Output = ()> + Send;
fn record_attempt_at(
&self,
now: DateTime<Utc>,
) -> impl Future<Output = ()> + Send;
}testing only.Expand description
Test-fixture extension trait that re-exposes the
state-mutation methods on
AuthSession. The
inherent methods (set_authenticated, begin_authenticating,
advance_factor, record_attempt_at) are pub(crate) so handler
code can’t corrupt the factor-pipeline state machine by calling
them directly; the service-side login flow drives them through
audited entry points. Integration tests legitimately need to plant
a session in a fixture state; importing this trait makes those
methods callable on AuthSession again. Method names match the
inherent surface so existing test code only needs the new use
line: no per-site rewrite.
Always-on (not behind cfg(test)) so adopter integration tests
pick up the trait via axess-core in [dev-dependencies].
Importing AuthSessionTestExt in handler code is itself a strong
review signal that the handler is reaching past the audited entry
points; code reviewers should treat the use line as a red flag.
Extension trait; see module-level docs for the rationale.
Required Methods§
Sourcefn set_authenticated(
&self,
user_id: UserId,
tenant_id: TenantId,
authn_time: DateTime<Utc>,
) -> impl Future<Output = ()> + Send
fn set_authenticated( &self, user_id: UserId, tenant_id: TenantId, authn_time: DateTime<Utc>, ) -> impl Future<Output = ()> + Send
Force the session into AuthState::Authenticated.
Sourcefn begin_authenticating(
&self,
user_id: UserId,
tenant_id: TenantId,
method_name: Arc<str>,
factors: Vec<FactorKind>,
) -> impl Future<Output = ()> + Send
fn begin_authenticating( &self, user_id: UserId, tenant_id: TenantId, method_name: Arc<str>, factors: Vec<FactorKind>, ) -> impl Future<Output = ()> + Send
Force the session into AuthState::Authenticating
with the given factor sequence.
Sourcefn advance_factor(
&self,
kind: &FactorKind,
authn_time: DateTime<Utc>,
) -> impl Future<Output = ()> + Send
fn advance_factor( &self, kind: &FactorKind, authn_time: DateTime<Utc>, ) -> impl Future<Output = ()> + Send
Drive one factor-pipeline step from the test side,
advancing the in-session remaining queue and transitioning
to AuthState::Authenticated
when empty.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".