Commit | Line | Data |
e517ed3d |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
16585083 |
6 | use Test::More tests => 12; |
e517ed3d |
7 | |
e517ed3d |
8 | use File::Temp qw/tempfile/; |
9 | |
16585083 |
10 | my $m; BEGIN { use_ok($m = "Catalyst::Authentication::Store::Htpasswd") } |
e517ed3d |
11 | |
12 | (undef, my $tmp) = tempfile(); |
13 | |
3e0bbcff |
14 | my $passwd = Authen::Htpasswd->new($tmp, { encrypt_hash => 'md5' }); |
e517ed3d |
15 | |
3e0bbcff |
16 | $passwd->add_user("user", "s3cr3t"); |
e517ed3d |
17 | |
e517ed3d |
18 | can_ok($m, "new"); |
16585083 |
19 | isa_ok(my $o = $m->new( { file => $passwd } ), $m); |
e517ed3d |
20 | |
21 | can_ok($m, "file"); |
3e0bbcff |
22 | isa_ok( $o->file, "Authen::Htpasswd"); |
e517ed3d |
23 | |
e517ed3d |
24 | can_ok( $m, "user_supports"); |
25 | ok( $m->user_supports(qw/password self_check/), "user_supports self check" ); |
26 | |
16585083 |
27 | can_ok($m, "find_user"); |
28 | isa_ok( my $u = $o->find_user({username => "user"}), "Catalyst::Authentication::Store::Htpasswd::User"); |
29 | isa_ok( $u, "Catalyst::Authentication::User"); |
e517ed3d |
30 | |
31 | can_ok( $u, "check_password"); |
32 | ok( $u->check_password( "s3cr3t" ), "password is s3cr3t"); |
33 | |
34 | |
35 | |