ported Authentication::Store::Htpasswd to Authen::Htpasswd
[catagits/Catalyst-Authentication-Store-Htpasswd.git] / t / backend.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More 'no_plan';
7 use Path::Class;
8
9 use File::Temp qw/tempfile/;
10
11 my $m; BEGIN { use_ok($m = "Catalyst::Plugin::Authentication::Store::Htpasswd::Backend") }
12
13 (undef, my $tmp) = tempfile();
14
15 my $passwd = Authen::Htpasswd->new($tmp);
16
17 $passwd->add_user("user", "s3cr3t");
18
19
20 can_ok($m, "new");
21 isa_ok(my $o = $m->new( $passwd ), $m);
22
23 can_ok($m, "file");
24 isa_ok( $o->file, "Authen::Htpasswd");
25
26
27 can_ok( $m, "user_supports");
28 ok( $m->user_supports(qw/password self_check/), "user_supports self check" );
29
30 can_ok($m, "get_user");
31 isa_ok( my $u = $o->get_user("user"), "Catalyst::Plugin::Authentication::Store::Htpasswd::User");
32 isa_ok( $u, "Catalyst::Plugin::Authentication::User");
33
34 can_ok( $u, "supports");
35 ok( $u->supports(qw/password self_check/), "htpasswd users check their own passwords");
36
37 can_ok( $u, "check_password");
38 ok( $u->check_password( "s3cr3t" ), "password is s3cr3t");
39
40