We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
MockTokenUser::for_token()
1 parent 203808c commit fc5582eCopy full SHA for fc5582e
src/tests/util.rs
@@ -39,6 +39,7 @@ use http::header;
39
use secrecy::ExposeSecret;
40
use serde_json::json;
41
use std::collections::HashMap;
42
+use std::fmt::Display;
43
use std::net::SocketAddr;
44
use tower::ServiceExt;
45
@@ -370,6 +371,14 @@ impl RequestHelper for MockTokenUser {
370
371
}
372
373
impl MockTokenUser {
374
+ pub fn for_token(token: impl Display, app: TestApp) -> Self {
375
+ Self {
376
+ app,
377
+ token: None,
378
+ plaintext: format!("Bearer {token}"),
379
+ }
380
381
+
382
/// Returns a reference to the database `ApiToken` model
383
pub fn as_model(&self) -> &ApiToken {
384
const ERROR: &str = "Original `ApiToken` was not set on this `MockTokenUser` instance";
0 commit comments