Initial commit
[apache2-authen-passphrase.git] / t / Apache2-Authen-Passphrase.t
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 my $tempdir = tempdir CLEANUP => 1;
10 mkdir "$tempdir/us";
11 $Apache2::Authen::Passphrase::rootdir = $tempdir;
12
13 sub pw_ok {
14 my ($user, $pass, $testname) = @_;
15 eval { pwcheck $user, $pass };
16 is $@, '', $testname;
17 }
18
19 sub pw_nok {
20 my ($user, $pass, $testname) = @_;
21 eval { pwcheck $user, $pass };
22 isnt $@, '', $testname;
23 }
24
25 pwset marius => 'password';
26 pw_ok marius => 'password', 'Set password and check it';
27 pw_nok marius => 'anotherpassword', 'Check an incorrect password';
28
29 pwset marius => 'anotherpassword';
30 pw_ok marius => 'anotherpassword', 'Change the password and check it';
31
32 pw_nok 'BadUsername++', 'a', 'Bad username';
33 pw_nok 'a', 'a', 'Short username';
34 pw_nok 'asfwe0g3girg4ih45jho45ih45hi45h045jh4oh', 'a', 'Long username';
This page took 0.022055 seconds and 4 git commands to generate.