]>
Commit | Line | Data |
---|---|---|
1 | use v5.14; | |
2 | use strict; | |
3 | use warnings; | |
4 | ||
5 | use File::Temp qw/tempdir/; | |
6 | use Test::More tests => 7; | |
7 | BEGIN { use_ok('Apache2::Authen::Passphrase', qw/pwset pwcheck/) }; | |
8 | ||
9 | $Apache2::Authen::Passphrase::rootdir = tempdir CLEANUP => 1; | |
10 | ||
11 | sub pw_ok { | |
12 | my ($user, $pass, $testname) = @_; | |
13 | eval { pwcheck $user, $pass }; | |
14 | is $@, '', $testname; | |
15 | } | |
16 | ||
17 | sub pw_nok { | |
18 | my ($user, $pass, $testname) = @_; | |
19 | eval { pwcheck $user, $pass }; | |
20 | isnt $@, '', $testname; | |
21 | } | |
22 | ||
23 | pwset marius => 'password'; | |
24 | pw_ok marius => 'password', 'Set password and check it'; | |
25 | pw_nok marius => 'anotherpassword', 'Check an incorrect password'; | |
26 | ||
27 | pwset marius => 'anotherpassword'; | |
28 | pw_ok marius => 'anotherpassword', 'Change the password and check it'; | |
29 | ||
30 | pw_nok 'BadUsername++', 'a', 'Bad username'; | |
31 | pw_nok 'a', 'a', 'Short username'; | |
32 | pw_nok 'asfwe0g3girg4ih45jho45ih45hi45h045jh4oh', 'a', 'Long username'; |