Simplify diagnostic report ownership
This commit is contained in:
@@ -393,3 +393,27 @@ func (b cancelOnCloseSmokeBody) Close() error {
|
||||
b.cancel()
|
||||
return b.ReadCloser.Close()
|
||||
}
|
||||
|
||||
func TestSmokeReportTargetOwnsProviderValuesAndRedactsCredentials(t *testing.T) {
|
||||
target := domain.SmokeTestTarget{
|
||||
Endpoint: "https://user:password@example.invalid/key",
|
||||
EffectiveSettings: domain.ExecutionTarget{
|
||||
Endpoint: "https://user:password@example.invalid/v1",
|
||||
APIKey: "secret",
|
||||
ExtraParams: map[string]any{"nested": map[string]any{"value": "original"}},
|
||||
},
|
||||
}
|
||||
got, err := smokeReportTarget(target)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got.EffectiveSettings.ExtraParams["nested"].(map[string]any)["value"] = "changed"
|
||||
if target.EffectiveSettings.ExtraParams["nested"].(map[string]any)["value"] != "original" ||
|
||||
got.EffectiveSettings.APIKey != "" || got.Endpoint != "https://example.invalid/key" || got.EffectiveSettings.Endpoint != "https://example.invalid/v1" {
|
||||
t.Fatalf("report target not detached or redacted: %+v", got)
|
||||
}
|
||||
target.EffectiveSettings.ExtraParams = map[string]any{"invalid": func() {}}
|
||||
if _, err := smokeReportTarget(target); err == nil {
|
||||
t.Fatal("invalid provider values were accepted")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user