-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathconnectors_test.go
More file actions
29 lines (25 loc) · 892 Bytes
/
connectors_test.go
File metadata and controls
29 lines (25 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package setup
import (
"strings"
"testing"
)
func TestRedactConnectorErrorBody_RedactsSecrets(t *testing.T) {
secret := "AIzaSy-very-secret-key"
body := []byte("validation failed for key AIzaSy-very-secret-key with provider error")
redacted := redactConnectorErrorBody(body, secret)
if redacted == string(body) {
t.Fatalf("expected redaction to change error body")
}
if contains := (redacted == "" || redacted == "<empty response body>"); contains {
t.Fatalf("expected non-empty redacted output")
}
if wantAbsent := secret; wantAbsent != "" && strings.Contains(redacted, wantAbsent) {
t.Fatalf("expected secret to be redacted, got %q", redacted)
}
}
func TestRedactConnectorErrorBody_EmptyBody(t *testing.T) {
redacted := redactConnectorErrorBody(nil, "anything")
if redacted != "<empty response body>" {
t.Fatalf("expected empty body marker, got %q", redacted)
}
}