pub struct AuthFactory;Expand description
Factory for creating authentication test data.
§Example
ⓘ
use fastapi_core::fixtures::AuthFactory;
// Bearer token
let token = AuthFactory::bearer_token();
// API key
let key = AuthFactory::api_key();
// JWT-like token
let jwt = AuthFactory::jwt_token()
.sub("user123")
.build();Factory for creating authentication test data - provides static methods.
Implementations§
Source§impl AuthFactory
impl AuthFactory
Sourcepub fn bearer_token() -> String
pub fn bearer_token() -> String
Generate a random-looking bearer token.
Sourcepub fn session_id() -> String
pub fn session_id() -> String
Generate a random-looking session ID.
Sourcepub fn refresh_token() -> String
pub fn refresh_token() -> String
Generate a refresh token.
Sourcepub fn jwt_token() -> JwtFactory
pub fn jwt_token() -> JwtFactory
Create a JWT-like token factory.
Sourcepub fn basic_credentials() -> (String, String)
pub fn basic_credentials() -> (String, String)
Generate basic auth credentials.
Sourcepub fn oauth_code() -> String
pub fn oauth_code() -> String
Generate an OAuth2 authorization code.
Auto Trait Implementations§
impl Freeze for AuthFactory
impl RefUnwindSafe for AuthFactory
impl Send for AuthFactory
impl Sync for AuthFactory
impl Unpin for AuthFactory
impl UnwindSafe for AuthFactory
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).