mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-04-13 21:57:29 +08:00
27 lines
751 B
Go
27 lines
751 B
Go
package agent
|
|
|
|
import "testing"
|
|
|
|
func TestRedactSecretsInText(t *testing.T) {
|
|
in := `{"token":"abc123","authorization":"Bearer sk-xyz","password":"p@ss","note":"ok"}`
|
|
out := redactSecretsInText(in)
|
|
|
|
if out == in {
|
|
t.Fatalf("expected redaction to change input")
|
|
}
|
|
if containsAnySubstring(out, "abc123", "sk-xyz", "p@ss") {
|
|
t.Fatalf("expected sensitive values to be redacted, got: %s", out)
|
|
}
|
|
}
|
|
|
|
func TestSanitizeSensitiveToolArgs(t *testing.T) {
|
|
args := map[string]interface{}{
|
|
"command": "git -c http.extraHeader='Authorization: token abc123' ls-remote https://example.com/repo.git",
|
|
"token": "abc123",
|
|
}
|
|
safe := sanitizeSensitiveToolArgs(args)
|
|
if safe["token"] == "abc123" {
|
|
t.Fatalf("expected token field to be redacted")
|
|
}
|
|
}
|