Commit | Line | Data |
7ea446f1 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More; |
7 | |
8 | use Plack::Request; |
9 | use Plack::Session::State::Cookie; |
10 | use Plack::Session::Store; |
11 | use Plack::Util; |
12 | |
13 | use t::lib::TestSessionHash; |
14 | |
15 | t::lib::TestSessionHash::run_all_tests( |
16 | store => Plack::Session::Store->new, |
17 | state => Plack::Session::State::Cookie->new, |
18 | env_cb => sub { |
19 | my $cookies = shift; |
20 | open my $in, '<', \do { my $d }; |
21 | my $env = { |
22 | 'psgi.version' => [ 1, 0 ], |
23 | 'psgi.input' => $in, |
24 | 'psgi.errors' => *STDERR, |
25 | 'psgi.url_scheme' => 'http', |
26 | SERVER_PORT => 80, |
27 | REQUEST_METHOD => 'GET', |
28 | HTTP_COOKIE => join "; " => map { $_ . "=" . $cookies->{ $_ } } keys %$cookies, |
29 | }; |
30 | }, |
31 | response_test => sub { |
32 | my ($res_cb, $session_id, $check_expired) = @_; |
33 | my $cookie; |
34 | $res_cb->(sub { |
35 | my $res = shift; |
36 | $cookie = Plack::Util::header_get($res->[1], 'Set-Cookie'); |
37 | }); |
38 | |
39 | like($cookie, qr/plack_session=$session_id/, '... cookie value is as suspected'); |
40 | if ($check_expired) { |
41 | like($cookie, qr/expires=/, '... cookie is expriring as suspected'); |
42 | } |
43 | } |
44 | ); |
45 | |
46 | done_testing; |