X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flive_app_session.t;h=ac99352059709b6a1ccc2801e76696ee519f113c;hb=d055ce0c91dca58df9b579d450af3ae250fb119c;hp=2ec39a4ecb83c5c54d993ada0dbae6012ebe17f0;hpb=63ffb30f4d5a245ffd3126704bb2b63d1db699f5;p=catagits%2FCatalyst-Plugin-Authentication.git diff --git a/t/live_app_session.t b/t/live_app_session.t index 2ec39a4..ac99352 100644 --- a/t/live_app_session.t +++ b/t/live_app_session.t @@ -1,5 +1,3 @@ -#!/usr/bin/perl - use strict; use warnings; @@ -8,79 +6,24 @@ use Test::More; BEGIN { eval { require Test::WWW::Mechanize::Catalyst; require Catalyst::Plugin::Session; require Catalyst::Plugin::Session::State::Cookie }; plan skip_all => "This test needs Test::WWW::Mechanize::Catalyst, Catalyst::Plugin::Session and Catalyst::Plugin::Session::State::Cookie installed" if $@; - plan tests => 14; + plan skip_all => "This test needs Test::WWW::Mechanize::Catalyst >= 0.50, you have only $Test::WWW::Mechanize::Catalyst::VERSION" + unless $Test::WWW::Mechanize::Catalyst::VERSION >= 0.50; } -{ - package User::SessionRestoring; - use base qw/Catalyst::Plugin::Authentication::User::Hash/; - - sub for_session { $_[0]->id } - sub store { $_[0]->{store} } - - package AuthTestApp; - use Catalyst qw/ - Session - Session::Store::Dummy - Session::State::Cookie - - 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->sessionid, "no session id yet"); - ok(!$c->user_exists, "no user exists"); - ok(!$c->user, "no user yet"); - ok($c->login( "foo", "s3cr3t" ), "can login with clear"); - is( $c->user, $users->{foo}, "user object is in proper place"); - } - - sub elk : Local { - my ( $self, $c ) = @_; - - ok( $c->sessionid, "session ID was restored" ); - ok( $c->user_exists, "user exists" ); - ok( $c->user, "a user was also restored"); - is_deeply( $c->user, $users->{foo}, "restored user is the right one (deep test - store might change identity)" ); +use lib 't/lib'; +use Test::WWW::Mechanize::Catalyst qw/AuthSessionTestApp/; # for the cookie support - $c->delete_session("bah"); - } - - sub fluffy_bunny : Local { - my ( $self, $c ) = @_; - - ok( !$c->sessionid, "no session ID was restored"); - ok( !$c->user, "no user was restored"); - } +my $m = Test::WWW::Mechanize::Catalyst->new; - __PACKAGE__->config->{authentication}{users} = $users = { - foo => User::SessionRestoring->new( - id => 'foo', - password => "s3cr3t", - ), - }; +$m->get_ok("http://localhost/moose", "get ok"); +$m->get_ok("http://localhost/elk", "get ok"); - __PACKAGE__->setup; +$m->get("http://localhost/yak"); +ok(!$m->success, 'Not ok, user unable to be resotred == nasal demons'); - $users->{foo}{store} = __PACKAGE__->default_auth_store; +foreach my $type (qw/ goat fluffy_bunny possum butterfly /) { + $m->get_ok("http://localhost/$type", "get $type ok"); } -use Test::WWW::Mechanize::Catalyst qw/AuthTestApp/; # for the cookie support - -my $m = Test::WWW::Mechanize::Catalyst->new; - -$m->get_ok("http://localhost/moose", "get ok"); -$m->get_ok("http://localhost/elk", "get ok"); -$m->get_ok("http://localhost/fluffy_bunny", "get ok"); +done_testing;