X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flive_app_session.t;h=3f718cfe1b8a514dc3155c045085482bc3b58876;hb=622e71d9ad63648e294499347525496d218a8564;hp=19f42c989094eee58d979ca21b6b75b61a4f45cd;hpb=c4d560a576705f9415169c5cf3585451582a4a92;p=catagits%2FCatalyst-Plugin-Authentication.git diff --git a/t/live_app_session.t b/t/live_app_session.t index 19f42c9..3f718cf 100644 --- a/t/live_app_session.t +++ b/t/live_app_session.t @@ -1,83 +1,31 @@ -#!/usr/bin/perl - use strict; use warnings; use Test::More; BEGIN { - eval { require Catalyst::Plugin::Session; require Catalyst::Plugin::Session::State::Cookie }; - plan skip_all => "This test needs Catalyst::Plugin::Session and Catalyst::Plugin::Session::State::Cookie installed" if $@; - plan tests => 12; -} - -{ - package User::SessionRestoring; - use base qw/Catalyst::Plugin::Authentication::User::Hash/; - - sub for_session { $_[0]->id } - - 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, "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, "a user was also restored"); - is_deeply( $c->user, $users->{foo}, "restored user is the right one (deep test - store might change identity)" ); - - $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"); - } - - __PACKAGE__->config->{authentication}{users} = $users = { - foo => User::SessionRestoring->new( - id => 'foo', - password => "s3cr3t", - ), - }; - - __PACKAGE__->setup; - - $users->{foo}{store} = __PACKAGE__->default_auth_store; + 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 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; + # There is something fishy going on here. When you run this from make test, + # there are 29 tests, when you run it from prove, there are 26 - WTF FIXME (t0m) + plan tests => 29; } -use Test::WWW::Mechanize::Catalyst qw/AuthTestApp/; # for the cookie support +use lib 't/lib'; +use Test::WWW::Mechanize::Catalyst qw/AuthSessionTestApp/; # 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("http://localhost/yak"); +ok(!$m->success, 'Not ok, user unable to be resotred == nasal demons'); + +$m->get_ok("http://localhost/goat", "get ok"); $m->get_ok("http://localhost/fluffy_bunny", "get ok"); +$m->get_ok("http://localhost/possum", "get ok"); +$m->get_ok("http://localhost/butterfly", "get ok");