summaryrefslogtreecommitdiff
path: root/src/test/fixtures/login.rs
blob: e5ac71668c91527a6523acb9306ab758a43caeec (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use faker_rand::en_us::internet;
use uuid::Uuid;

use crate::{
    app::App,
    clock::RequestedAt,
    login::{self, Login, Password},
};

pub async fn create_with_password(app: &App, created_at: &RequestedAt) -> (String, Password) {
    let (name, password) = propose();
    app.logins()
        .create(&name, &password, created_at)
        .await
        .expect("should always succeed if the login is actually new");

    (name, password)
}

pub async fn create(app: &App, created_at: &RequestedAt) -> Login {
    let (name, password) = propose();
    app.logins()
        .create(&name, &password, created_at)
        .await
        .expect("should always succeed if the login is actually new")
}

pub fn fictitious() -> Login {
    Login {
        id: login::Id::generate(),
        name: name(),
    }
}

pub fn propose() -> (String, Password) {
    (name(), propose_password())
}

fn name() -> String {
    rand::random::<internet::Username>().to_string()
}

pub fn propose_password() -> Password {
    Uuid::new_v4().to_string().into()
}