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