File: cookies.t

package info (click to toggle)
libapache-asp-perl 2.62-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 4,108 kB
  • ctags: 830
  • sloc: perl: 6,033; php: 417; sh: 65; lisp: 22; makefile: 10
file content (46 lines) | stat: -rw-r--r-- 1,196 bytes parent folder | download | duplicates (7)
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
use Apache::ASP::CGI::Test;

use lib qw(t . ..);
use T;
use strict;

my $t = T->new;
my $r = Apache::ASP::CGI::Test->do_self(
					UseStrict => 1, 
					CookieDomain => 'apache-asp.com', 
					SecureSession => 1,
					CookiePath => '/eg/'
					);
my $header = $r->test_header_out;
my $body = $r->test_body_out;

my @cookie_tests = (
		    'Set-Cookie: test=cookie; path=/',
		    'Set-Cookie: test2=value; expires=Wed, 06 Nov 2002 21:52:30 GMT; path=/path/; domain=test.com; secure',
		    'Set-Cookie: test3=key1=value1&key2=value2; path=/',
		    'Set-Cookie: session-id=[0-9a-f]+; path=/eg/; domain=apache-asp.com; secure',
		    );

for my $cookie_test ( @cookie_tests ) {
#    $cookie_test =~ s/(\W)/$1/isg;
    $t->eok(($header =~ /$cookie_test/s) ? 1 : 0, "Cookies header test");
}

$t->eok($body =~ /^\s*1\.\.1\nok\s*$/ ? 1 : 0, "Body test");
$t->done;

__END__
<% 
$Response->{Cookies}{test} = "cookie";
$Response->{Cookies}{test2} = { 
    Value => 'value', 
    Path => "/path/", 
    Secure => 1,
    Expires => "Wed, 06 Nov 2002 21:52:30 GMT",
    Domain => 'test.com',
    };
$Response->Cookies("test3", "key1", "value1");
$Response->Cookies("test3", "key2", "value2");
$t->ok;
%>