19cec4212b09de7fc7a0aeac444252a838a02aad
[catagits/Catalyst-Plugin-Session.git] / t / cat_test.t
1 #!/usr/bin/env perl
2
3 use strict;
4 use warnings;
5 use Test::More;
6 use HTTP::Request::Common;
7
8 # setup library path
9 use FindBin qw($Bin);
10 use lib "$Bin/lib";
11
12 use Catalyst::Test 'SessionTestApp';
13 my ($res, $c);
14
15 ($res, $c) = ctx_request(POST 'http://localhost/login', [username => 'bob', password => 's00p3r', remember => 1]);
16 is($res->code, 200, 'succeeded');
17 my $cookie = $res->header('Set-Cookie');
18 ok($cookie, 'Have a cookie');
19
20 # this checks that cookie persists across a redirect
21 ($res, $c) = ctx_request(GET 'http://localhost/logout_persist', Cookie => $cookie);
22 is($res->code, 302, '/logout with cookie redirects');
23 is($res->header('Location'), 'http://localhost/', 'Redirect to / after logout');
24 ok($res->header('Set-Cookie'), 'Cookie is reset by /logout');
25
26 done_testing;