Auth::Store::Htpasswd - check md5 too (does not reproduce ningu's bug)
[catagits/Catalyst-Authentication-Store-Htpasswd.git] / t / backend_md5.t
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
14 use Path::Class;
15
16 use File::Temp qw/tempfile/;
17
18 my $m; BEGIN { use_ok($m = "Catalyst::Plugin::Authentication::Store::Htpasswd::Backend") }
19
20 (undef, my $tmp) = tempfile();
21
22 my $passwd = Apache::Htpasswd->new({ passwdFile => "$tmp", UseMD5 => 1 });
23
24 $passwd->htpasswd("user", "s3cr3t");
25
26
27 can_ok($m, "new");
28 isa_ok(my $o = $m->new( $passwd ), $m);
29
30 can_ok($m, "file");
31 isa_ok( $o->file, "Apache::Htpasswd");
32
33
34 can_ok( $m, "user_supports");
35 ok( $m->user_supports(qw/password self_check/), "user_supports self check" );
36
37 can_ok($m, "get_user");
38 isa_ok( my $u = $o->get_user("user"), "Catalyst::Plugin::Authentication::Store::Htpasswd::User");
39 isa_ok( $u, "Catalyst::Plugin::Authentication::User");
40
41 can_ok( $u, "check_password");
42 ok( $u->check_password( "s3cr3t" ), "password is s3cr3t");
43
44
45