File: 014_cookie_options.t

package info (click to toggle)
libplack-middleware-session-perl 0.36-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 276 kB
  • sloc: perl: 1,322; makefile: 2
file content (32 lines) | stat: -rw-r--r-- 1,244 bytes parent folder | download | duplicates (2)
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
use strict;
use Test::More;

my $time = 1264843167;
BEGIN { *CORE::GLOBAL::time = sub() { $time } }
use Plack::Session::State::Cookie;

my $st = Plack::Session::State::Cookie->new;
$st->domain('.example.com');
$st->secure(1);
$st->expires(3600);
$st->path('/cgi-bin');

is_deeply +{ $st->merge_options(id => 123) },
  { domain => '.example.com', secure => 1, expires => $time + 3600, path => '/cgi-bin' };

is_deeply +{ $st->merge_options(id => 123, path => '/', domain => '.perl.org') },
  { domain => '.perl.org', secure => 1, expires => $time + 3600, path => '/' };

is_deeply +{ $st->merge_options(id => 123, expires => $time + 1, secure => 0, partitioned => 0) },
  { domain => '.example.com', secure => 0, expires => $time + 1, path => '/cgi-bin', partitioned => 0 };

is_deeply +{ $st->merge_options(id => 123, expires => $time + 1, secure => 0, partitioned => 1) },
  { domain => '.example.com', secure => 1, samesite => 'None', expires => $time + 1, path => '/cgi-bin', partitioned => 1 };

$st->partitioned(1);

is_deeply +{ $st->merge_options(id => 123, expires => $time + 1, secure => 0) },
  { domain => '.example.com', secure => 1, samesite => 'None', expires => $time + 1, path => '/cgi-bin', partitioned => 1 };


done_testing;