6 use Test::More tests => 19;
8 use File::Temp qw/tempfile/;
10 my $m; BEGIN { use_ok($m = "Catalyst::Authentication::Store::Htpasswd") }
12 (undef, my $tmp) = tempfile();
14 my $passwd = Authen::Htpasswd->new($tmp);
16 $passwd->add_user("user", "s3cr3t");
19 isa_ok(my $o = $m->new( { file => $passwd } ), $m);
22 isa_ok( $o->file, "Authen::Htpasswd");
24 can_ok( $m, "user_supports");
25 ok( $m->user_supports(qw/password self_check/), "user_supports self check" );
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");
31 can_ok( $u, "supports");
32 ok( $u->supports(qw/password self_check/), "htpasswd users check their own passwords");
34 can_ok( $u, "check_password");
35 ok( $u->check_password( "s3cr3t" ), "password is s3cr3t");
37 ok( $m->user_supports(qw/session/), "user_supports session");
39 is( $u->store, $o, "can get store");
41 can_ok( $m, "from_session" );
42 can_ok( $u, "for_session" );
44 my $recovered = $u->store->from_session( undef, $u->for_session );
46 is( $recovered->username, $u->username, "recovery from session works");