pub struct ScriptedOAuthProvider { /* private fields */ }Expand description
A scripted OAuth provider for tests and embedder smoke checks — the
lifecycle’s stand-in for a live token endpoint, so no test needs a
network. Authorization codes map to scripted outcomes (an unknown code
is the provider’s invalid_grant, permanent); refreshes pop a
scripted queue and default to rotation: each call mints the next
access token beneath the same refresh token, which is exactly the
provider behavior the broker’s rotation-beneath-a-stable-id contract
is built on.
Implementations§
Source§impl ScriptedOAuthProvider
impl ScriptedOAuthProvider
Sourcepub fn new() -> Self
pub fn new() -> Self
A provider whose tokens read scripted-token-{n} and live one
hour per grant.
Sourcepub fn with_token_prefix(self, prefix: impl Into<String>) -> Self
pub fn with_token_prefix(self, prefix: impl Into<String>) -> Self
Builder-style: the minted token prefix (a distinctive marker, so a leak scan is a scan for it).
Sourcepub fn with_grant_ttl(self, ttl: Duration) -> Self
pub fn with_grant_ttl(self, ttl: Duration) -> Self
Builder-style: the lifetime stamped on minted grants.
Sourcepub fn with_code(self, code: impl Into<String>, grant: TokenGrant) -> Self
pub fn with_code(self, code: impl Into<String>, grant: TokenGrant) -> Self
Script code to exchange for grant.
Sourcepub fn with_code_failure(
self,
code: impl Into<String>,
failure: OAuthFailure,
) -> Self
pub fn with_code_failure( self, code: impl Into<String>, failure: OAuthFailure, ) -> Self
Script code to fail its exchange with failure.
Sourcepub fn then_refresh_failure(self, failure: OAuthFailure) -> Self
pub fn then_refresh_failure(self, failure: OAuthFailure) -> Self
Queue a scripted refresh failure (consumed in call order; the queue empty is steady-state rotation — a transient failure that heals is one entry, a terminal one is the last).
Sourcepub fn then_refresh_grant(self, grant: TokenGrant) -> Self
pub fn then_refresh_grant(self, grant: TokenGrant) -> Self
Queue a scripted refresh grant.
Sourcepub fn call_counts(&self) -> (usize, u64)
pub fn call_counts(&self) -> (usize, u64)
(exchanges, refreshes) observed so far — the assertions a
lifecycle test makes (“the rotation happened exactly once”).
Trait Implementations§
Source§impl Debug for ScriptedOAuthProvider
impl Debug for ScriptedOAuthProvider
Source§impl Default for ScriptedOAuthProvider
impl Default for ScriptedOAuthProvider
Source§impl OAuthProvider for ScriptedOAuthProvider
impl OAuthProvider for ScriptedOAuthProvider
Source§fn exchange_code<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
code: &'life1 str,
scopes: &'life2 BTreeSet<String>,
) -> Pin<Box<dyn Future<Output = Result<TokenGrant, OAuthFailure>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn exchange_code<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
code: &'life1 str,
scopes: &'life2 BTreeSet<String>,
) -> Pin<Box<dyn Future<Output = Result<TokenGrant, OAuthFailure>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
scopes are
the consent set being recorded; providers that echo the granted
scope set in the exchange response answer for the same set.Source§fn refresh<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
connection: &'life1 ConnectionRecord,
material: &'life2 TokenMaterial,
) -> Pin<Box<dyn Future<Output = Result<TokenGrant, OAuthFailure>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn refresh<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
connection: &'life1 ConnectionRecord,
material: &'life2 TokenMaterial,
) -> Pin<Box<dyn Future<Output = Result<TokenGrant, OAuthFailure>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
material.refresh_token; client-credentials connections re-present
material.client_secret. The connection record rides along for the
provider kind, the subject, and the consented scope set.