Skip to content

Commit

Permalink
enhancement(core): add unit test (ignored) for support for encoding s…
Browse files Browse the repository at this point in the history
…pecial chars in `ProxyConfig` (vectordotdev#17148)
  • Loading branch information
neuronull authored Apr 13, 2023
1 parent 198068c commit 5247972
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/actions/spelling/patterns.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 21 additions & 0 deletions lib/vector-core/src/config/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
}
}

0 comments on commit 5247972

Please sign in to comment.