X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flive_app_session.t;h=2ec39a4ecb83c5c54d993ada0dbae6012ebe17f0;hb=9630670114ba04685f564a314ffcaf511581a2be;hp=cb97025051e55f7ddb9b2b17227beac3c20d5163;hpb=ff817455b9bb4d7fec5b2b86c4e243f29f68ee53;p=catagits%2FCatalyst-Plugin-Authentication.git diff --git a/t/live_app_session.t b/t/live_app_session.t index cb97025..2ec39a4 100644 --- a/t/live_app_session.t +++ b/t/live_app_session.t @@ -6,15 +6,18 @@ use warnings; use Test::More; BEGIN { - eval { require Catalyst::Plugin::Session; require Catalyst::Plugin::Session::State::Cookie }; - if ($@) { - plan skip_all => "This test needs Catalyst::Plugin::Session and Catalyst::Plugin::Session::State::Cookie installed"; - } else { - plan tests => 12; - } + 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; } { + 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 @@ -37,6 +40,7 @@ BEGIN { 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"); @@ -46,6 +50,7 @@ BEGIN { 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)" ); @@ -60,12 +65,15 @@ BEGIN { } __PACKAGE__->config->{authentication}{users} = $users = { - foo => { + foo => User::SessionRestoring->new( + id => 'foo', password => "s3cr3t", - }, + ), }; __PACKAGE__->setup; + + $users->{foo}{store} = __PACKAGE__->default_auth_store; } use Test::WWW::Mechanize::Catalyst qw/AuthTestApp/; # for the cookie support