X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F014_cookiestore_again.t;fp=t%2F014_cookiestore_again.t;h=65d2ac2fc3a6e7d173d6b7cef0b4ee6bd83ecf99;hb=7ea446f1ba6e6ce640485a34ed5d2466709dc264;hp=0000000000000000000000000000000000000000;hpb=92edbddf6ada06255baa085d25d75c9ef75dfc59;p=catagits%2FWeb-Session.git diff --git a/t/014_cookiestore_again.t b/t/014_cookiestore_again.t new file mode 100644 index 0000000..65d2ac2 --- /dev/null +++ b/t/014_cookiestore_again.t @@ -0,0 +1,45 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More; + +use Plack::Request; +use Plack::Middleware::Session::Cookie; + +use t::lib::TestSessionHash; + +t::lib::TestSessionHash::run_all_tests( + middleware_create_cb => sub { + Plack::Middleware::Session::Cookie->wrap( $_[0], secret => "foobar" ); + }, + 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;