summaryrefslogtreecommitdiff
path: root/src/test/fixtures/user.rs
blob: d4d8db43ad85c707167413c903e0f016d88fa9f9 (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
use faker_rand::{en_us::internet, lorem::Paragraphs};
use uuid::Uuid;

use crate::{app::App, clock::RequestedAt, login::Login, name::Name, password::Password};

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

    (user.name, password)
}

pub async fn create(app: &App, created_at: &RequestedAt) -> Login {
    super::login::create(app, created_at).await
}

pub fn propose() -> (Name, Password) {
    (propose_name(), propose_password())
}

pub fn propose_invalid_name() -> Name {
    rand::random::<Paragraphs>().to_string().into()
}

pub(crate) fn propose_name() -> Name {
    rand::random::<internet::Username>().to_string().into()
}

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