33 lines
1.3 KiB
Rust
33 lines
1.3 KiB
Rust
mod tests {
|
|
use super::*;
|
|
#[test]
|
|
fn removes_nominated_fields_and_preserves_cookies() {
|
|
let mut h = HeaderMap::new();
|
|
h.insert("connection", "keep-alive, X-Internal".parse().unwrap());
|
|
h.insert("x-internal", "secret".parse().unwrap());
|
|
h.insert("keep-alive", "timeout=5".parse().unwrap());
|
|
h.append("set-cookie", "a=1".parse().unwrap());
|
|
h.append("set-cookie", "b=2".parse().unwrap());
|
|
strip_hop_by_hop(&mut h);
|
|
assert!(!h.contains_key("x-internal"));
|
|
assert!(!h.contains_key("connection"));
|
|
assert_eq!(h.get_all("set-cookie").iter().count(), 2);
|
|
}
|
|
#[test]
|
|
fn upgrade_is_case_insensitive() {
|
|
let mut h = HeaderMap::new();
|
|
h.insert("connection", "keep-alive, Upgrade".parse().unwrap());
|
|
assert!(requests_upgrade(&h));
|
|
}
|
|
#[test]
|
|
fn admin_cookie_can_be_restored_only_from_captured_fragment() {
|
|
let mut h = HeaderMap::new();
|
|
h.insert("cookie", "a=1; rustproxy_session=secret; b=2".parse().unwrap());
|
|
let admin = strip_admin_cookie(&mut h);
|
|
assert_eq!(h.get("cookie").unwrap(), "a=1; b=2");
|
|
assert_eq!(admin, vec!["rustproxy_session=secret"]);
|
|
restore_admin_cookie(&mut h, &admin);
|
|
assert_eq!(h.get("cookie").unwrap(), "a=1; b=2; rustproxy_session=secret");
|
|
}
|
|
}
|