v0.34.0_4
This commit is contained in:
1 parent
f20c8da718
commit
5910e6e901
21 files changed
+377
-51
No files matched your search
@@ -52,4 +52,34 @@ mod tests {
|
||||
restore_admin_cookie(&mut h, &admin);
|
||||
assert_eq!(h.get("cookie").unwrap(), "a=1; b=2; rustproxy_session=secret");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn common_keep_alive_does_not_strip_unrelated_headers() {
|
||||
for value in ["keep-alive", "KEEP-ALIVE", "Keep-Alive"] {
|
||||
let mut headers = HeaderMap::new();
|
||||
headers.insert("connection", value.parse().unwrap());
|
||||
headers.insert("keep-alive", "timeout=2".parse().unwrap());
|
||||
headers.insert("x-tenant", "alpha".parse().unwrap());
|
||||
headers.insert("authorization", "Bearer allowed".parse().unwrap());
|
||||
strip_hop_by_hop(&mut headers);
|
||||
assert!(!headers.contains_key("connection"));
|
||||
assert!(!headers.contains_key("keep-alive"));
|
||||
assert_eq!(headers["x-tenant"], "alpha");
|
||||
assert_eq!(headers["authorization"], "Bearer allowed");
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn multiple_connection_fields_still_strip_all_nominated_headers() {
|
||||
let mut headers = HeaderMap::new();
|
||||
headers.append("connection", "keep-alive".parse().unwrap());
|
||||
headers.append("connection", "x-hidden, upgrade".parse().unwrap());
|
||||
headers.insert("x-hidden", "sensitive".parse().unwrap());
|
||||
headers.insert("x-public", "allowed".parse().unwrap());
|
||||
headers.insert("upgrade", "websocket".parse().unwrap());
|
||||
strip_hop_by_hop(&mut headers);
|
||||
assert!(!headers.contains_key("x-hidden"));
|
||||
assert!(!headers.contains_key("connection"));
|
||||
assert!(!headers.contains_key("upgrade"));
|
||||
assert_eq!(headers["x-public"], "allowed");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user