X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flive_app.t;h=af9042cf078f79154137218f115961fff2ed7dfe;hb=8f57bf96b78b15ca9407e6ab5d2426745ac8a1f0;hp=ebb0c29ae15ff78f0847d47a8800688d8806ae7b;hpb=fd5b31a09aec3cbf4f4286833b3139b703656b39;p=catagits%2FCatalyst-Plugin-Authentication.git diff --git a/t/live_app.t b/t/live_app.t index ebb0c29..af9042c 100644 --- a/t/live_app.t +++ b/t/live_app.t @@ -1,91 +1,14 @@ -#!/usr/bin/perl - use strict; use warnings; -use Test::More 'no_plan'; - -{ - package AuthTestApp; - use Catalyst qw/ - Authentication - Authentication::Store::Minimal - Authentication::Credential::Password - /; - - use Test::More; - use Test::Exception; - - use Digest::MD5 qw/md5/; - use Digest::SHA1 qw/sha1_base64/; - - our $users; - - sub moose : Local { - my ( $self, $c ) = @_; - - ok(!$c->user, "no user"); - ok($c->login( "foo", "s3cr3t" ), "can login with clear"); - is( $c->user, $users->{foo}, "user object is in proper place"); - - ok( !$c->user->roles, "no roles for foo" ); - my @new = qw/foo bar gorch/; - $c->user->roles( @new ); - is_deeply( [ $c->user->roles ], \@new, "roles set as array"); - - $c->logout; - ok(!$c->user, "no more user, after logout"); - - - ok($c->login( "bar", "s3cr3t" ), "can login with crypted"); - is( $c->user, $users->{bar}, "user object is in proper place"); - $c->logout; - - ok($c->login("gorch", "s3cr3t"), "can login with hashed"); - is( $c->user, $users->{gorch}, "user object is in proper place"); - $c->logout; - - ok($c->login("shabaz", "s3cr3t"), "can login with base64 hashed"); - is( $c->user, $users->{shabaz}, "user object is in proper place"); - $c->logout; - - ok($c->login("sadeek", "s3cr3t"), "can login with padded base64 hashed"); - is( $c->user, $users->{sadeek}, "user object is in proper place"); - $c->logout; - - ok(!$c->login( "bar", "bad pass" ), "can't login with bad password"); - ok(!$c->user, "no user"); - - throws_ok { $c->login( "baz", "foo" ) } qr/support.*mechanism/, "can't login without any supported mech"; - - $c->res->body( "ok" ); - } - - __PACKAGE__->config->{authentication}{users} = $users = { - foo => { - password => "s3cr3t", - }, - bar => { - crypted_password => crypt("s3cr3t", "x8"), - }, - gorch => { - hashed_password => md5("s3cr3t"), - hash_algorithm => "MD5", - }, - shabaz => { - hashed_password => sha1_base64("s3cr3t"), - hash_algorithm => "SHA-1" - }, - sadeek => { - hashed_password => sha1_base64("s3cr3t").'=', - hash_algorithm => "SHA-1" - }, - baz => {}, - }; +use Test::More; - __PACKAGE__->setup; +BEGIN { + plan skip_all => "Digest::SHA1 is required for this test" unless eval { require Digest::SHA1 }; + plan "no_plan"; } +use lib 't/lib'; use Catalyst::Test qw/AuthTestApp/; -ok( get("/moose"), "get ok"); +ok(get("/moose"), "get ok");