[core] Tests first: wildcard headers, file name, size and upstream caps, identity stripping (red)
This commit is contained in:
@@ -217,3 +217,32 @@ fn caddy_output_matches_golden_file() {
|
||||
&compile::caddy(&model(false), &options()).unwrap(),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn forward_auth_hosts_strip_client_identity_headers_in_both_engines() {
|
||||
let m = model(false);
|
||||
let edge: EdgeConfig = serde_json::from_str(&compile::edge(&m, &options()).unwrap()).unwrap();
|
||||
let strip = edge.forward_auth.unwrap().strip_headers;
|
||||
for h in ["Remote-User", "Remote-Groups", "Remote-Email", "Remote-Name"] {
|
||||
assert!(strip.iter().any(|s| s.eq_ignore_ascii_case(h)), "edge strips {h}");
|
||||
}
|
||||
let caddy = compile::caddy(&m, &options()).unwrap();
|
||||
let v: serde_json::Value = serde_json::from_str(&caddy).unwrap();
|
||||
let routes = v["apps"]["http"]["servers"]["ianitor_https"]["routes"].as_array().unwrap();
|
||||
let wiki = routes.iter().find(|r| r["match"][0]["host"][0] == "wiki.home.test").unwrap();
|
||||
let steps = wiki["handle"][0]["routes"].as_array().unwrap();
|
||||
let first = &steps[0]["handle"][0];
|
||||
assert_eq!(first["handler"], "headers", "identity headers are deleted before forward_auth");
|
||||
let deleted: Vec<&str> =
|
||||
first["request"]["delete"].as_array().unwrap().iter().map(|d| d.as_str().unwrap()).collect();
|
||||
for h in ["Remote-User", "Remote-Groups", "Remote-Email", "Remote-Name"] {
|
||||
assert!(deleted.contains(&h), "caddy deletes {h}: {deleted:?}");
|
||||
}
|
||||
assert_eq!(steps[1]["handle"][0]["handler"], "reverse_proxy", "then forward_auth");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn websocket_refusal_in_caddy_matches_any_upgrade_token() {
|
||||
let caddy = compile::caddy(&model(false), &options()).unwrap();
|
||||
assert!(caddy.contains(r#"(?i)(^|,)\\s*websocket\\s*(,|$)"#), "token-aware Upgrade matcher");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user