refactor: harden tests

This commit is contained in:
zhom
2026-07-21 23:13:17 +04:00
parent f7daf68b52
commit 9624ec846d
81 changed files with 11771 additions and 983 deletions
+12 -3
View File
@@ -1351,9 +1351,8 @@ pub async fn handle_proxy_connection(
/// Render an upstream proxy URL for logging with any embedded credentials
/// stripped. `config.upstream_url` carries `scheme://user:pass@host:port`, and
/// these logs land in a world-readable file under the system temp dir, so the
/// userinfo must never be emitted.
fn redacted_upstream(upstream: &str) -> String {
/// diagnostic logs and command responses must never expose the userinfo.
pub fn redacted_upstream(upstream: &str) -> String {
if upstream.is_empty() {
return "none".to_string();
}
@@ -2238,6 +2237,16 @@ mod tests {
assert_eq!(upstream_userpass(&u), ("u@name".into(), String::new()));
}
#[test]
fn upstream_log_value_never_contains_credentials() {
assert_eq!(
redacted_upstream("http://user:p%40ss@example.com:8080"),
"http://example.com:8080"
);
assert_eq!(redacted_upstream("not a URL"), "<redacted>");
assert_eq!(redacted_upstream(""), "none");
}
#[test]
fn test_blocklist_exact_match() {
let mut matcher = BlocklistMatcher::new();