pub trait TokenFactoryExt {
// Required methods
fn token(&self, label: impl AsRef<str>, spec: TokenSpec) -> TokenFixture;
fn token_with_variant(
&self,
label: impl AsRef<str>,
spec: TokenSpec,
variant: impl AsRef<str>,
) -> TokenFixture;
}Expand description
Extension trait to hang token helpers off the core Factory.
Required Methods§
Sourcefn token(&self, label: impl AsRef<str>, spec: TokenSpec) -> TokenFixture
fn token(&self, label: impl AsRef<str>, spec: TokenSpec) -> TokenFixture
Generate (or retrieve from cache) a token fixture.
The label identifies this token within your test suite.
In deterministic mode, seed + label + spec always produces the same token.
§Examples
let fx = Factory::deterministic(Seed::from_env_value("test-seed").unwrap());
let tok = fx.token("billing", TokenSpec::bearer());
assert!(!tok.value().is_empty());Sourcefn token_with_variant(
&self,
label: impl AsRef<str>,
spec: TokenSpec,
variant: impl AsRef<str>,
) -> TokenFixture
fn token_with_variant( &self, label: impl AsRef<str>, spec: TokenSpec, variant: impl AsRef<str>, ) -> TokenFixture
Generate a token fixture with an explicit variant.
Different variants for the same (label, spec) produce different tokens.
§Examples
let fx = Factory::deterministic(Seed::from_env_value("test-seed").unwrap());
let good = fx.token("svc", TokenSpec::api_key());
let alt = fx.token_with_variant("svc", TokenSpec::api_key(), "alt");
assert_ne!(good.value(), alt.value());Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.