6 use Test::More 'no_plan';
9 use File::Temp qw/tempfile/;
11 my $m; BEGIN { use_ok($m = "Catalyst::Plugin::Authentication::Store::Htpasswd::Backend") }
13 (undef, my $tmp) = tempfile();
15 my $passwd = Authen::Htpasswd->new($tmp);
17 $passwd->add_user("user", "s3cr3t");
21 isa_ok(my $o = $m->new( $passwd ), $m);
24 isa_ok( $o->file, "Authen::Htpasswd");
27 can_ok( $m, "user_supports");
28 ok( $m->user_supports(qw/password self_check/), "user_supports self check" );
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");
34 can_ok( $u, "supports");
35 ok( $u->supports(qw/password self_check/), "htpasswd users check their own passwords");
37 can_ok( $u, "check_password");
38 ok( $u->check_password( "s3cr3t" ), "password is s3cr3t");
41 ok( $m->user_supports(qw/session/), "user_supports session");
43 is( $u->store, $o, "can get store");
45 can_ok( $m, "from_session" );
46 can_ok( $u, "for_session" );
48 my $recovered = $u->store->from_session( undef, $u->for_session );
50 is( $recovered->username, $u->username, "recovery from session works");