1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
use crate::{
app::App,
name::Name,
test::fixtures,
token::{Secret, app},
user::User,
};
pub async fn valid_for_name(app: &App, secret: &Secret, name: &Name) {
let identity = app
.tokens()
.validate(secret, &fixtures::now())
.await
.expect("provided secret is valid");
assert_eq!(name, &identity.user.name);
}
pub async fn valid_for_user(app: &App, secret: &Secret, user: &User) {
let identity = app
.tokens()
.validate(secret, &fixtures::now())
.await
.expect("provided secret is valid");
assert_eq!(user, &identity.user);
}
pub async fn invalid(app: &App, secret: &Secret) {
let error = app
.tokens()
.validate(secret, &fixtures::now())
.await
.expect_err("provided secret is invalid");
assert!(matches!(error, app::ValidateError::InvalidToken));
}
|