6 use Test::More 'no_plan';
12 Authentication::Store::Minimal
13 Authentication::Credential::Password
19 use Digest::MD5 qw/md5/;
20 use Digest::SHA1 qw/sha1_base64/;
25 my ( $self, $c ) = @_;
27 ok(!$c->user, "no user");
28 ok($c->login( "foo", "s3cr3t" ), "can login with clear");
29 is( $c->user, $users->{foo}, "user object is in proper place");
31 ok( !$c->user->roles, "no roles for foo" );
32 my @new = qw/foo bar gorch/;
33 $c->user->roles( @new );
34 is_deeply( [ $c->user->roles ], \@new, "roles set as array");
37 ok(!$c->user, "no more user, after logout");
40 ok($c->login( "bar", "s3cr3t" ), "can login with crypted");
41 is( $c->user, $users->{bar}, "user object is in proper place");
44 ok($c->login("gorch", "s3cr3t"), "can login with hashed");
45 is( $c->user, $users->{gorch}, "user object is in proper place");
48 ok($c->login("shabaz", "s3cr3t"), "can login with base64 hashed");
49 is( $c->user, $users->{shabaz}, "user object is in proper place");
52 ok($c->login("sadeek", "s3cr3t"), "can login with padded base64 hashed");
53 is( $c->user, $users->{sadeek}, "user object is in proper place");
56 ok(!$c->login( "bar", "bad pass" ), "can't login with bad password");
57 ok(!$c->user, "no user");
59 throws_ok { $c->login( "baz", "foo" ) } qr/support.*mechanism/, "can't login without any supported mech";
61 $c->res->body( "ok" );
64 __PACKAGE__->config->{authentication}{users} = $users = {
69 crypted_password => crypt("s3cr3t", "x8"),
72 hashed_password => md5("s3cr3t"),
73 hash_algorithm => "MD5",
76 hashed_password => sha1_base64("s3cr3t"),
77 hash_algorithm => "SHA-1"
80 hashed_password => sha1_base64("s3cr3t").'=',
81 hash_algorithm => "SHA-1"
89 use Catalyst::Test qw/AuthTestApp/;
91 ok( get("/moose"), "get ok");