Remove application credential substitution
This commit is contained in:
@@ -4,13 +4,12 @@ import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDiagnosticsWriterProducesValidJSONArtifacts(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
writer := NewDiagnosticsWriter(dir, nil)
|
||||
writer := NewDiagnosticsWriter(dir)
|
||||
|
||||
artifacts, err := writer.WriteInteraction(
|
||||
"validation:batch-1",
|
||||
@@ -31,45 +30,6 @@ func TestDiagnosticsWriterProducesValidJSONArtifacts(t *testing.T) {
|
||||
assertValidJSONFile(t, artifacts.ResponsePayloadPath)
|
||||
}
|
||||
|
||||
func TestDiagnosticsWriterRedactsSecrets(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
secret := "top-secret-token"
|
||||
writer := NewDiagnosticsWriter(dir, []string{secret})
|
||||
|
||||
artifacts, err := writer.WriteInteraction(
|
||||
"module glossary / request",
|
||||
map[string]any{"authorization": "Bearer " + secret},
|
||||
map[string]any{"api_key": secret, "nested": map[string]any{"value": secret}},
|
||||
map[string]any{"echo": secret},
|
||||
map[string]any{"error": "failed with " + secret},
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("WriteInteraction: %v", err)
|
||||
}
|
||||
|
||||
for _, path := range []string{
|
||||
artifacts.RequestMetadataPath,
|
||||
artifacts.RequestPayloadPath,
|
||||
artifacts.ResponsePayloadPath,
|
||||
artifacts.ErrorPayloadPath,
|
||||
} {
|
||||
raw, readErr := os.ReadFile(path)
|
||||
if readErr != nil {
|
||||
t.Fatalf("read %s: %v", path, readErr)
|
||||
}
|
||||
content := string(raw)
|
||||
if strings.Contains(content, secret) {
|
||||
t.Fatalf("secret leaked in %s: %s", filepath.Base(path), content)
|
||||
}
|
||||
if !strings.Contains(content, "[REDACTED]") {
|
||||
t.Fatalf("redaction marker missing in %s: %s", filepath.Base(path), content)
|
||||
}
|
||||
if !json.Valid(raw) {
|
||||
t.Fatalf("invalid json in %s", filepath.Base(path))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func assertValidJSONFile(t *testing.T, path string) {
|
||||
t.Helper()
|
||||
raw, err := os.ReadFile(path)
|
||||
|
||||
Reference in New Issue
Block a user