Revert "Move call to _save_session_expires to finalize_session"
[catagits/Catalyst-Plugin-Session.git] / t / cat_test.t
CommitLineData
a2e23c04 1#!/usr/bin/env perl
2
3use strict;
4use warnings;
5use Test::More;
6use HTTP::Request::Common;
7
8# setup library path
9use FindBin qw($Bin);
10use lib "$Bin/lib";
11
f851ba4e 12BEGIN {
13 plan skip_all => "Need Catalyst::Plugin::Session::State::Cookie"
14 unless do { local $@; eval { require Catalyst::Plugin::Session::State::Cookie; } };
15}
16
a2e23c04 17use Catalyst::Test 'SessionTestApp';
18my ($res, $c);
19
20($res, $c) = ctx_request(POST 'http://localhost/login', [username => 'bob', password => 's00p3r', remember => 1]);
21is($res->code, 200, 'succeeded');
22my $cookie = $res->header('Set-Cookie');
23ok($cookie, 'Have a cookie');
24
25# this checks that cookie persists across a redirect
601be17a 26($res, $c) = ctx_request(GET 'http://localhost/do_redirect', Cookie => $cookie);
27is($res->code, 302, 'redirected');
28is($res->header('Location'), 'http://localhost/page', 'Redirected after do_redirect');
29ok($res->header('Set-Cookie'), 'Cookie is still there after redirect');
a2e23c04 30
31done_testing;