summaryrefslogtreecommitdiff
path: root/src/test/verify/login.rs
blob: 3f291a3fec24b68b23cd63f8a3e8258e1bddda3d (plain)
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
use crate::{
    app::App,
    name::Name,
    password::Password,
    test::{fixtures, verify},
    token::app::LoginError,
};

pub async fn valid_login(app: &App, name: &Name, password: &Password) {
    let secret = app
        .tokens()
        .login(&name, &password, &fixtures::now())
        .await
        .expect("login credentials expected to be valid");
    verify::token::valid_for_name(&app, &secret, &name).await;
}

pub async fn invalid_login(app: &App, name: &Name, password: &Password) {
    let error = app
        .tokens()
        .login(name, password, &fixtures::now())
        .await
        .expect_err("login credentials expected not to be valid");
    assert!(matches!(error, LoginError::Rejected));
}