use FindBin qw($Bin);
use lib "$Bin/lib";
+# this test was copied from CatalystX::SimpleLogin
+
BEGIN {
plan skip_all => "Need Catalyst::Plugin::Session::State::Cookie"
unless do { local $@; eval { require Catalyst::Plugin::Session::State::Cookie; } };
+ plan skip_all => "Need Catalyst::Plugin::Authentication"
+ unless do { local $@; eval { require Catalyst::Plugin::Authentication; } };
}
use Catalyst::Test 'SessionTestApp';
my $cookie = $res->header('Set-Cookie');
ok($cookie, 'Have a cookie');
-# this checks that cookie persists across a redirect
-($res, $c) = ctx_request(GET 'http://localhost/do_redirect', Cookie => $cookie);
+# check that the cookie has not been reset by the get
+($res, $c) = ctx_request(GET 'http://localhost/page', Cookie => $cookie);
+like($c->res->body, qr/logged in/, 'Am logged in');
+my $new_cookie = $res->header('Set-Cookie');
+is( $cookie, $new_cookie, 'cookie is the same' );
+
+# this checks that cookie exists after a logout and redirect
+# Catalyst::Plugin::Authentication removes the user session (remove_persisted_user)
+($res, $c) = ctx_request(GET 'http://localhost/logout_redirect', Cookie => $cookie);
is($res->code, 302, 'redirected');
-is($res->header('Location'), 'http://localhost/page', 'Redirected after do_redirect');
-ok($res->header('Set-Cookie'), 'Cookie is still there after redirect');
+is($res->header('Location'), 'http://localhost/from_logout_redirect', 'Redirected after logout_redirect');
+ok($res->header('Set-Cookie'), 'Cookie is there after redirect');
done_testing;
#!/usr/bin/env perl
package SessionTestApp;
-use Catalyst qw/Session Session::Store::Dummy Session::State::Cookie/;
+use Catalyst qw/Session Session::Store::Dummy Session::State::Cookie Authentication/;
use strict;
use warnings;
__PACKAGE__->config('Plugin::Session' => {
- # needed for live_verify_user_agent.t; should be harmless for other tests
- verify_user_agent => 1,
-
- # need for live_verify_address.t; should be harmless for other tests
- verify_address => 1,
+ # needed for live_verify_user_agent.t; should be harmless for other tests
+ verify_user_agent => 1,
+ verify_address => 1,
-});
+ },
+
+ 'Plugin::Authentication' => {
+ default => {
+ credential => {
+ class => 'Password',
+ password_field => 'password',
+ password_type => 'clear'
+ },
+ store => {
+ class => 'Minimal',
+ users => {
+ bob => {
+ password => "s00p3r",
+ },
+ william => {
+ password => "s3cr3t",
+ },
+ },
+ },
+ },
+ },
+);
__PACKAGE__->setup;
$c->delete_session("logout");
}
-sub do_redirect : Global {
+sub logout_redirect : Global {
my ( $self, $c ) = @_;
- # session is not deleted
- $c->res->redirect( $c->uri_for('page') );
+
+ $c->logout;
+ $c->res->output("redirect from here");
+ $c->res->redirect( $c->uri_for('from_logout_redirect') );
+}
+
+sub from_logout_redirect : Global {
+ my ( $self, $c ) = @_;
+ $c->res->output( "got here from logout_redirect" );
}
sub set_session_variable : Global {