Skip to content

Commit 917a203

Browse files
committed
tests/util: Add MockTokenUser::with_auth_header() fn
This makes it possible to construct `MockTokenUser` instances from an existing plaintext token or other random header value.
1 parent 1d31bc8 commit 917a203

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/tests/util.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,14 @@ impl RequestHelper for MockTokenUser {
370370
}
371371

372372
impl MockTokenUser {
373+
pub fn with_auth_header(token: String, app: TestApp) -> Self {
374+
Self {
375+
app,
376+
token: None,
377+
plaintext: token,
378+
}
379+
}
380+
373381
/// Returns a reference to the database `ApiToken` model
374382
pub fn as_model(&self) -> &ApiToken {
375383
const ERROR: &str = "Original `ApiToken` was not set on this `MockTokenUser` instance";

0 commit comments

Comments
 (0)