Commit | Line | Data |
e517ed3d |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More; |
7 | |
8 | BEGIN { |
9 | eval { require Crypt::PasswdMD5 }; |
10 | plan skip_all => "This test requires Crypt::PasswdMD5 to be installed" if $@; |
11 | plan tests => 12; |
12 | } |
13 | |
e517ed3d |
14 | use File::Temp qw/tempfile/; |
15 | |
16 | my $m; BEGIN { use_ok($m = "Catalyst::Plugin::Authentication::Store::Htpasswd::Backend") } |
17 | |
18 | (undef, my $tmp) = tempfile(); |
19 | |
3e0bbcff |
20 | my $passwd = Authen::Htpasswd->new($tmp, { encrypt_hash => 'md5' }); |
e517ed3d |
21 | |
3e0bbcff |
22 | $passwd->add_user("user", "s3cr3t"); |
e517ed3d |
23 | |
e517ed3d |
24 | can_ok($m, "new"); |
25 | isa_ok(my $o = $m->new( $passwd ), $m); |
26 | |
27 | can_ok($m, "file"); |
3e0bbcff |
28 | isa_ok( $o->file, "Authen::Htpasswd"); |
e517ed3d |
29 | |
e517ed3d |
30 | can_ok( $m, "user_supports"); |
31 | ok( $m->user_supports(qw/password self_check/), "user_supports self check" ); |
32 | |
33 | can_ok($m, "get_user"); |
34 | isa_ok( my $u = $o->get_user("user"), "Catalyst::Plugin::Authentication::Store::Htpasswd::User"); |
35 | isa_ok( $u, "Catalyst::Plugin::Authentication::User"); |
36 | |
37 | can_ok( $u, "check_password"); |
38 | ok( $u->check_password( "s3cr3t" ), "password is s3cr3t"); |
39 | |
40 | |
41 | |