v0.42.2_fix2

This commit is contained in:
Mateusz Gruszczyński committed 2026-11-26 13:06:54 +01:00
1 parent 25148f26eb
commit a75893d428
16 files changed
+301 -66

No files matched your search

+38
View File
@@ -327,3 +327,41 @@ mod timing_allow_origin_tests {
}
}
}
mod local_web_service_redirect_tests {
use super::Vhost;
use serde_json::json;
#[test]
fn web_service_with_local_redirect_does_not_require_proxy_backend() {
let mut host: Vhost = serde_json::from_value(json!({
"id": "web-with-redirect",
"frontend": { "hosts": ["example.test"], "listener_ids": ["http"] },
"source": { "type": "web_server", "web_service_id": "site" },
"routes": [
{
"id": "root-redirect", "match_type": "exact", "path_prefix": "/",
"source": { "type": "reverse_proxy" },
"redirect": { "status": 302, "target": "https://example.test/app/" }
},
{
"id": "local-error", "match_type": "exact", "path_prefix": "/maintenance",
"source": { "type": "reverse_proxy" },
"response": { "status": 503, "body": "Maintenance" }
}
]
}))
.unwrap();
assert!(host.validate().is_ok(), "local actions require no backend");
host.routes.push(serde_json::from_value(json!({
"id": "unused-proxy", "path_prefix": "/disabled/", "enabled": false,
"source": { "type": "reverse_proxy" }
})).unwrap());
assert!(host.validate().is_ok(), "disabled proxy route needs no backend");
host.routes.last_mut().unwrap().enabled = true;
assert!(host.validate().unwrap_err().to_string().contains("backend"),
"an active reverse-proxy route still requires a backend");
}
}