mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Implement mutable HSTS list
This prepares the resource task to update the HSTS list when it sees STS headers. This will allow full HSTS support for servo/servo#6105 when the resource task implements the header checking
This commit is contained in:
parent
aa19a9a741
commit
d2f35555b9
2 changed files with 127 additions and 14 deletions
|
@ -19,6 +19,63 @@ fn test_exit() {
|
|||
resource_task.send(ControlMsg::Exit).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_push_entry_to_hsts_list_should_not_add_subdomains_whose_superdomain_is_already_matched() {
|
||||
let mut list = HSTSList {
|
||||
entries: vec!(HSTSEntry {
|
||||
host: "mozilla.org".to_string(),
|
||||
include_subdomains: true
|
||||
})
|
||||
};
|
||||
|
||||
list.push("servo.mozilla.org".to_string(), false);
|
||||
|
||||
assert!(list.entries.len() == 1)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_push_entry_to_hsts_list_should_update_existing_domain_entrys_include_subdomains() {
|
||||
let mut list = HSTSList {
|
||||
entries: vec!(HSTSEntry {
|
||||
host: "mozilla.org".to_string(),
|
||||
include_subdomains: true
|
||||
})
|
||||
};
|
||||
|
||||
assert!(list.always_secure("servo.mozilla.org"));
|
||||
|
||||
list.push("mozilla.org".to_string(), false);
|
||||
|
||||
assert!(!list.always_secure("servo.mozilla.org"))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_push_entry_to_hsts_list_should_not_create_duplicate_entry() {
|
||||
let mut list = HSTSList {
|
||||
entries: vec!(HSTSEntry {
|
||||
host: "mozilla.org".to_string(),
|
||||
include_subdomains: false
|
||||
})
|
||||
};
|
||||
|
||||
list.push("mozilla.org".to_string(), false);
|
||||
|
||||
assert!(list.entries.len() == 1)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_push_entry_to_hsts_list_should_add_an_entry() {
|
||||
let mut list = HSTSList {
|
||||
entries: Vec::new()
|
||||
};
|
||||
|
||||
assert!(!list.always_secure("mozilla.org"));
|
||||
|
||||
list.push("mozilla.org".to_string(), true);
|
||||
|
||||
assert!(list.always_secure("mozilla.org"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_hsts_preload_should_return_none_when_json_invalid() {
|
||||
let mock_preload_content = "derp";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue