Initial commit
[apache2-authen-passphrase.git] / t / Apache2-Authen-Passphrase.t
CommitLineData
f4cc782b
MG
1use v5.14;
2use strict;
3use warnings;
4
5use File::Temp qw/tempdir/;
6use Test::More tests => 7;
7BEGIN { use_ok('Apache2::Authen::Passphrase', qw/pwset pwcheck/) };
8
9my $tempdir = tempdir CLEANUP => 1;
10mkdir "$tempdir/us";
11$Apache2::Authen::Passphrase::rootdir = $tempdir;
12
13sub pw_ok {
14 my ($user, $pass, $testname) = @_;
15 eval { pwcheck $user, $pass };
16 is $@, '', $testname;
17}
18
19sub pw_nok {
20 my ($user, $pass, $testname) = @_;
21 eval { pwcheck $user, $pass };
22 isnt $@, '', $testname;
23}
24
25pwset marius => 'password';
26pw_ok marius => 'password', 'Set password and check it';
27pw_nok marius => 'anotherpassword', 'Check an incorrect password';
28
29pwset marius => 'anotherpassword';
30pw_ok marius => 'anotherpassword', 'Change the password and check it';
31
32pw_nok 'BadUsername++', 'a', 'Bad username';
33pw_nok 'a', 'a', 'Short username';
34pw_nok 'asfwe0g3girg4ih45jho45ih45hi45h045jh4oh', 'a', 'Long username';
This page took 0.011067 seconds and 4 git commands to generate.