pub struct TokenFixture { /* private fields */ }Expand description
A token fixture with a generated value.
Created via TokenFactoryExt::token(). Provides access to
the generated token value and an HTTP Authorization header.
§Examples
let fx = Factory::deterministic(Seed::from_env_value("test-seed").unwrap());
let tok = fx.token("api-key", TokenSpec::api_key());
assert!(tok.value().starts_with("uk_test_"));Implementations§
Source§impl TokenFixture
impl TokenFixture
Sourcepub fn value(&self) -> &str
pub fn value(&self) -> &str
Access the token value.
§Examples
let fx = Factory::deterministic(Seed::from_env_value("test-seed").unwrap());
let tok = fx.token("svc", TokenSpec::api_key());
let val = tok.value();
assert!(val.starts_with("uk_test_"));Returns an HTTP Authorization header value for this token.
- API keys use
ApiKey <token> - Bearer and OAuth access tokens use
Bearer <token>
§Examples
let fx = Factory::deterministic(Seed::from_env_value("test-seed").unwrap());
let bearer = fx.token("svc", TokenSpec::bearer());
assert!(bearer.authorization_header().starts_with("Bearer "));
let api = fx.token("svc", TokenSpec::api_key());
assert!(api.authorization_header().starts_with("ApiKey "));Trait Implementations§
Source§impl Clone for TokenFixture
impl Clone for TokenFixture
Source§fn clone(&self) -> TokenFixture
fn clone(&self) -> TokenFixture
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TokenFixture
impl !RefUnwindSafe for TokenFixture
impl Send for TokenFixture
impl Sync for TokenFixture
impl Unpin for TokenFixture
impl UnsafeUnpin for TokenFixture
impl !UnwindSafe for TokenFixture
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