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