This commit is contained in:
Mateusz Gruszczyński committed 2026-11-15 20:54:59 +01:00
1 parent 758cfd6274
commit 8bdec5c757
32 files changed
+418 -44

No files matched your search

+28
View File
@@ -299,3 +299,31 @@ mod websocket_protocol_flags_tests {
assert!(r#"{"websocket_rfc9220":true}"#.contains("\"websocket_rfc9220\":true"));
}
}
mod timing_allow_origin_tests {
use super::*;
fn value(origins: &[&str]) -> Result<Option<http::HeaderValue>> {
timing_allow_origin_value(&origins.iter().map(|v| v.to_string()).collect::<Vec<_>>())
}
#[test]
fn origins_and_wildcard_are_accepted() {
assert!(value(&[]).unwrap().is_none());
assert_eq!(value(&["*"]).unwrap().unwrap(), "*");
assert_eq!(
value(&["https://app.example.com", "http://localhost:3000"]).unwrap().unwrap(),
"https://app.example.com, http://localhost:3000"
);
}
#[test]
fn paths_wildcard_mixes_and_other_schemes_are_rejected() {
for bad in [
&["https://app.example.com/"][..],
&["https://app.example.com/path"],
&["https://user@app.example.com"],
&["ftp://app.example.com"],
&["app.example.com"],
&["*", "https://app.example.com"],
] {
assert!(value(bad).is_err(), "{bad:?}");
}
}
}