summaryrefslogtreecommitdiff
path: root/src/test/verify/login.rs
blob: ae2e91e01f405348d2f372827478a2947fbe4ead (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,
    login::app::LoginError,
    name::Name,
    password::Password,
    test::{fixtures, verify},
};

pub async fn valid_login(app: &App, name: &Name, password: &Password) {
    let secret = app
        .logins()
        .with_password(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
        .logins()
        .with_password(name, password, &fixtures::now())
        .await
        .expect_err("login credentials expected not to be valid");
    assert!(matches!(error, LoginError::Rejected));
}