summaryrefslogtreecommitdiff
path: root/src/test/fixtures/cookie.rs
blob: 7dc5083c16552df00a1f6b7a6e7328b146b75662 (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
use uuid::Uuid;

use crate::{
    app::App, clock::RequestedAt, name::Name, password::Password, token::extract::IdentityCookie,
};

pub fn not_logged_in() -> IdentityCookie {
    IdentityCookie::new()
}

pub async fn logged_in(
    app: &App,
    credentials: &(Name, Password),
    now: &RequestedAt,
) -> IdentityCookie {
    let (name, password) = credentials;
    let secret = app
        .logins()
        .with_password(name, password, now)
        .await
        .expect("should succeed given known-valid credentials");

    IdentityCookie::new().set(secret)
}

pub fn fictitious() -> IdentityCookie {
    let token = Uuid::new_v4().to_string();
    IdentityCookie::new().set(token)
}