Skip to main content

ScriptedOAuthProvider

Struct ScriptedOAuthProvider 

Source
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

Source

pub fn new() -> Self

A provider whose tokens read scripted-token-{n} and live one hour per grant.

Source

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).

Source

pub fn with_grant_ttl(self, ttl: Duration) -> Self

Builder-style: the lifetime stamped on minted grants.

Source

pub fn with_code(self, code: impl Into<String>, grant: TokenGrant) -> Self

Script code to exchange for grant.

Source

pub fn with_code_failure( self, code: impl Into<String>, failure: OAuthFailure, ) -> Self

Script code to fail its exchange with failure.

Source

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).

Source

pub fn then_refresh_grant(self, grant: TokenGrant) -> Self

Queue a scripted refresh grant.

Source

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ScriptedOAuthProvider

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

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,

Exchange an authorization code for the initial grant — the back half of the human’s consent act at the provider. The 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,

Refresh the connection’s access token. The two OAuth flows differ in what they present, and the provider sees the sealed material so it can serve both: authorization-code connections present 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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more