diff --git a/.github/actions/spelling/patterns.txt b/.github/actions/spelling/patterns.txt index 8050ff07afd4f..c15a1bb00a89f 100644 --- a/.github/actions/spelling/patterns.txt +++ b/.github/actions/spelling/patterns.txt @@ -218,3 +218,6 @@ k8s # ignore comment in package-msi.sh [#].*custom\.a28ecdc.* + +# ignore specific user:password string containing special chars for unit testing +user:P@ssw0rd diff --git a/lib/vector-core/src/config/proxy.rs b/lib/vector-core/src/config/proxy.rs index 79bceaa63c79c..266ffed72d167 100644 --- a/lib/vector-core/src/config/proxy.rs +++ b/lib/vector-core/src/config/proxy.rs @@ -356,4 +356,25 @@ mod tests { expected_header_value.as_ref().ok() ); } + + #[ignore] + #[test] + fn build_proxy_with_special_chars_url_encoded() { + let config = ProxyConfig { + http: Some("http://user:P%40ssw0rd@1.2.3.4:5678".into()), + https: Some("https://user:P%40ssw0rd@2.3.4.5:9876".into()), + ..Default::default() + }; + let first = config + .http_proxy() + .expect("should not be an error") + .expect("should not be None"); + let encoded_header = format!("Basic {}", BASE64_STANDARD.encode("user:P@ssw0rd")); + let expected_header_value = HeaderValue::from_str(encoded_header.as_str()); + + assert_eq!( + first.headers().get("authorization"), + expected_header_value.as_ref().ok() + ); + } }