3 use Test::Requires qw(Digest::HMAC_SHA1);
5 use Plack::Middleware::Session::Cookie;
6 use HTTP::Request::Common;
10 $Plack::Test::Impl = 'Server';
14 my $session = $env->{'psgix.session'};
16 my $counter = $session->{counter} || 0;
17 if ($session->{counter}++ >= 2) {
18 $env->{'psgix.session.options'}->{expire} = 1;
21 return [ 200, [], [ "counter=$counter" ] ];
24 $app = Plack::Middleware::Session::Cookie->wrap($app, secret => "foobar", expires => 3600);
26 my $ua = LWP::UserAgent->new;
27 $ua->cookie_jar( HTTP::Cookies->new );
29 test_psgi ua => $ua, app => $app, client => sub {
32 my $res = $cb->(GET "/");
33 is $res->content, "counter=0";
34 like $res->header('Set-Cookie'), qr/expires=/;
36 $res = $cb->(GET "/");
37 is $res->content, "counter=1";
38 like $res->header('Set-Cookie'), qr/expires=/;
40 $res = $cb->(GET "/");
41 is $res->content, "counter=2";
43 $res = $cb->(GET "/");
44 is $res->content, "counter=0";