From 52433c758c416e1f448ffe743c6cf502b4be4c5a Mon Sep 17 00:00:00 2001 From: Tim Ruehsen Date: Fri, 9 Nov 2012 15:51:23 +0100 Subject: [PATCH 2/2] check cookie deletion and cookie domain matching --- tests/Test-cookies.px | 57 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/tests/Test-cookies.px b/tests/Test-cookies.px index a4b9125..ac7da56 100755 --- a/tests/Test-cookies.px +++ b/tests/Test-cookies.px @@ -10,6 +10,10 @@ use HTTPTest; my $page1 = "Hello, world!\n"; my $page2 = "Goodbye, Sam.\n"; +my $page3 = "Page three.\n"; +my $page4 = "Page four.\n"; +my $page5 = "Page five.\n"; +my $page6 = "Page six.\n"; # code, msg, headers, content my %urls = ( @@ -30,10 +34,49 @@ my %urls = ( "Cookie" => qr|foo=bar|, }, }, +# remove the cookie 'foo' + '/three.txt' => { + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/plain", + "Set-Cookie" => "foo=; Expires=Sun, 06 Nov 1994 08:49:37 GMT", + }, + content => $page3, + }, + '/four.txt' => { + code => "200", + msg => "Ok", + content => $page4, + request_headers => { + "!Cookie" => qr|foo=|, + }, + }, +# try to set a cookie 'foo' with mismatching domain +# see RFC 6265 5.3.6: ignore the cookie if it doesn't domain-match + '/five.txt' => { + code => "200", + msg => "Ok", + headers => { + "Content-type" => "text/plain", + "Set-Cookie" => "foo=bar; domain=.example.com", + }, + content => $page5, + }, + '/six.txt' => { + code => "200", + msg => "Ok", + content => $page6, + request_headers => { + "!Cookie" => qr|foo=bar|, + }, + }, ); my $cmdline = $WgetTest::WGETPATH . " http://localhost:{{port}}/one.txt" - . " http://localhost:{{port}}/two.txt"; + . " http://localhost:{{port}}/two.txt" . " http://localhost:{{port}}/three.txt" + . " http://localhost:{{port}}/four.txt" . " http://localhost:{{port}}/five.txt" + . " http://localhost:{{port}}/six.txt"; my $expected_error_code = 0; @@ -44,6 +87,18 @@ my %expected_downloaded_files = ( 'two.txt' => { content => $page2, }, + 'three.txt' => { + content => $page3, + }, + 'four.txt' => { + content => $page4, + }, + 'five.txt' => { + content => $page5, + }, + 'six.txt' => { + content => $page6, + }, ); ############################################################################### -- 1.7.10.4