X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flive_app.t;h=70ca6768bc3a2cb84d419b3a30c2e70ae73d6725;hb=cb5d628d9f1a02fda5e195f39fff589139456186;hp=260a8ea6c2e86a3dbcbb25d79f17f7aad1858891;hpb=36d8ef793d4857a1d8ce1adfe89dee16a56cd36b;p=catagits%2FCatalyst-Plugin-Authentication.git diff --git a/t/live_app.t b/t/live_app.t index 260a8ea..70ca676 100644 --- a/t/live_app.t +++ b/t/live_app.t @@ -1,74 +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/; - - 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( "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", - }, - 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");