Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(core_rpc): add test for URL redaction in logs

Steven Enamakele825458485a3
diff --git a/app/src-tauri/src/core_rpc.rs b/app/src-tauri/src/core_rpc.rs
index 7cc37d32b4..3768924167 100644
--- a/app/src-tauri/src/core_rpc.rs
+++ b/app/src-tauri/src/core_rpc.rs
@@ -217,4 +217,20 @@ mod tests {
assert_eq!(relay_bearer_header(Some("")), None);
assert_eq!(relay_bearer_header(Some(" ")), None);
}
+
+ #[test]
+ fn redact_strips_credentials_query_and_path() {
+ // Userinfo, query, fragment, and path must not survive into logs; only
+ // the scheme://host[:port] surface is kept for transport diagnostics.
+ assert_eq!(
+ redact_url_for_log("http://user:[email protected]:7788/rpc/secret?token=t0k#frag"),
+ "http://[email protected]:7788/"
+ );
+ assert_eq!(
+ redact_url_for_log("https://core.example.com/rpc"),
+ "https://core.example.com/"
+ );
+ // An unparseable URL degrades to the coarse sentinel.
+ assert_eq!(redact_url_for_log("not a url"), "<invalid relay url>");
+ }
}