summaryrefslogtreecommitdiff
path: root/t/tests/model/users.t
blob: 1518831b271903950295b809b1e51553ad1583a2 (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
46
use v6.d.PREVIEW;
use Test;
use Ultramarine::Model::Users;
 
my $u = Ultramarine::Model::Users.new(accounts => { me => 'sesame' });
 
nok(
    $u.authenticate(:user<me>,:password<bad>),
    'bad password should fail',
);
    
nok(
    $u.authenticate(:user<not-there>,:password<bad>),
    'bad username should fail',
);
 
ok(
    $u.authenticate(:user<me>,:password<sesame>),
    'plaintext should work',
);
 
ok(
    $u.authenticate(:user<me>,:password<enc:736573616d65>),
    'hex-encoded should work',
);
 
nok(
    $u.authenticate(:user<me>,:password<enc:736573616d64>),
    'bad hex-encoded should fail',
);
 
ok(
    $u.authenticate(:user<me>,:token<26719a1196d2a940705a59634eb18eab>,
                    :salt<c19b2d>),
    'salted hash should work',
);
 
nok(
    $u.authenticate(:user<me>,:token<26719a1196d2a940705a59634eb18eab>,
                    :salt<c19b2c>),
    'bad salted hash should work',
);
 
done-testing;