We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
MockTokenUser::for_token()
1 parent 3dc45ec commit 4f03641Copy full SHA for 4f03641
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
@@ -361,6 +362,14 @@ impl RequestHelper for MockTokenUser {
361
362
}
363
364
impl MockTokenUser {
365
+ pub fn for_token(token: impl Display, app: TestApp) -> Self {
366
+ Self {
367
+ app,
368
+ token: None,
369
+ plaintext: format!("Bearer {token}"),
370
+ }
371
372
+
373
/// Returns a reference to the database `ApiToken` model
374
pub fn as_model(&self) -> &ApiToken {
375
const ERROR: &str = "Original `ApiToken` was not set on this `MockTokenUser` instance";
0 commit comments