From dbef65129f40ce6ca0e8ee7e520ec366c1c7577e Mon Sep 17 00:00:00 2001 From: Florian Duraffourg Date: Thu, 9 Jun 2016 09:11:38 +0200 Subject: Add mach command to update public domain list and use a HashSet instead of a Vec to lookup public domains --- tests/unit/net/cookie_http_state.rs | 1 - tests/unit/net/cookie_http_state_utils.py | 1 - tests/unit/net/lib.rs | 1 + tests/unit/net/pub_domains.rs | 38 +++++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 tests/unit/net/pub_domains.rs (limited to 'tests/unit') diff --git a/tests/unit/net/cookie_http_state.rs b/tests/unit/net/cookie_http_state.rs index a8388558336..45abb4d5d5f 100644 --- a/tests/unit/net/cookie_http_state.rs +++ b/tests/unit/net/cookie_http_state.rs @@ -975,7 +975,6 @@ fn test_domain0016() { } #[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"], diff --git a/tests/unit/net/cookie_http_state_utils.py b/tests/unit/net/cookie_http_state_utils.py index 1afabd48492..6b429b5d859 100644 --- a/tests/unit/net/cookie_http_state_utils.py +++ b/tests/unit/net/cookie_http_state_utils.py @@ -27,7 +27,6 @@ FAILING_TESTS = [ "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 diff --git a/tests/unit/net/lib.rs b/tests/unit/net/lib.rs index a20926967ca..7923ede897d 100644 --- a/tests/unit/net/lib.rs +++ b/tests/unit/net/lib.rs @@ -27,6 +27,7 @@ extern crate util; #[cfg(test)] mod file_loader; #[cfg(test)] mod fetch; #[cfg(test)] mod mime_classifier; +#[cfg(test)] mod pub_domains; #[cfg(test)] mod resource_thread; #[cfg(test)] mod hsts; #[cfg(test)] mod http_loader; diff --git a/tests/unit/net/pub_domains.rs b/tests/unit/net/pub_domains.rs new file mode 100644 index 00000000000..60f2aa2b2e9 --- /dev/null +++ b/tests/unit/net/pub_domains.rs @@ -0,0 +1,38 @@ +/* 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 net::pub_domains::is_pub_domain; + +#[test] +fn test_is_pub_domain_plain() { + assert!(is_pub_domain("com")); + assert!(is_pub_domain(".org")); + assert!(is_pub_domain("za.org")); + assert!(is_pub_domain("xn--od0alg.hk")); + assert!(is_pub_domain("xn--krdsherad-m8a.no")); +} + +#[test] +fn test_is_pub_domain_wildcard() { + assert!(is_pub_domain("hello.bd")); + assert!(is_pub_domain("world.jm")); + assert!(is_pub_domain("toto.kobe.jp")); +} + +#[test] +fn test_is_pub_domain_exception() { + assert_eq!(is_pub_domain("www.ck"), false); + assert_eq!(is_pub_domain("city.kawasaki.jp"), false); + assert_eq!(is_pub_domain("city.nagoya.jp"), false); + assert_eq!(is_pub_domain("teledata.mz"), false); +} + +#[test] +fn test_is_pub_domain_not() { + assert_eq!(is_pub_domain(".servo.org"), false); + assert_eq!(is_pub_domain("www.mozilla.org"), false); + assert_eq!(is_pub_domain("publicsuffix.org"), false); + assert_eq!(is_pub_domain("hello.world.jm"), false); + assert_eq!(is_pub_domain("toto.toto.kobe.jp"), false); +} -- cgit v1.2.3