From 8b9b36454c7aa8ec07e96adaea81fa09dadf52f1 Mon Sep 17 00:00:00 2001 From: Florian Duraffourg Date: Tue, 17 May 2016 10:13:26 +0200 Subject: [PATCH 1/2] Add unit tests for cookies base on abarth/http-state github repo - Add unit tests - Add a mach command to update cookie's unit tests --- python/servo/testing_commands.py | 12 + tests/unit/net/cookie_http_state.rs | 1932 +++++++++++++++++++++ tests/unit/net/cookie_http_state_utils.py | 179 ++ tests/unit/net/lib.rs | 1 + 4 files changed, 2124 insertions(+) create mode 100644 tests/unit/net/cookie_http_state.rs create mode 100644 tests/unit/net/cookie_http_state_utils.py diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py index 854236102171..89e511750545 100644 --- a/python/servo/testing_commands.py +++ b/python/servo/testing_commands.py @@ -656,3 +656,15 @@ def run_create(self, **kwargs): if editor: proc.wait() + + @Command('update-net-cookies', + description='Update the net unit tests with cookie tests from http-state', + category='testing') + def update_net_cookies(self): + cache_dir = path.join(self.config["tools"]["cache-dir"], "tests") + run_file = path.abspath(path.join(PROJECT_TOPLEVEL_PATH, + "tests", "unit", "net", + "cookie_http_state_utils.py")) + run_globals = {"__file__": run_file} + execfile(run_file, run_globals) + return run_globals["update_test_file"](cache_dir) diff --git a/tests/unit/net/cookie_http_state.rs b/tests/unit/net/cookie_http_state.rs new file mode 100644 index 000000000000..a8388558336b --- /dev/null +++ b/tests/unit/net/cookie_http_state.rs @@ -0,0 +1,1932 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +use hyper::header::{Header, SetCookie}; +use net::cookie::Cookie; +use net::cookie_storage::CookieStorage; +use net_traits::CookieSource; +use url::Url; + + +fn run(set_location: &str, set_cookies: &[&str], final_location: &str) -> String { + let mut storage = CookieStorage::new(); + let url = Url::parse(set_location).unwrap(); + let source = CookieSource::HTTP; + + // Add all cookies to the store + for str_cookie in set_cookies { + let bytes = str_cookie.to_string().into_bytes(); + let header = Header::parse_header(&[bytes]); + if let Ok(SetCookie(cookies)) = header { + for bare_cookie in cookies { + if let Some(cookie) = Cookie::new_wrapped(bare_cookie, &url, source) { + storage.push(cookie, source); + } + } + } + } + + // Get cookies for the test location + let url = Url::parse(final_location).unwrap(); + storage.cookies_for_url(&url, source).unwrap_or("".to_string()) +} + +// Following are all tests extracted from https://github.com/abarth/http-state.git +// They are generated by `./mach update-net-cookies` +// Test listing + +#[test] +fn test_0001() { + let r = run("http://home.example.org:8888/cookie-parser?0001", + &["foo=bar"], + "http://home.example.org:8888/cookie-parser-result?0001"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_0002() { + let r = run("http://home.example.org:8888/cookie-parser?0002", + &["foo=bar; Expires=Fri, 07 Aug 2019 08:04:19 GMT"], + "http://home.example.org:8888/cookie-parser-result?0002"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +#[should_panic] // Look at cookie_http_state_utils.py if this test fails +fn test_0003() { + let r = run("http://home.example.org:8888/cookie-parser?0003", + &["foo=bar; Expires=Fri, 07 Aug 2007 08:04:19 GMT", + "foo2=bar2; Expires=Fri, 07 Aug 2017 08:04:19 GMT"], + "http://home.example.org:8888/cookie-parser-result?0003"); + assert_eq!(&r, "foo2=bar2"); +} + +#[test] +fn test_0004() { + let r = run("http://home.example.org:8888/cookie-parser?0004", + &["foo"], + "http://home.example.org:8888/cookie-parser-result?0004"); + assert_eq!(&r, ""); +} + +#[test] +fn test_0005() { + let r = run("http://home.example.org:8888/cookie-parser?0005", + &["foo=bar; max-age=10000;"], + "http://home.example.org:8888/cookie-parser-result?0005"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +#[should_panic] // Look at cookie_http_state_utils.py if this test fails +fn test_0006() { + let r = run("http://home.example.org:8888/cookie-parser?0006", + &["foo=bar; max-age=0;"], + "http://home.example.org:8888/cookie-parser-result?0006"); + assert_eq!(&r, ""); +} + +#[test] +fn test_0007() { + let r = run("http://home.example.org:8888/cookie-parser?0007", + &["foo=bar; version=1;"], + "http://home.example.org:8888/cookie-parser-result?0007"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_0008() { + let r = run("http://home.example.org:8888/cookie-parser?0008", + &["foo=bar; version=1000;"], + "http://home.example.org:8888/cookie-parser-result?0008"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_0009() { + let r = run("http://home.example.org:8888/cookie-parser?0009", + &["foo=bar; customvalue=1000;"], + "http://home.example.org:8888/cookie-parser-result?0009"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_0010() { + let r = run("http://home.example.org:8888/cookie-parser?0010", + &["foo=bar; secure;"], + "http://home.example.org:8888/cookie-parser-result?0010"); + assert_eq!(&r, ""); +} + +#[test] +fn test_0011() { + let r = run("http://home.example.org:8888/cookie-parser?0011", + &["foo=bar; customvalue=\"1000 or more\";"], + "http://home.example.org:8888/cookie-parser-result?0011"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_0012() { + let r = run("http://home.example.org:8888/cookie-parser?0012", + &["foo=bar; customvalue=\"no trailing semicolon\""], + "http://home.example.org:8888/cookie-parser-result?0012"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_0013() { + let r = run("http://home.example.org:8888/cookie-parser?0013", + &["foo=bar", "foo=qux"], + "http://home.example.org:8888/cookie-parser-result?0013"); + assert_eq!(&r, "foo=qux"); +} + +#[test] +fn test_0014() { + let r = run("http://home.example.org:8888/cookie-parser?0014", + &["foo1=bar", "foo2=qux"], + "http://home.example.org:8888/cookie-parser-result?0014"); + assert_eq!(&r, "foo1=bar; foo2=qux"); +} + +#[test] +fn test_0015() { + let r = run("http://home.example.org:8888/cookie-parser?0015", + &["a=b", "z=y"], + "http://home.example.org:8888/cookie-parser-result?0015"); + assert_eq!(&r, "a=b; z=y"); +} + +#[test] +fn test_0016() { + let r = run("http://home.example.org:8888/cookie-parser?0016", + &["z=y", "a=b"], + "http://home.example.org:8888/cookie-parser-result?0016"); + assert_eq!(&r, "z=y; a=b"); +} + +#[test] +fn test_0017() { + let r = run("http://home.example.org:8888/cookie-parser?0017", + &["z=y, a=b"], + "http://home.example.org:8888/cookie-parser-result?0017"); + assert_eq!(&r, "z=y, a=b"); +} + +#[test] +fn test_0018() { + let r = run("http://home.example.org:8888/cookie-parser?0018", + &["z=y; foo=bar, a=b"], + "http://home.example.org:8888/cookie-parser-result?0018"); + assert_eq!(&r, "z=y"); +} + +#[test] +fn test_0019() { + let r = run("http://home.example.org:8888/cookie-parser?0019", + &["foo=b;max-age=3600, c=d;path=/"], + "http://home.example.org:8888/cookie-parser-result?0019"); + assert_eq!(&r, "foo=b"); +} + +#[test] +fn test_0020() { + let r = run("http://home.example.org:8888/cookie-parser?0020", + &["a=b", "=", "c=d"], + "http://home.example.org:8888/cookie-parser-result?0020"); + assert_eq!(&r, "a=b; c=d"); +} + +#[test] +fn test_0021() { + let r = run("http://home.example.org:8888/cookie-parser?0021", + &["a=b", "=x", "c=d"], + "http://home.example.org:8888/cookie-parser-result?0021"); + assert_eq!(&r, "a=b; c=d"); +} + +#[test] +fn test_0022() { + let r = run("http://home.example.org:8888/cookie-parser?0022", + &["a=b", "x=", "c=d"], + "http://home.example.org:8888/cookie-parser-result?0022"); + assert_eq!(&r, "a=b; x=; c=d"); +} + +#[test] +fn test_0023() { + let r = run("http://home.example.org:8888/cookie-parser?0023", + &["foo"], + "http://home.example.org:8888/cookie-parser-result?0023"); + assert_eq!(&r, ""); +} + +#[test] +fn test_0024() { + let r = run("http://home.example.org:8888/cookie-parser?0024", + &["foo", "="], + "http://home.example.org:8888/cookie-parser-result?0024"); + assert_eq!(&r, ""); +} + +#[test] +fn test_0025() { + let r = run("http://home.example.org:8888/cookie-parser?0025", + &["foo", "; bar"], + "http://home.example.org:8888/cookie-parser-result?0025"); + assert_eq!(&r, ""); +} + +#[test] +fn test_0026() { + let r = run("http://home.example.org:8888/cookie-parser?0026", + &["foo"], + "http://home.example.org:8888/cookie-parser-result?0026"); + assert_eq!(&r, ""); +} + +#[test] +fn test_0027() { + let r = run("http://home.example.org:8888/cookie-parser?0027", + &["foo", "bar"], + "http://home.example.org:8888/cookie-parser-result?0027"); + assert_eq!(&r, ""); +} + +#[test] +fn test_0028() { + let r = run("http://home.example.org:8888/cookie-parser?0028", + &["foo"], + "http://home.example.org:8888/cookie-parser-result?0028"); + assert_eq!(&r, ""); +} + +#[test] +fn test_attribute0001() { + let r = run("http://home.example.org:8888/cookie-parser?attribute0001", + &["foo=bar; Secure"], + "http://home.example.org:8888/cookie-parser-result?attribute0001"); + assert_eq!(&r, ""); +} + +#[test] +fn test_attribute0002() { + let r = run("http://home.example.org:8888/cookie-parser?attribute0002", + &["foo=bar; seCURe"], + "http://home.example.org:8888/cookie-parser-result?attribute0002"); + assert_eq!(&r, ""); +} + +#[test] +fn test_attribute0003() { + let r = run("http://home.example.org:8888/cookie-parser?attribute0003", + &["foo=bar; \"Secure\""], + "http://home.example.org:8888/cookie-parser-result?attribute0003"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +#[should_panic] // Look at cookie_http_state_utils.py if this test fails +fn test_attribute0004() { + let r = run("http://home.example.org:8888/cookie-parser?attribute0004", + &["foo=bar; Secure="], + "http://home.example.org:8888/cookie-parser-result?attribute0004"); + assert_eq!(&r, ""); +} + +#[test] +#[should_panic] // Look at cookie_http_state_utils.py if this test fails +fn test_attribute0005() { + let r = run("http://home.example.org:8888/cookie-parser?attribute0005", + &["foo=bar; Secure=aaaa"], + "http://home.example.org:8888/cookie-parser-result?attribute0005"); + assert_eq!(&r, ""); +} + +#[test] +fn test_attribute0006() { + let r = run("http://home.example.org:8888/cookie-parser?attribute0006", + &["foo=bar; Secure qux"], + "http://home.example.org:8888/cookie-parser-result?attribute0006"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +#[should_panic] // Look at cookie_http_state_utils.py if this test fails +fn test_attribute0007() { + let r = run("http://home.example.org:8888/cookie-parser?attribute0007", + &["foo=bar; Secure =aaaaa"], + "http://home.example.org:8888/cookie-parser-result?attribute0007"); + assert_eq!(&r, ""); +} + +#[test] +#[should_panic] // Look at cookie_http_state_utils.py if this test fails +fn test_attribute0008() { + let r = run("http://home.example.org:8888/cookie-parser?attribute0008", + &["foo=bar; Secure= aaaaa"], + "http://home.example.org:8888/cookie-parser-result?attribute0008"); + assert_eq!(&r, ""); +} + +#[test] +fn test_attribute0009() { + let r = run("http://home.example.org:8888/cookie-parser?attribute0009", + &["foo=bar; Secure; qux"], + "http://home.example.org:8888/cookie-parser-result?attribute0009"); + assert_eq!(&r, ""); +} + +#[test] +fn test_attribute0010() { + let r = run("http://home.example.org:8888/cookie-parser?attribute0010", + &["foo=bar; Secure;qux"], + "http://home.example.org:8888/cookie-parser-result?attribute0010"); + assert_eq!(&r, ""); +} + +#[test] +fn test_attribute0011() { + let r = run("http://home.example.org:8888/cookie-parser?attribute0011", + &["foo=bar; Secure ; qux"], + "http://home.example.org:8888/cookie-parser-result?attribute0011"); + assert_eq!(&r, ""); +} + +#[test] +fn test_attribute0012() { + let r = run("http://home.example.org:8888/cookie-parser?attribute0012", + &["foo=bar; Secure"], + "http://home.example.org:8888/cookie-parser-result?attribute0012"); + assert_eq!(&r, ""); +} + +#[test] +fn test_attribute0013() { + let r = run("http://home.example.org:8888/cookie-parser?attribute0013", + &["foo=bar; Secure ;"], + "http://home.example.org:8888/cookie-parser-result?attribute0013"); + assert_eq!(&r, ""); +} + +#[test] +fn test_attribute0014() { + let r = run("http://home.example.org:8888/cookie-parser?attribute0014", + &["foo=bar; Path"], + "http://home.example.org:8888/cookie-parser-result?attribute0014"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_attribute0015() { + let r = run("http://home.example.org:8888/cookie-parser?attribute0015", + &["foo=bar; Path="], + "http://home.example.org:8888/cookie-parser-result?attribute0015"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_attribute0016() { + let r = run("http://home.example.org:8888/cookie-parser?attribute0016", + &["foo=bar; Path=/"], + "http://home.example.org:8888/cookie-parser-result?attribute0016"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_attribute0017() { + let r = run("http://home.example.org:8888/cookie-parser?attribute0017", + &["foo=bar; Path=/qux"], + "http://home.example.org:8888/cookie-parser-result?attribute0017"); + assert_eq!(&r, ""); +} + +#[test] +fn test_attribute0018() { + let r = run("http://home.example.org:8888/cookie-parser?attribute0018", + &["foo=bar; Path =/qux"], + "http://home.example.org:8888/cookie-parser-result?attribute0018"); + assert_eq!(&r, ""); +} + +#[test] +fn test_attribute0019() { + let r = run("http://home.example.org:8888/cookie-parser?attribute0019", + &["foo=bar; Path= /qux"], + "http://home.example.org:8888/cookie-parser-result?attribute0019"); + assert_eq!(&r, ""); +} + +#[test] +fn test_attribute0020() { + let r = run("http://home.example.org:8888/cookie-parser?attribute0020", + &["foo=bar; Path=/qux ; taz"], + "http://home.example.org:8888/cookie-parser-result?attribute0020"); + assert_eq!(&r, ""); +} + +#[test] +fn test_attribute0021() { + let r = run("http://home.example.org:8888/cookie-parser?attribute0021", + &["foo=bar; Path=/qux; Path=/"], + "http://home.example.org:8888/cookie-parser-result?attribute0021"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_attribute0022() { + let r = run("http://home.example.org:8888/cookie-parser?attribute0022", + &["foo=bar; Path=/; Path=/qux"], + "http://home.example.org:8888/cookie-parser-result?attribute0022"); + assert_eq!(&r, ""); +} + +#[test] +fn test_attribute0023() { + let r = run("http://home.example.org:8888/cookie-parser?attribute0023", + &["foo=bar; Path=/qux; Path=/cookie-parser-result"], + "http://home.example.org:8888/cookie-parser-result?attribute0023"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_attribute0024() { + let r = run("http://home.example.org:8888/cookie-parser?attribute0024", + &["foo=bar; Path=/cookie-parser-result; Path=/qux"], + "http://home.example.org:8888/cookie-parser-result?attribute0024"); + assert_eq!(&r, ""); +} + +#[test] +fn test_attribute0025() { + let r = run("http://home.example.org:8888/cookie-parser?attribute0025", + &["foo=bar; qux; Secure"], + "http://home.example.org:8888/cookie-parser-result?attribute0025"); + assert_eq!(&r, ""); +} + +#[test] +fn test_attribute0026() { + let r = run("http://home.example.org:8888/cookie-parser?attribute0026", + &["foo=bar; qux=\"aaa;bbb\"; Secure"], + "http://home.example.org:8888/cookie-parser-result?attribute0026"); + assert_eq!(&r, ""); +} + +#[test] +fn test_charset0001() { + let r = run("http://home.example.org:8888/cookie-parser?charset0001", + &["foo=\u{6625}\u{8282}\u{56de}\u{5bb6}\u{8def}\u{b7}\u{6625}\u{8fd0}\u{5b8c}\ +\u{5168}\u{624b}\u{518c}"], + "http://home.example.org:8888/cookie-parser-result?charset0001"); + assert_eq!(&r, "foo=\u{6625}\u{8282}\u{56de}\u{5bb6}\u{8def}\u{b7}\u{6625}\u{8fd0}\u{5b8c}\ +\u{5168}\u{624b}\u{518c}"); +} + +#[test] +fn test_charset0002() { + let r = run("http://home.example.org:8888/cookie-parser?charset0002", + &["\u{6625}\u{8282}\u{56de}=\u{5bb6}\u{8def}\u{b7}\u{6625}\u{8fd0}\u{5b8c}\ +\u{5168}\u{624b}\u{518c}"], + "http://home.example.org:8888/cookie-parser-result?charset0002"); + assert_eq!(&r, "\u{6625}\u{8282}\u{56de}=\u{5bb6}\u{8def}\u{b7}\u{6625}\u{8fd0}\u{5b8c}\ +\u{5168}\u{624b}\u{518c}"); +} + +#[test] +fn test_charset0003() { + let r = run("http://home.example.org:8888/cookie-parser?charset0003", + &["\u{6625}\u{8282}\u{56de}=\u{5bb6}\u{8def}\u{b7}\u{6625}\u{8fd0}; \u{5b8c}\ +\u{5168}\u{624b}\u{518c}"], + "http://home.example.org:8888/cookie-parser-result?charset0003"); + assert_eq!(&r, "\u{6625}\u{8282}\u{56de}=\u{5bb6}\u{8def}\u{b7}\u{6625}\u{8fd0}"); +} + +#[test] +fn test_charset0004() { + let r = run("http://home.example.org:8888/cookie-parser?charset0004", + &["foo=\"\u{6625}\u{8282}\u{56de}\u{5bb6}\u{8def}\u{b7}\u{6625}\u{8fd0}\u{5b8c}\ +\u{5168}\u{624b}\u{518c}\""], + "http://home.example.org:8888/cookie-parser-result?charset0004"); + assert_eq!(&r, "foo=\"\u{6625}\u{8282}\u{56de}\u{5bb6}\u{8def}\u{b7}\u{6625}\u{8fd0}\u{5b8c}\ +\u{5168}\u{624b}\u{518c}\""); +} + +#[test] +fn test_chromium0001() { + let r = run("http://home.example.org:8888/cookie-parser?chromium0001", + &["a=b"], + "http://home.example.org:8888/cookie-parser-result?chromium0001"); + assert_eq!(&r, "a=b"); +} + +#[test] +fn test_chromium0002() { + let r = run("http://home.example.org:8888/cookie-parser?chromium0002", + &["aBc=\"zzz \" ;"], + "http://home.example.org:8888/cookie-parser-result?chromium0002"); + assert_eq!(&r, "aBc=\"zzz \""); +} + +#[test] +fn test_chromium0003() { + let r = run("http://home.example.org:8888/cookie-parser?chromium0003", + &["aBc=\"zzz \" ;"], + "http://home.example.org:8888/cookie-parser-result?chromium0003"); + assert_eq!(&r, "aBc=\"zzz \""); +} + +#[test] +fn test_chromium0004() { + let r = run("http://home.example.org:8888/cookie-parser?chromium0004", + &["aBc=\"zz;pp\" ; ;"], + "http://home.example.org:8888/cookie-parser-result?chromium0004"); + assert_eq!(&r, "aBc=\"zz"); +} + +#[test] +fn test_chromium0005() { + let r = run("http://home.example.org:8888/cookie-parser?chromium0005", + &["aBc=\"zz ;"], + "http://home.example.org:8888/cookie-parser-result?chromium0005"); + assert_eq!(&r, "aBc=\"zz"); +} + +#[test] +fn test_chromium0006() { + let r = run("http://home.example.org:8888/cookie-parser?chromium0006", + &["aBc=\"zzz \" \"ppp\" ;"], + "http://home.example.org:8888/cookie-parser-result?chromium0006"); + assert_eq!(&r, "aBc=\"zzz \" \"ppp\""); +} + +#[test] +fn test_chromium0007() { + let r = run("http://home.example.org:8888/cookie-parser?chromium0007", + &["aBc=\"zzz \" \"ppp\" ;"], + "http://home.example.org:8888/cookie-parser-result?chromium0007"); + assert_eq!(&r, "aBc=\"zzz \" \"ppp\""); +} + +#[test] +fn test_chromium0008() { + let r = run("http://home.example.org:8888/cookie-parser?chromium0008", + &["aBc=A\"B ;"], + "http://home.example.org:8888/cookie-parser-result?chromium0008"); + assert_eq!(&r, "aBc=A\"B"); +} + +#[test] +fn test_chromium0009() { + let r = run("http://home.example.org:8888/cookie-parser?chromium0009", + &["BLAHHH; path=/;"], + "http://home.example.org:8888/cookie-parser-result?chromium0009"); + assert_eq!(&r, ""); +} + +#[test] +fn test_chromium0010() { + let r = run("http://home.example.org:8888/cookie-parser?chromium0010", + &["\"BLA\\\"HHH\"; path=/;"], + "http://home.example.org:8888/cookie-parser-result?chromium0010"); + assert_eq!(&r, ""); +} + +#[test] +fn test_chromium0011() { + let r = run("http://home.example.org:8888/cookie-parser?chromium0011", + &["a=\"B"], + "http://home.example.org:8888/cookie-parser-result?chromium0011"); + assert_eq!(&r, "a=\"B"); +} + +#[test] +fn test_chromium0012() { + let r = run("http://home.example.org:8888/cookie-parser?chromium0012", + &["=ABC"], + "http://home.example.org:8888/cookie-parser-result?chromium0012"); + assert_eq!(&r, ""); +} + +#[test] +fn test_chromium0013() { + let r = run("http://home.example.org:8888/cookie-parser?chromium0013", + &["ABC=; path = /"], + "http://home.example.org:8888/cookie-parser-result?chromium0013"); + assert_eq!(&r, "ABC="); +} + +#[test] +fn test_chromium0014() { + let r = run("http://home.example.org:8888/cookie-parser?chromium0014", + &[" A = BC ;foo;;; bar"], + "http://home.example.org:8888/cookie-parser-result?chromium0014"); + assert_eq!(&r, "A=BC"); +} + +#[test] +fn test_chromium0015() { + let r = run("http://home.example.org:8888/cookie-parser?chromium0015", + &[" A=== BC ;foo;;; bar"], + "http://home.example.org:8888/cookie-parser-result?chromium0015"); + assert_eq!(&r, "A=== BC"); +} + +#[test] +fn test_chromium0016() { + let r = run("http://home.example.org:8888/cookie-parser?chromium0016", + &["foo=\"zohNumRKgI0oxyhSsV3Z7D\" ; expires=Sun, 18-Apr-2027 21:06:29 GMT\ + ; path=/ ;"], + "http://home.example.org:8888/cookie-parser-result?chromium0016"); + assert_eq!(&r, "foo=\"zohNumRKgI0oxyhSsV3Z7D\""); +} + +#[test] +fn test_chromium0017() { + let r = run("http://home.example.org:8888/cookie-parser?chromium0017", + &["foo=zohNumRKgI0oxyhSsV3Z7D ; expires=Sun, 18-Apr-2027 21:06:29 GMT ; p\ +ath=/ ;"], + "http://home.example.org:8888/cookie-parser-result?chromium0017"); + assert_eq!(&r, "foo=zohNumRKgI0oxyhSsV3Z7D"); +} + +#[test] +fn test_chromium0018() { + let r = run("http://home.example.org:8888/cookie-parser?chromium0018", + &[], + "http://home.example.org:8888/cookie-parser-result?chromium0018"); + assert_eq!(&r, ""); +} + +#[test] +fn test_chromium0019() { + let r = run("http://home.example.org:8888/cookie-parser?chromium0019", + &["a=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); +} + +#[test] +fn test_chromium0021() { + let r = run("http://home.example.org:8888/cookie-parser?chromium0021", + &[], + "http://home.example.org:8888/cookie-parser-result?chromium0021"); + assert_eq!(&r, ""); +} + +#[test] +fn test_comma0001() { + let r = run("http://home.example.org:8888/cookie-parser?comma0001", + &["foo=bar, baz=qux"], + "http://home.example.org:8888/cookie-parser-result?comma0001"); + assert_eq!(&r, "foo=bar, baz=qux"); +} + +#[test] +fn test_comma0002() { + let r = run("http://home.example.org:8888/cookie-parser?comma0002", + &["foo=\"bar, baz=qux\""], + "http://home.example.org:8888/cookie-parser-result?comma0002"); + assert_eq!(&r, "foo=\"bar, baz=qux\""); +} + +#[test] +fn test_comma0003() { + let r = run("http://home.example.org:8888/cookie-parser?comma0003", + &["foo=bar; b,az=qux"], + "http://home.example.org:8888/cookie-parser-result?comma0003"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_comma0004() { + let r = run("http://home.example.org:8888/cookie-parser?comma0004", + &["foo=bar; baz=q,ux"], + "http://home.example.org:8888/cookie-parser-result?comma0004"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_comma0005() { + let r = run("http://home.example.org:8888/cookie-parser?comma0005", + &["foo=bar; Max-Age=50,399"], + "http://home.example.org:8888/cookie-parser-result?comma0005"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_comma0006() { + let r = run("http://home.example.org:8888/cookie-parser?comma0006", + &["foo=bar; Expires=Fri, 07 Aug 2019 08:04:19 GMT"], + "http://home.example.org:8888/cookie-parser-result?comma0006"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_comma0007() { + let r = run("http://home.example.org:8888/cookie-parser?comma0007", + &["foo=bar; Expires=Fri 07 Aug 2019 08:04:19 GMT, baz=qux"], + "http://home.example.org:8888/cookie-parser-result?comma0007"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_domain0001() { + let r = run("http://home.example.org:8888/cookie-parser?domain0001", + &["foo=bar; domain=home.example.org"], + "http://home.example.org:8888/cookie-parser-result?domain0001"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_domain0002() { + let r = run("http://home.example.org:8888/cookie-parser?domain0002", + &["foo=bar; domain=home.example.org"], + "http://sibling.example.org:8888/cookie-parser-result?domain0002"); + assert_eq!(&r, ""); +} + +#[test] +fn test_domain0003() { + let r = run("http://home.example.org:8888/cookie-parser?domain0003", + &["foo=bar; domain=.home.example.org"], + "http://home.example.org:8888/cookie-parser-result?domain0003"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_domain0004() { + let r = run("http://home.example.org:8888/cookie-parser?domain0004", + &["foo=bar; domain=home.example.org"], + "http://subdomain.home.example.org:8888/cookie-parser-result?domain0004"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_domain0005() { + let r = run("http://home.example.org:8888/cookie-parser?domain0005", + &["foo=bar; domain=.home.example.org"], + "http://subdomain.home.example.org:8888/cookie-parser-result?domain0005"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_domain0006() { + let r = run("http://home.example.org:8888/cookie-parser?domain0006", + &["foo=bar; domain=.home.example.org"], + "http://sibling.example.org:8888/cookie-parser-result?domain0006"); + assert_eq!(&r, ""); +} + +#[test] +fn test_domain0007() { + let r = run("http://home.example.org:8888/cookie-parser?domain0007", + &["foo=bar; domain=sibling.example.org"], + "http://sibling.example.org:8888/cookie-parser-result?domain0007"); + assert_eq!(&r, ""); +} + +#[test] +fn test_domain0008() { + let r = run("http://home.example.org:8888/cookie-parser?domain0008", + &["foo=bar; domain=.example.org"], + "http://home.example.org:8888/cookie-parser-result?domain0008"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_domain0009() { + let r = run("http://home.example.org:8888/cookie-parser?domain0009", + &["foo=bar; domain=example.org"], + "http://home.example.org:8888/cookie-parser-result?domain0009"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_domain0010() { + let r = run("http://home.example.org:8888/cookie-parser?domain0010", + &["foo=bar; domain=..home.example.org"], + "http://home.example.org:8888/cookie-parser-result?domain0010"); + assert_eq!(&r, ""); +} + +#[test] +fn test_domain0011() { + let r = run("http://home.example.org:8888/cookie-parser?domain0011", + &["foo=bar; domain=home..example.org"], + "http://home.example.org:8888/cookie-parser-result?domain0011"); + assert_eq!(&r, ""); +} + +#[test] +fn test_domain0012() { + let r = run("http://home.example.org:8888/cookie-parser?domain0012", + &["foo=bar; domain= .home.example.org"], + "http://home.example.org:8888/cookie-parser-result?domain0012"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_domain0013() { + let r = run("http://home.example.org:8888/cookie-parser?domain0013", + &["foo=bar; domain= . home.example.org"], + "http://home.example.org:8888/cookie-parser-result?domain0013"); + assert_eq!(&r, ""); +} + +#[test] +fn test_domain0014() { + let r = run("http://home.example.org:8888/cookie-parser?domain0014", + &["foo=bar; domain=home.example.org."], + "http://home.example.org:8888/cookie-parser-result?domain0014"); + assert_eq!(&r, ""); +} + +#[test] +fn test_domain0015() { + let r = run("http://home.example.org:8888/cookie-parser?domain0015", + &["foo=bar; domain=home.example.org.."], + "http://home.example.org:8888/cookie-parser-result?domain0015"); + assert_eq!(&r, ""); +} + +#[test] +fn test_domain0016() { + let r = run("http://home.example.org:8888/cookie-parser?domain0016", + &["foo=bar; domain=home.example.org ."], + "http://home.example.org:8888/cookie-parser-result?domain0016"); + assert_eq!(&r, ""); +} + +#[test] +#[should_panic] // Look at cookie_http_state_utils.py if this test fails +fn test_domain0017() { + let r = run("http://home.example.org:8888/cookie-parser?domain0017", + &["foo=bar; domain=.org"], + "http://home.example.org:8888/cookie-parser-result?domain0017"); + assert_eq!(&r, ""); +} + +#[test] +fn test_domain0018() { + let r = run("http://home.example.org:8888/cookie-parser?domain0018", + &["foo=bar; domain=.org."], + "http://home.example.org:8888/cookie-parser-result?domain0018"); + assert_eq!(&r, ""); +} + +#[test] +fn test_domain0019() { + let r = run("http://home.example.org:8888/cookie-parser?domain0019", + &["foo=bar; domain=home.example.org", "foo2=bar2; domain=.home.example.org"], + "http://home.example.org:8888/cookie-parser-result?domain0019"); + assert_eq!(&r, "foo=bar; foo2=bar2"); +} + +#[test] +fn test_domain0020() { + let r = run("http://home.example.org:8888/cookie-parser?domain0020", + &["foo2=bar2; domain=.home.example.org", "foo=bar; domain=home.example.org"], + "http://home.example.org:8888/cookie-parser-result?domain0020"); + assert_eq!(&r, "foo2=bar2; foo=bar"); +} + +#[test] +fn test_domain0021() { + let r = run("http://home.example.org:8888/cookie-parser?domain0021", + &["foo=bar; domain=\"home.example.org\""], + "http://home.example.org:8888/cookie-parser-result?domain0021"); + assert_eq!(&r, ""); +} + +#[test] +fn test_domain0022() { + let r = run("http://home.example.org:8888/cookie-parser?domain0022", + &["foo=bar; domain=home.example.org", "foo2=bar2; domain=.example.org"], + "http://home.example.org:8888/cookie-parser-result?domain0022"); + assert_eq!(&r, "foo=bar; foo2=bar2"); +} + +#[test] +fn test_domain0023() { + let r = run("http://home.example.org:8888/cookie-parser?domain0023", + &["foo2=bar2; domain=.example.org", "foo=bar; domain=home.example.org"], + "http://home.example.org:8888/cookie-parser-result?domain0023"); + assert_eq!(&r, "foo2=bar2; foo=bar"); +} + +#[test] +fn test_domain0024() { + let r = run("http://home.example.org:8888/cookie-parser?domain0024", + &["foo=bar; domain=.example.org; domain=home.example.org"], + "http://sibling.example.org:8888/cookie-parser-result?domain0024"); + assert_eq!(&r, ""); +} + +#[test] +fn test_domain0025() { + let r = run("http://home.example.org:8888/cookie-parser?domain0025", + &["foo=bar; domain=home.example.org; domain=.example.org"], + "http://sibling.example.org:8888/cookie-parser-result?domain0025"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_domain0026() { + let r = run("http://home.example.org:8888/cookie-parser?domain0026", + &["foo=bar; domain=home.eXaMpLe.org"], + "http://home.example.org:8888/cookie-parser-result?domain0026"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_domain0027() { + let r = run("http://home.example.org:8888/cookie-parser?domain0027", + &["foo=bar; domain=home.example.org:8888"], + "http://home.example.org:8888/cookie-parser-result?domain0027"); + assert_eq!(&r, ""); +} + +#[test] +fn test_domain0028() { + let r = run("http://home.example.org:8888/cookie-parser?domain0028", + &["foo=bar; domain=subdomain.home.example.org"], + "http://subdomain.home.example.org:8888/cookie-parser-result?domain0028"); + assert_eq!(&r, ""); +} + +#[test] +fn test_domain0029() { + let r = run("http://home.example.org:8888/cookie-parser?domain0029", + &["foo=bar"], + "http://subdomain.home.example.org:8888/cookie-parser-result?domain0029"); + assert_eq!(&r, ""); +} + +#[test] +fn test_domain0031() { + let r = run("http://home.example.org:8888/cookie-parser?domain0031", + &["foo=bar; domain=home.example.org; domain=.example.org"], + "http://sibling.example.org:8888/cookie-parser-result?domain0031"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_domain0033() { + let r = run("http://home.example.org:8888/cookie-parser?domain0033", + &["foo=bar; domain=home.example.org"], + "http://hoMe.eXaMplE.org:8888/cookie-parser-result?domain0033"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_domain0034() { + let r = run("http://home.example.org:8888/cookie-parser?domain0034", + &["foo=bar; domain=home.example.org; domain=home.example.com"], + "http://home.example.org:8888/cookie-parser-result?domain0034"); + assert_eq!(&r, ""); +} + +#[test] +fn test_domain0035() { + let r = run("http://home.example.org:8888/cookie-parser?domain0035", + &["foo=bar; domain=home.example.com; domain=home.example.org"], + "http://home.example.org:8888/cookie-parser-result?domain0035"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_domain0036() { + let r = run("http://home.example.org:8888/cookie-parser?domain0036", + &["foo=bar; domain=home.example.org; domain=home.example.com; domain=home.\ +example.org"], + "http://home.example.org:8888/cookie-parser-result?domain0036"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_domain0037() { + let r = run("http://home.example.org:8888/cookie-parser?domain0037", + &["foo=bar; domain=home.example.com; domain=home.example.org; domain=home.\ +example.com"], + "http://home.example.org:8888/cookie-parser-result?domain0037"); + assert_eq!(&r, ""); +} + +#[test] +fn test_domain0038() { + let r = run("http://home.example.org:8888/cookie-parser?domain0038", + &["foo=bar; domain=home.example.org; domain=home.example.org"], + "http://home.example.org:8888/cookie-parser-result?domain0038"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_domain0039() { + let r = run("http://home.example.org:8888/cookie-parser?domain0039", + &["foo=bar; domain=home.example.org; domain=example.org"], + "http://home.example.org:8888/cookie-parser-result?domain0039"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_domain0040() { + let r = run("http://home.example.org:8888/cookie-parser?domain0040", + &["foo=bar; domain=example.org; domain=home.example.org"], + "http://home.example.org:8888/cookie-parser-result?domain0040"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_domain0041() { + let r = run("http://home.example.org:8888/cookie-parser?domain0041", + &["foo=bar; domain=.sibling.example.org"], + "http://sibling.example.org:8888/cookie-parser-result?domain0041"); + assert_eq!(&r, ""); +} + +#[test] +fn test_domain0042() { + let r = run("http://home.example.org:8888/cookie-parser?domain0042", + &["foo=bar; domain=.sibling.home.example.org"], + "http://sibling.home.example.org:8888/cookie-parser-result?domain0042"); + assert_eq!(&r, ""); +} + +#[test] +#[should_panic] // Look at cookie_http_state_utils.py if this test fails +fn test_mozilla0001() { + let r = run("http://home.example.org:8888/cookie-parser?mozilla0001", + &["foo=bar; max-age=-1"], + "http://home.example.org:8888/cookie-parser-result?mozilla0001"); + assert_eq!(&r, ""); +} + +#[test] +#[should_panic] // Look at cookie_http_state_utils.py if this test fails +fn test_mozilla0002() { + let r = run("http://home.example.org:8888/cookie-parser?mozilla0002", + &["foo=bar; max-age=0"], + "http://home.example.org:8888/cookie-parser-result?mozilla0002"); + assert_eq!(&r, ""); +} + +#[test] +#[should_panic] // Look at cookie_http_state_utils.py if this test fails +fn test_mozilla0003() { + let r = run("http://home.example.org:8888/cookie-parser?mozilla0003", + &["foo=bar; expires=Thu, 10 Apr 1980 16:33:12 GMT"], + "http://home.example.org:8888/cookie-parser-result?mozilla0003"); + assert_eq!(&r, ""); +} + +#[test] +fn test_mozilla0004() { + let r = run("http://home.example.org:8888/cookie-parser?mozilla0004", + &["foo=bar; max-age=60"], + "http://home.example.org:8888/cookie-parser-result?mozilla0004"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +#[should_panic] // Look at cookie_http_state_utils.py if this test fails +fn test_mozilla0005() { + let r = run("http://home.example.org:8888/cookie-parser?mozilla0005", + &["foo=bar; max-age=-20"], + "http://home.example.org:8888/cookie-parser-result?mozilla0005"); + assert_eq!(&r, ""); +} + +#[test] +fn test_mozilla0006() { + let r = run("http://home.example.org:8888/cookie-parser?mozilla0006", + &["foo=bar; max-age=60"], + "http://home.example.org:8888/cookie-parser-result?mozilla0006"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +#[should_panic] // Look at cookie_http_state_utils.py if this test fails +fn test_mozilla0007() { + let r = run("http://home.example.org:8888/cookie-parser?mozilla0007", + &["foo=bar; expires=Thu, 10 Apr 1980 16:33:12 GMT"], + "http://home.example.org:8888/cookie-parser-result?mozilla0007"); + assert_eq!(&r, ""); +} + +#[test] +fn test_mozilla0008() { + let r = run("http://home.example.org:8888/cookie-parser?mozilla0008", + &["foo=bar; max-age=60", "foo1=bar; max-age=60"], + "http://home.example.org:8888/cookie-parser-result?mozilla0008"); + assert_eq!(&r, "foo=bar; foo1=bar"); +} + +#[test] +#[should_panic] // Look at cookie_http_state_utils.py if this test fails +fn test_mozilla0009() { + let r = run("http://home.example.org:8888/cookie-parser?mozilla0009", + &["foo=bar; max-age=60", "foo1=bar; max-age=60", "foo=differentvalue; max-age=0"], + "http://home.example.org:8888/cookie-parser-result?mozilla0009"); + assert_eq!(&r, "foo1=bar"); +} + +#[test] +#[should_panic] // Look at cookie_http_state_utils.py if this test fails +fn test_mozilla0010() { + let r = run("http://home.example.org:8888/cookie-parser?mozilla0010", + &["foo=bar; max-age=60", + "foo1=bar; max-age=60", + "foo=differentvalue; max-age=0", + "foo2=evendifferentvalue; max-age=0"], + "http://home.example.org:8888/cookie-parser-result?mozilla0010"); + assert_eq!(&r, "foo1=bar"); +} + +#[test] +fn test_mozilla0011() { + let r = run("http://home.example.org:8888/cookie-parser?mozilla0011", + &["test=parser; domain=.parser.test; ;; ;=; ,,, ===,abc,=; abracadabra! ma\ +x-age=20;=;;"], + "http://home.example.org:8888/cookie-parser-result?mozilla0011"); + assert_eq!(&r, ""); +} + +#[test] +fn test_mozilla0012() { + let r = run("http://home.example.org:8888/cookie-parser?mozilla0012", + &["test=\"fubar! = foo;bar\\\";\" parser; max-age=6", "five; max-age=2.63,"], + "http://home.example.org:8888/cookie-parser-result?mozilla0012"); + assert_eq!(&r, "test=\"fubar! = foo"); +} + +#[test] +#[should_panic] // Look at cookie_http_state_utils.py if this test fails +fn test_mozilla0013() { + let r = run("http://home.example.org:8888/cookie-parser?mozilla0013", + &["test=kill; max-age=0", "five; max-age=0"], + "http://home.example.org:8888/cookie-parser-result?mozilla0013"); + assert_eq!(&r, ""); +} + +#[test] +fn test_mozilla0014() { + let r = run("http://home.example.org:8888/cookie-parser?mozilla0014", + &["six"], + "http://home.example.org:8888/cookie-parser-result?mozilla0014"); + assert_eq!(&r, ""); +} + +#[test] +fn test_mozilla0015() { + let r = run("http://home.example.org:8888/cookie-parser?mozilla0015", + &["six", "seven"], + "http://home.example.org:8888/cookie-parser-result?mozilla0015"); + assert_eq!(&r, ""); +} + +#[test] +fn test_mozilla0016() { + let r = run("http://home.example.org:8888/cookie-parser?mozilla0016", + &["six", "seven", " =eight"], + "http://home.example.org:8888/cookie-parser-result?mozilla0016"); + assert_eq!(&r, ""); +} + +#[test] +fn test_mozilla0017() { + let r = run("http://home.example.org:8888/cookie-parser?mozilla0017", + &["six", "seven", " =eight", "test=six"], + "http://home.example.org:8888/cookie-parser-result?mozilla0017"); + assert_eq!(&r, "test=six"); +} + +#[test] +fn test_name0001() { + let r = run("http://home.example.org:8888/cookie-parser?name0001", + &["a=bar"], + "http://home.example.org:8888/cookie-parser-result?name0001"); + assert_eq!(&r, "a=bar"); +} + +#[test] +fn test_name0002() { + let r = run("http://home.example.org:8888/cookie-parser?name0002", + &["1=bar"], + "http://home.example.org:8888/cookie-parser-result?name0002"); + assert_eq!(&r, "1=bar"); +} + +#[test] +fn test_name0003() { + let r = run("http://home.example.org:8888/cookie-parser?name0003", + &["$=bar"], + "http://home.example.org:8888/cookie-parser-result?name0003"); + assert_eq!(&r, "$=bar"); +} + +#[test] +fn test_name0004() { + let r = run("http://home.example.org:8888/cookie-parser?name0004", + &["!a=bar"], + "http://home.example.org:8888/cookie-parser-result?name0004"); + assert_eq!(&r, "!a=bar"); +} + +#[test] +fn test_name0005() { + let r = run("http://home.example.org:8888/cookie-parser?name0005", + &["@a=bar"], + "http://home.example.org:8888/cookie-parser-result?name0005"); + assert_eq!(&r, "@a=bar"); +} + +#[test] +fn test_name0006() { + let r = run("http://home.example.org:8888/cookie-parser?name0006", + &["#a=bar"], + "http://home.example.org:8888/cookie-parser-result?name0006"); + assert_eq!(&r, "#a=bar"); +} + +#[test] +fn test_name0007() { + let r = run("http://home.example.org:8888/cookie-parser?name0007", + &["$a=bar"], + "http://home.example.org:8888/cookie-parser-result?name0007"); + assert_eq!(&r, "$a=bar"); +} + +#[test] +fn test_name0008() { + let r = run("http://home.example.org:8888/cookie-parser?name0008", + &["%a=bar"], + "http://home.example.org:8888/cookie-parser-result?name0008"); + assert_eq!(&r, "%a=bar"); +} + +#[test] +fn test_name0009() { + let r = run("http://home.example.org:8888/cookie-parser?name0009", + &["^a=bar"], + "http://home.example.org:8888/cookie-parser-result?name0009"); + assert_eq!(&r, "^a=bar"); +} + +#[test] +fn test_name0010() { + let r = run("http://home.example.org:8888/cookie-parser?name0010", + &["&a=bar"], + "http://home.example.org:8888/cookie-parser-result?name0010"); + assert_eq!(&r, "&a=bar"); +} + +#[test] +fn test_name0011() { + let r = run("http://home.example.org:8888/cookie-parser?name0011", + &["*a=bar"], + "http://home.example.org:8888/cookie-parser-result?name0011"); + assert_eq!(&r, "*a=bar"); +} + +#[test] +fn test_name0012() { + let r = run("http://home.example.org:8888/cookie-parser?name0012", + &["(a=bar"], + "http://home.example.org:8888/cookie-parser-result?name0012"); + assert_eq!(&r, "(a=bar"); +} + +#[test] +fn test_name0013() { + let r = run("http://home.example.org:8888/cookie-parser?name0013", + &[")a=bar"], + "http://home.example.org:8888/cookie-parser-result?name0013"); + assert_eq!(&r, ")a=bar"); +} + +#[test] +fn test_name0014() { + let r = run("http://home.example.org:8888/cookie-parser?name0014", + &["-a=bar"], + "http://home.example.org:8888/cookie-parser-result?name0014"); + assert_eq!(&r, "-a=bar"); +} + +#[test] +fn test_name0015() { + let r = run("http://home.example.org:8888/cookie-parser?name0015", + &["_a=bar"], + "http://home.example.org:8888/cookie-parser-result?name0015"); + assert_eq!(&r, "_a=bar"); +} + +#[test] +fn test_name0016() { + let r = run("http://home.example.org:8888/cookie-parser?name0016", + &["+=bar"], + "http://home.example.org:8888/cookie-parser-result?name0016"); + assert_eq!(&r, "+=bar"); +} + +#[test] +fn test_name0017() { + let r = run("http://home.example.org:8888/cookie-parser?name0017", + &["=a=bar"], + "http://home.example.org:8888/cookie-parser-result?name0017"); + assert_eq!(&r, ""); +} + +#[test] +fn test_name0018() { + let r = run("http://home.example.org:8888/cookie-parser?name0018", + &["a =bar"], + "http://home.example.org:8888/cookie-parser-result?name0018"); + assert_eq!(&r, "a=bar"); +} + +#[test] +fn test_name0019() { + let r = run("http://home.example.org:8888/cookie-parser?name0019", + &["\"a=bar"], + "http://home.example.org:8888/cookie-parser-result?name0019"); + assert_eq!(&r, "\"a=bar"); +} + +#[test] +fn test_name0020() { + let r = run("http://home.example.org:8888/cookie-parser?name0020", + &["\"a=b\"=bar"], + "http://home.example.org:8888/cookie-parser-result?name0020"); + assert_eq!(&r, "\"a=b\"=bar"); +} + +#[test] +fn test_name0021() { + let r = run("http://home.example.org:8888/cookie-parser?name0021", + &["\"a=b\"=bar", "\"a=qux"], + "http://home.example.org:8888/cookie-parser-result?name0021"); + assert_eq!(&r, "\"a=qux"); +} + +#[test] +fn test_name0022() { + let r = run("http://home.example.org:8888/cookie-parser?name0022", + &[" foo=bar"], + "http://home.example.org:8888/cookie-parser-result?name0022"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_name0023() { + let r = run("http://home.example.org:8888/cookie-parser?name0023", + &["foo;bar=baz"], + "http://home.example.org:8888/cookie-parser-result?name0023"); + assert_eq!(&r, ""); +} + +#[test] +fn test_name0024() { + let r = run("http://home.example.org:8888/cookie-parser?name0024", + &["$Version=1; foo=bar"], + "http://home.example.org:8888/cookie-parser-result?name0024"); + assert_eq!(&r, "$Version=1"); +} + +#[test] +fn test_name0025() { + let r = run("http://home.example.org:8888/cookie-parser?name0025", + &["===a=bar"], + "http://home.example.org:8888/cookie-parser-result?name0025"); + assert_eq!(&r, ""); +} + +#[test] +fn test_name0026() { + let r = run("http://home.example.org:8888/cookie-parser?name0026", + &["foo=bar"], + "http://home.example.org:8888/cookie-parser-result?name0026"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_name0027() { + let r = run("http://home.example.org:8888/cookie-parser?name0027", + &["foo=bar ;"], + "http://home.example.org:8888/cookie-parser-result?name0027"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_name0028() { + let r = run("http://home.example.org:8888/cookie-parser?name0028", + &["=a"], + "http://home.example.org:8888/cookie-parser-result?name0028"); + assert_eq!(&r, ""); +} + +#[test] +fn test_name0029() { + let r = run("http://home.example.org:8888/cookie-parser?name0029", + &["="], + "http://home.example.org:8888/cookie-parser-result?name0029"); + assert_eq!(&r, ""); +} + +#[test] +fn test_name0030() { + let r = run("http://home.example.org:8888/cookie-parser?name0030", + &["foo bar=baz"], + "http://home.example.org:8888/cookie-parser-result?name0030"); + assert_eq!(&r, "foo bar=baz"); +} + +#[test] +fn test_name0031() { + let r = run("http://home.example.org:8888/cookie-parser?name0031", + &["\"foo;bar\"=baz"], + "http://home.example.org:8888/cookie-parser-result?name0031"); + assert_eq!(&r, ""); +} + +#[test] +fn test_name0032() { + let r = run("http://home.example.org:8888/cookie-parser?name0032", + &["\"foo\\\"bar;baz\"=qux"], + "http://home.example.org:8888/cookie-parser-result?name0032"); + assert_eq!(&r, ""); +} + +#[test] +fn test_name0033() { + let r = run("http://home.example.org:8888/cookie-parser?name0033", + &["=foo=bar", "aaa"], + "http://home.example.org:8888/cookie-parser-result?name0033"); + assert_eq!(&r, ""); +} + +#[test] +fn test_optional_domain0030() { + let r = run("http://home.example.org:8888/cookie-parser?optional-domain0030", + &["foo=bar; domain="], + "http://home.example.org:8888/cookie-parser-result?optional-domain0030"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_optional_domain0041() { + let r = run("http://home.example.org:8888/cookie-parser?optional-domain0041", + &["foo=bar; domain=example.org; domain="], + "http://home.example.org:8888/cookie-parser-result?optional-domain0041"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_optional_domain0042() { + let r = run("http://home.example.org:8888/cookie-parser?optional-domain0042", + &["foo=bar; domain=foo.example.org; domain="], + "http://home.example.org:8888/cookie-parser-result?optional-domain0042"); + assert_eq!(&r, ""); +} + +#[test] +fn test_optional_domain0043() { + let r = run("http://home.example.org:8888/cookie-parser?optional-domain0043", + &["foo=bar; domain=foo.example.org; domain="], + "http://subdomain.home.example.org:8888/cookie-parser-result?optional-do\ +main0043"); + assert_eq!(&r, ""); +} + +#[test] +fn test_ordering0001() { + let r = run("http://home.example.org:8888/cookie-parser?ordering0001", + &["key=val0;", + "key=val1; path=/cookie-parser-result", + "key=val2; path=/", + "key=val3; path=/bar", + "key=val4; domain=.example.org", + "key=val5; domain=.example.org; path=/cookie-parser-result/foo"], + "http://home.example.org:8888/cookie-parser-result/foo/baz?ordering0001"); + assert_eq!(&r, "key=val5; key=val1; key=val2; key=val4"); +} + +#[test] +fn test_path0001() { + let r = run("http://home.example.org:8888/cookie-parser?path0001", + &["a=b; path=/", "x=y; path=/cookie-parser-result"], + "http://home.example.org:8888/cookie-parser-result?path0001"); + assert_eq!(&r, "x=y; a=b"); +} + +#[test] +fn test_path0002() { + let r = run("http://home.example.org:8888/cookie-parser?path0002", + &["a=b; path=/cookie-parser-result", "x=y; path=/"], + "http://home.example.org:8888/cookie-parser-result?path0002"); + assert_eq!(&r, "a=b; x=y"); +} + +#[test] +fn test_path0003() { + let r = run("http://home.example.org:8888/cookie-parser?path0003", + &["x=y; path=/", "a=b; path=/cookie-parser-result"], + "http://home.example.org:8888/cookie-parser-result?path0003"); + assert_eq!(&r, "a=b; x=y"); +} + +#[test] +fn test_path0004() { + let r = run("http://home.example.org:8888/cookie-parser?path0004", + &["x=y; path=/cookie-parser-result", "a=b; path=/"], + "http://home.example.org:8888/cookie-parser-result?path0004"); + assert_eq!(&r, "x=y; a=b"); +} + +#[test] +fn test_path0005() { + let r = run("http://home.example.org:8888/cookie-parser?path0005", + &["foo=bar; path=/cookie-parser-result/foo"], + "http://home.example.org:8888/cookie-parser-result?path0005"); + assert_eq!(&r, ""); +} + +#[test] +fn test_path0006() { + let r = run("http://home.example.org:8888/cookie-parser?path0006", + &["foo=bar", "foo=qux; path=/cookie-parser-result/foo"], + "http://home.example.org:8888/cookie-parser-result?path0006"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_path0007() { + let r = run("http://home.example.org:8888/cookie-parser?path0007", + &["foo=bar; path=/cookie-parser-result/foo"], + "http://home.example.org:8888/cookie-parser-result/foo?path0007"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_path0008() { + let r = run("http://home.example.org:8888/cookie-parser?path0008", + &["foo=bar; path=/cookie-parser-result/foo"], + "http://home.example.org:8888/cookie-parser-result/bar?path0008"); + assert_eq!(&r, ""); +} + +#[test] +fn test_path0009() { + let r = run("http://home.example.org:8888/cookie-parser?path0009", + &["foo=bar; path=/cookie-parser-result/foo/qux"], + "http://home.example.org:8888/cookie-parser-result/foo?path0009"); + assert_eq!(&r, ""); +} + +#[test] +fn test_path0010() { + let r = run("http://home.example.org:8888/cookie-parser?path0010", + &["foo=bar; path=/cookie-parser-result/foo/qux"], + "http://home.example.org:8888/cookie-parser-result/foo/qux?path0010"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_path0011() { + let r = run("http://home.example.org:8888/cookie-parser?path0011", + &["foo=bar; path=/cookie-parser-result/foo/qux"], + "http://home.example.org:8888/cookie-parser-result/bar/qux?path0011"); + assert_eq!(&r, ""); +} + +#[test] +fn test_path0012() { + let r = run("http://home.example.org:8888/cookie-parser?path0012", + &["foo=bar; path=/cookie-parser-result/foo/qux"], + "http://home.example.org:8888/cookie-parser-result/foo/baz?path0012"); + assert_eq!(&r, ""); +} + +#[test] +fn test_path0013() { + let r = run("http://home.example.org:8888/cookie-parser?path0013", + &["foo=bar; path=/cookie-parser-result/foo/qux/"], + "http://home.example.org:8888/cookie-parser-result/foo/baz?path0013"); + assert_eq!(&r, ""); +} + +#[test] +fn test_path0014() { + let r = run("http://home.example.org:8888/cookie-parser?path0014", + &["foo=bar; path=/cookie-parser-result/foo/qux/"], + "http://home.example.org:8888/cookie-parser-result/foo/qux?path0014"); + assert_eq!(&r, ""); +} + +#[test] +fn test_path0015() { + let r = run("http://home.example.org:8888/cookie-parser?path0015", + &["foo=bar; path=/cookie-parser-result/foo/qux/"], + "http://home.example.org:8888/cookie-parser-result/foo/qux/?path0015"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_path0016() { + let r = run("http://home.example.org:8888/cookie-parser?path0016", + &["foo=bar; path=/cookie-parser-result/foo/"], + "http://home.example.org:8888/cookie-parser-result/foo/qux?path0016"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_path0017() { + let r = run("http://home.example.org:8888/cookie-parser?path0017", + &["foo=bar; path=/cookie-parser-result/foo/"], + "http://home.example.org:8888/cookie-parser-result/foo//qux?path0017"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_path0018() { + let r = run("http://home.example.org:8888/cookie-parser?path0018", + &["foo=bar; path=/cookie-parser-result/foo/"], + "http://home.example.org:8888/cookie-parser-result/fooqux?path0018"); + assert_eq!(&r, ""); +} + +#[test] +fn test_path0019() { + let r = run("http://home.example.org:8888/cookie-parser?path0019", + &["foo=bar; path"], + "http://home.example.org:8888/cookie-parser-result?path0019"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_path0020() { + let r = run("http://home.example.org:8888/cookie-parser?path0020", + &["foo=bar; path="], + "http://home.example.org:8888/cookie-parser-result?path0020"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_path0021() { + let r = run("http://home.example.org:8888/cookie-parser?path0021", + &["foo=bar; path=/"], + "http://home.example.org:8888/cookie-parser-result?path0021"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_path0022() { + let r = run("http://home.example.org:8888/cookie-parser?path0022", + &["foo=bar; path= /"], + "http://home.example.org:8888/cookie-parser-result?path0022"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_path0023() { + let r = run("http://home.example.org:8888/cookie-parser?path0023", + &["foo=bar; Path=/cookie-PARSER-result"], + "http://home.example.org:8888/cookie-parser-result?path0023"); + assert_eq!(&r, ""); +} + +#[test] +fn test_path0024() { + let r = run("http://home.example.org:8888/cookie-parser?path0024", + &["foo=bar; path=/cookie-parser-result/foo/qux?"], + "http://home.example.org:8888/cookie-parser-result/foo/qux?path0024"); + assert_eq!(&r, ""); +} + +#[test] +fn test_path0025() { + let r = run("http://home.example.org:8888/cookie-parser?path0025", + &["foo=bar; path=/cookie-parser-result/foo/qux#"], + "http://home.example.org:8888/cookie-parser-result/foo/qux?path0025"); + assert_eq!(&r, ""); +} + +#[test] +fn test_path0026() { + let r = run("http://home.example.org:8888/cookie-parser?path0026", + &["foo=bar; path=/cookie-parser-result/foo/qux;"], + "http://home.example.org:8888/cookie-parser-result/foo/qux?path0026"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_path0027() { + let r = run("http://home.example.org:8888/cookie-parser?path0027", + &["foo=bar; path=\"/cookie-parser-result/foo/qux;\""], + "http://home.example.org:8888/cookie-parser-result/foo/qux?path0027"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_path0028() { + let r = run("http://home.example.org:8888/cookie-parser?path0028", + &["foo=bar; path=/cookie-parser-result/f%6Fo/bar"], + "http://home.example.org:8888/cookie-parser-result/foo/bar?path0028"); + assert_eq!(&r, ""); +} + +#[test] +fn test_path0029() { + let r = run("http://home.example.org:8888/cookie-parser?path0029", + &["a=b; \tpath\t=\t/cookie-parser-result", "x=y; \tpath\t=\t/book"], + "http://home.example.org:8888/cookie-parser-result?path0029"); + assert_eq!(&r, "a=b"); +} + +#[test] +fn test_path0030() { + let r = run("http://home.example.org:8888/cookie-parser?path0030", + &["foo=bar; path=/dog; path="], + "http://home.example.org:8888/cookie-parser-result?path0030"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_path0031() { + let r = run("http://home.example.org:8888/cookie-parser?path0031", + &["foo=bar; path=; path=/dog"], + "http://home.example.org:8888/cookie-parser-result?path0031"); + assert_eq!(&r, ""); +} + +#[test] +fn test_path0032() { + let r = run("http://home.example.org:8888/cookie-parser?path0032", + &["foo=bar; path=/cookie-parser-result", "foo=qux; path=/cookie-parser-result/"], + "http://home.example.org:8888/cookie-parser-result/dog?path0032"); + assert_eq!(&r, "foo=qux; foo=bar"); +} + +#[test] +fn test_value0001() { + let r = run("http://home.example.org:8888/cookie-parser?value0001", + &["foo= bar"], + "http://home.example.org:8888/cookie-parser-result?value0001"); + assert_eq!(&r, "foo=bar"); +} + +#[test] +fn test_value0002() { + let r = run("http://home.example.org:8888/cookie-parser?value0002", + &["foo=\"bar\""], + "http://home.example.org:8888/cookie-parser-result?value0002"); + assert_eq!(&r, "foo=\"bar\""); +} + +#[test] +fn test_value0003() { + let r = run("http://home.example.org:8888/cookie-parser?value0003", + &["foo=\" bar \""], + "http://home.example.org:8888/cookie-parser-result?value0003"); + assert_eq!(&r, "foo=\" bar \""); +} + +#[test] +fn test_value0004() { + let r = run("http://home.example.org:8888/cookie-parser?value0004", + &["foo=\"bar;baz\""], + "http://home.example.org:8888/cookie-parser-result?value0004"); + assert_eq!(&r, "foo=\"bar"); +} + +#[test] +fn test_value0005() { + let r = run("http://home.example.org:8888/cookie-parser?value0005", + &["foo=\"bar=baz\""], + "http://home.example.org:8888/cookie-parser-result?value0005"); + assert_eq!(&r, "foo=\"bar=baz\""); +} + +#[test] +fn test_value0006() { + let r = run("http://home.example.org:8888/cookie-parser?value0006", + &["\tfoo\t=\tbar\t \t;\tttt"], + "http://home.example.org:8888/cookie-parser-result?value0006"); + assert_eq!(&r, "foo=bar"); +} diff --git a/tests/unit/net/cookie_http_state_utils.py b/tests/unit/net/cookie_http_state_utils.py new file mode 100644 index 000000000000..1afabd484926 --- /dev/null +++ b/tests/unit/net/cookie_http_state_utils.py @@ -0,0 +1,179 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +import os +import subprocess +import tempfile + +REPO = "https://github.com/abarth/http-state.git" +TEST_FILE = "cookie_http_state.rs" +DOMAIN = "http://home.example.org:8888" +RUST_FN = """ +#[test]{should_panic} +fn test_{name}() {{ + let r = run("{set_location}", + {set_cookies}, + "{location}"); + assert_eq!(&r, "{expect}"); +}} +""" +SET_COOKIES_INDENT = 18 +SHOULD_PANIC = "\n#[should_panic] // Look at cookie_http_state_utils.py if this test fails" + +# Those tests should PASS. But until fixes land in servo, keep them failing +FAILING_TESTS = [ + "attribute0004", # Waiting for issue 46 of alexcrichton/cookie-rs + "attribute0005", # Waiting for issue 46 of alexcrichton/cookie-rs + "attribute0007", # Waiting for issue 46 of alexcrichton/cookie-rs + "attribute0008", # Waiting for issue 46 of alexcrichton/cookie-rs + "domain0017", # Waiting for issue 11216 of servo/servo + "0003", # Waiting for a way to clean expired cookies + "0006", # Waiting for a way to clean expired cookies + "mozilla0001", # Waiting for a way to clean expired cookies + "mozilla0002", # Waiting for a way to clean expired cookies + "mozilla0003", # Waiting for a way to clean expired cookies + "mozilla0005", # Waiting for a way to clean expired cookies + "mozilla0007", # Waiting for a way to clean expired cookies + "mozilla0009", # Waiting for a way to clean expired cookies + "mozilla0010", # Waiting for a way to clean expired cookies + "mozilla0013", # Waiting for a way to clean expired cookies +] + + +def list_tests(dir): + suffix = "-test" + + def keep(name): + return name.endswith(suffix) and not name.startswith("disabled") + + tests = [name[:-len(suffix)] for name in os.listdir(dir) if keep(name)] + tests.sort() + return tests + + +def escape(s): + """ Escape the string `s` so that it can be parsed by rust as a valid + UTF-8 string. + We can't use only `encode("unicode_escape")` as it produces things that + rust does not accept ("\\xbf", "\\u6265" for example). So we manually + convert all character whose code point is greater than 128 to + \\u{code_point}. + All other characters are encoded with "unicode_escape" to get escape + sequences ("\\r" for example) except for `"` that we specifically escape + because our string will be quoted by double-quotes. + Lines are also limited in size, so split the string every 70 characters + (gives room for indentation). + """ + res = "" + last_split = 0 + for c in s: + if len(res) - last_split > 70: + res += "\\\n" + last_split = len(res) + o = ord(c) + if o == 34: + res += "\\\"" + continue + if o >= 128: + res += "\\u{" + hex(o)[2:] + "}" + else: + res += c.encode("unicode_escape") + return res + + +def format_slice_cookies(cookies): + esc_cookies = ['"%s"' % escape(c) for c in cookies] + if sum(len(s) for s in esc_cookies) < 80: + sep = ", " + else: + sep = ",\n" + " " * SET_COOKIES_INDENT + return "&[" + sep.join(esc_cookies) + "]" + + +def generate_code_for_test(test_dir, name): + if name in FAILING_TESTS: + should_panic = SHOULD_PANIC + else: + should_panic = "" + + test_file = os.path.join(test_dir, name + "-test") + expect_file = os.path.join(test_dir, name + "-expected") + + set_cookies = [] + set_location = DOMAIN + "/cookie-parser?" + name + expect = "" + location = DOMAIN + "/cookie-parser-result?" + name + + with open(test_file) as fo: + for line in fo: + line = line.decode("utf-8").rstrip() + prefix = "Set-Cookie: " + if line.startswith(prefix): + set_cookies.append(line[len(prefix):]) + prefix = "Location: " + if line.startswith(prefix): + location = line[len(prefix):] + if location.startswith("/"): + location = DOMAIN + location + + with open(expect_file) as fo: + for line in fo: + line = line.decode("utf-8").rstrip() + prefix = "Cookie: " + if line.startswith(prefix): + expect = line[len(prefix):] + + return RUST_FN.format(name=name.replace('-', '_'), + set_location=escape(set_location), + set_cookies=format_slice_cookies(set_cookies), + should_panic=should_panic, + location=escape(location), + expect=escape(expect)) + + +def update_test_file(cachedir): + workdir = os.path.dirname(os.path.realpath(__file__)) + test_file = os.path.join(workdir, TEST_FILE) + + # Create the cache dir + if not os.path.isdir(cachedir): + os.makedirs(cachedir) + + # Clone or update the repo + repo_dir = os.path.join(cachedir, "http-state") + if os.path.isdir(repo_dir): + args = ["git", "pull", "-f"] + process = subprocess.Popen(args, cwd=repo_dir) + if process.wait() != 0: + print("failed to update the http-state git repo") + return 1 + else: + args = ["git", "clone", REPO, repo_dir] + process = subprocess.Popen(args) + if process.wait() != 0: + print("failed to clone the http-state git repo") + return 1 + + # Truncate the unit test file to remove all existing tests + with open(test_file, "r+") as fo: + while True: + line = fo.readline() + if line.strip() == "// Test listing": + fo.truncate() + fo.flush() + break + if line == "": + print("Failed to find listing delimiter on unit test file") + return 1 + + # Append all tests to unit test file + tests_dir = os.path.join(repo_dir, "tests", "data", "parser") + with open(test_file, "a") as fo: + for test in list_tests(tests_dir): + fo.write(generate_code_for_test(tests_dir, test).encode("utf-8")) + + return 0 + +if __name__ == "__main__": + update_test_file(tempfile.gettempdir()) diff --git a/tests/unit/net/lib.rs b/tests/unit/net/lib.rs index 4e8e38dc8547..9a260a6f4552 100644 --- a/tests/unit/net/lib.rs +++ b/tests/unit/net/lib.rs @@ -20,6 +20,7 @@ extern crate util; #[cfg(test)] mod chrome_loader; #[cfg(test)] mod cookie; +#[cfg(test)] mod cookie_http_state; #[cfg(test)] mod data_loader; #[cfg(test)] mod file_loader; #[cfg(test)] mod fetch; From 4fb53c8256fc5b770255b47d9b60cdc540b9838b Mon Sep 17 00:00:00 2001 From: Florian Duraffourg Date: Tue, 17 May 2016 10:13:47 +0200 Subject: [PATCH 2/2] Correct cookie handling behavior - Cookies with empty values are not to be ignored as per RFC6265 - A space should separate two cookie-pairs as per RFC6265 section 4.2.1 --- components/net/cookie_storage.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/components/net/cookie_storage.rs b/components/net/cookie_storage.rs index 0698b8e46cd8..7482481bad11 100644 --- a/components/net/cookie_storage.rs +++ b/components/net/cookie_storage.rs @@ -58,10 +58,6 @@ impl CookieStorage { return; } - if cookie.cookie.value.is_empty() { - return; - } - // Step 11 if let Some(old_cookie) = old_cookie.unwrap() { // Step 11.3 @@ -108,7 +104,7 @@ impl CookieStorage { // Step 4 (match acc.len() { 0 => acc, - _ => acc + ";" + _ => acc + "; " }) + &c.cookie.name + "=" + &c.cookie.value }; let result = url_cookies.iter_mut().fold("".to_owned(), reducer);