diff --git a/service/pkg/util/redact.go b/service/pkg/util/redact.go index cb1ebbc06..6bebd5dc6 100644 --- a/service/pkg/util/redact.go +++ b/service/pkg/util/redact.go @@ -12,6 +12,7 @@ func RedactSensitiveData(i interface{}, sensitiveFields []string) interface{} { } func redact(v reflect.Value, sensitiveFields []string) reflect.Value { + //nolint:exhaustive switch v.Kind() { case reflect.Ptr: if v.IsNil() { diff --git a/service/pkg/util/redact_test.go b/service/pkg/util/redact_test.go index 4ad7b01fc..50f81faec 100644 --- a/service/pkg/util/redact_test.go +++ b/service/pkg/util/redact_test.go @@ -108,13 +108,16 @@ func TestRedactSensitiveData_WithSensitiveFieldsInNestedStruct(t *testing.T) { }` var config Config - json.Unmarshal([]byte(rawConfig), &config) + err := json.Unmarshal([]byte(rawConfig), &config) + if err != nil { + t.Fatalf("Failed to unmarshal rawConfig: %v", err) + } sensitiveFields := []string{"Password", "clientsecret"} redacted := RedactSensitiveData(config, sensitiveFields) - redactedConfig, ok := redacted.(Config) - if !ok { + redactedConfig, ok1 := redacted.(Config) + if !ok1 { t.Fatalf("Expected redacted data to be of type Config") } @@ -123,7 +126,7 @@ func TestRedactSensitiveData_WithSensitiveFieldsInNestedStruct(t *testing.T) { } for _, service := range redactedConfig.Services { - if clientSecret, ok := service.ExtraProps["clientsecret"]; ok && clientSecret != "REDACTED" { + if clientSecret, ok2 := service.ExtraProps["clientsecret"]; ok2 && clientSecret != "REDACTED" { t.Errorf("Expected Services.ExtraProps.ClientSecret to be redacted") } }