v0.34.0_8

This commit is contained in:
Mateusz Gruszczyński committed 2026-10-18 08:26:35 +02:00
1 parent b6a3e12225
commit 480c3ec769
92 files changed
+298 -10035

No files matched your search

+55 -15
View File
@@ -36,7 +36,12 @@ mod authority_tests {
fn preserve_host_sets_http2_authority_without_changing_network_origin() {
use crate::config::UpstreamProtocol;
for (protocol, scheme, expected_authority, remove_host) in [
(UpstreamProtocol::Http1, "https", "backend.internal:443", false),
(
UpstreamProtocol::Http1,
"https",
"backend.internal:443",
false,
),
(UpstreamProtocol::Auto, "https", "unitraklub.pl", false),
(UpstreamProtocol::Http2, "https", "unitraklub.pl", false),
(UpstreamProtocol::H2, "https", "unitraklub.pl", true),
@@ -59,7 +64,11 @@ mod authority_tests {
let mut headers = HeaderMap::new();
headers.insert(HOST, HeaderValue::from_static("unitraklub.pl"));
let target = upstream_request_target(uri, &mut headers, backend, false, false).unwrap();
assert_eq!(target.authority().unwrap().as_str(), expected_authority, "{protocol:?}");
assert_eq!(
target.authority().unwrap().as_str(),
expected_authority,
"{protocol:?}"
);
assert_eq!(target.path(), "/block_refresh/block/10");
assert_eq!(headers.contains_key(HOST), !remove_host);
assert_eq!(backend.origin, format!("{scheme}://10.87.20.2:443"));
@@ -70,8 +79,10 @@ mod authority_tests {
fn optimized_log_prefix_preserves_unicode_char_count_and_ascii_bytes() {
assert_eq!(log_prefix("/small.html", 256), "/small.html");
assert_eq!(log_prefix("abcdefghijklmnopqrstuvwxyz", 5), "abcde");
assert_eq!(log_prefix("za\u{17c}\u{f3}\u{142}\u{107}\u{1f525}", 4),
"za\u{17c}\u{f3}");
assert_eq!(
log_prefix("za\u{17c}\u{f3}\u{142}\u{107}\u{1f525}", 4),
"za\u{17c}\u{f3}"
);
assert_eq!(log_prefix("", 0), "");
}
@@ -83,8 +94,14 @@ mod authority_tests {
let uri = upstream_uri(backend, "/keep?key=hello%2Fworld").unwrap();
let mut headers = HeaderMap::new();
let target = upstream_request_target(uri, &mut headers, backend, false, false).unwrap();
assert_eq!(target.path_and_query().unwrap().as_str(), "/keep?key=hello%2Fworld");
assert_eq!(target.authority().unwrap(), backend.request_origin_uri.authority().unwrap());
assert_eq!(
target.path_and_query().unwrap().as_str(),
"/keep?key=hello%2Fworld"
);
assert_eq!(
target.authority().unwrap(),
backend.request_origin_uri.authority().unwrap()
);
}
#[test]
@@ -109,8 +126,16 @@ mod authority_tests {
let backend = &snapshot.pools[0].members[0].backend;
let mut headers = HeaderMap::new();
headers.insert(HOST, HeaderValue::from_static("public.example"));
let req = retry_request(&Method::GET, Version::HTTP_2, &headers, backend,
&HeaderValue::from_static("public.example"), "/retry", true).unwrap();
let req = retry_request(
&Method::GET,
Version::HTTP_2,
&headers,
backend,
&HeaderValue::from_static("public.example"),
"/retry",
true,
)
.unwrap();
assert_eq!(req.uri().authority().unwrap().as_str(), "public.example");
assert!(req.headers().get(HOST).is_none());
}
@@ -361,7 +386,10 @@ mod authority_tests {
#[test]
fn backend_diagnostics_are_opt_in_and_strip_spoofed_values() {
let mut response = Response::new(Body::empty());
response.headers_mut().insert("x-rustproxy-backend", HeaderValue::from_static("canonical-spoof"));
response.headers_mut().insert(
"x-rustproxy-backend",
HeaderValue::from_static("canonical-spoof"),
);
response
.headers_mut()
.insert("x-rust-proxy-backend", HeaderValue::from_static("spoofed"));
@@ -388,7 +416,10 @@ mod authority_tests {
response
.extensions_mut()
.insert(OriginTiming(Duration::from_millis(12)));
response.headers_mut().insert("x-rustproxy-backend", HeaderValue::from_static("canonical-spoof"));
response.headers_mut().insert(
"x-rustproxy-backend",
HeaderValue::from_static("canonical-spoof"),
);
apply_backend_diagnostic_values(&mut response, true, true);
assert!(response.headers().get("x-rustproxy-backend").is_none());
assert_eq!(
@@ -623,16 +654,25 @@ mod graceful_h2_tests {
config.vhosts[0].backends[0].tls_server_name = Some("backend.example".into());
let snapshot = crate::config::compile(config, 1, &validation_policy()).unwrap();
let backend = &snapshot.pools[0].members[0].backend;
assert_eq!(backend.request_origin_uri.to_string(), backend.request_origin);
assert_eq!(
backend.request_origin_uri.to_string(),
backend.request_origin
);
for suffix in [
"/", "/static/main.css", "/path?x=1&y=2", "/p%2Fq?url=https%3A//example.org/a",
"/?q=%C5%82&empty=", "/double//slash", "/item#frag",
"/",
"/static/main.css",
"/path?x=1&y=2",
"/p%2Fq?url=https%3A//example.org/a",
"/?q=%C5%82&empty=",
"/double//slash",
"/item#frag",
] {
let previous = format!("{}{suffix}", backend.request_origin).parse::<Uri>().ok();
let previous = format!("{}{suffix}", backend.request_origin)
.parse::<Uri>()
.ok();
assert_eq!(upstream_uri(backend, suffix), previous, "{suffix}");
}
assert!(upstream_uri(backend, "http://attacker.invalid/").is_none());
assert_eq!(backend.origin, "https://127.0.0.1:9000");
}
}