This commit is contained in:
Mateusz Gruszczyński committed 2026-10-04 22:53:33 +02:00
1 parent 174389e5b1
commit e6604e41fc
73 files changed
+1240 -201

No files matched your search

+24
View File
@@ -82,6 +82,30 @@ mod default_listener_tests {
);
}
#[test]
fn method_policy_normalizes_and_enforces_allow_and_block_modes() {
let mut allow: MethodPolicy = serde_json::from_value(json!({
"mode": "allow",
"methods": ["get", "HEAD", "post"]
}))
.unwrap();
allow.validate().unwrap();
assert_eq!(allow.methods, vec!["GET", "HEAD", "POST"]);
assert!(allow.allows(&http::Method::GET));
assert!(!allow.allows(&http::Method::DELETE));
assert_eq!(allow.allow_header().unwrap().to_str().unwrap(), "GET, HEAD, POST");
let mut block: MethodPolicy = serde_json::from_value(json!({
"mode": "block",
"methods": ["delete"]
}))
.unwrap();
block.validate().unwrap();
assert!(!block.allows(&http::Method::DELETE));
assert!(block.allows(&http::Method::GET));
assert!(block.allow_header().is_none());
}
#[test]
fn h2c_is_cleartext_only_and_defaults_off() {
let plain: Listener =