diff options
Diffstat (limited to 'components/net/tests')
-rw-r--r-- | components/net/tests/hsts.rs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/components/net/tests/hsts.rs b/components/net/tests/hsts.rs index a3bebb67fcf..e7fae4cf8a4 100644 --- a/components/net/tests/hsts.rs +++ b/components/net/tests/hsts.rs @@ -3,16 +3,19 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use std::collections::HashMap; +use std::time::Duration as StdDuration; +use base::cross_process_instant::CrossProcessInstant; use net::hsts::{HstsEntry, HstsList}; use net_traits::IncludeSubdomains; +use time_03::Duration; #[test] fn test_hsts_entry_is_not_expired_when_it_has_no_timestamp() { let entry = HstsEntry { host: "mozilla.org".to_owned(), include_subdomains: false, - max_age: Some(20), + max_age: Some(StdDuration::from_secs(20)), timestamp: None, }; @@ -25,7 +28,7 @@ fn test_hsts_entry_is_not_expired_when_it_has_no_max_age() { host: "mozilla.org".to_owned(), include_subdomains: false, max_age: None, - timestamp: Some(time::get_time().sec as u64), + timestamp: Some(CrossProcessInstant::now()), }; assert!(!entry.is_expired()); @@ -36,8 +39,8 @@ fn test_hsts_entry_is_expired_when_it_has_reached_its_max_age() { let entry = HstsEntry { host: "mozilla.org".to_owned(), include_subdomains: false, - max_age: Some(10), - timestamp: Some(time::get_time().sec as u64 - 20u64), + max_age: Some(StdDuration::from_secs(10)), + timestamp: Some(CrossProcessInstant::now() - Duration::seconds(20)), }; assert!(entry.is_expired()); @@ -106,7 +109,7 @@ fn test_push_entry_with_0_max_age_evicts_entry_from_list() { vec![HstsEntry::new( "mozilla.org".to_owned(), IncludeSubdomains::NotIncluded, - Some(500000u64), + Some(StdDuration::from_secs(500000)), ) .unwrap()], ); @@ -118,7 +121,7 @@ fn test_push_entry_with_0_max_age_evicts_entry_from_list() { HstsEntry::new( "mozilla.org".to_owned(), IncludeSubdomains::NotIncluded, - Some(0), + Some(StdDuration::ZERO), ) .unwrap(), ); @@ -367,8 +370,8 @@ fn test_hsts_list_with_expired_entry_is_not_is_host_secure() { vec![HstsEntry { host: "mozilla.org".to_owned(), include_subdomains: false, - max_age: Some(20), - timestamp: Some(time::get_time().sec as u64 - 100u64), + max_age: Some(StdDuration::from_secs(20)), + timestamp: Some(CrossProcessInstant::now() - Duration::seconds(100)), }], ); let hsts_list = HstsList { |