From 338f3a5f37fa49eb8fc30c4e83d4a2dc08e758aa Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Thu, 11 Jan 2024 12:57:14 +0100 Subject: [PATCH 1/2] [TEST] See if contrib tests break with a panic on configopaque fmt.Stringer impl --- config/configopaque/opaque.go | 2 +- config/configopaque/opaque_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/configopaque/opaque.go b/config/configopaque/opaque.go index f66c2829bb0..0331c6b5b9c 100644 --- a/config/configopaque/opaque.go +++ b/config/configopaque/opaque.go @@ -23,5 +23,5 @@ func (s String) MarshalText() ([]byte, error) { } func (s String) String() string { - return maskedString + panic("testing if this is called somewhere else") } diff --git a/config/configopaque/opaque_test.go b/config/configopaque/opaque_test.go index 49aa3d6763a..3dafa6f9872 100644 --- a/config/configopaque/opaque_test.go +++ b/config/configopaque/opaque_test.go @@ -24,7 +24,7 @@ func TestStringFmt(t *testing.T) { examples := []String{"opaque", "s", "veryveryveryveryveryveryveryveryveryverylong"} for _, example := range examples { // nolint S1025 - assert.Equal(t, "[REDACTED]", fmt.Sprintf("%s", example)) + assert.Panics(t, func() { fmt.Sprintf("%s", example) }) // converting to a string allows to output as an unredacted string still: // nolint S1025 assert.Equal(t, string(example), fmt.Sprintf("%s", string(example))) From 13dc5bafe6aea5eecadf1bacc701e954aca00fc1 Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Thu, 11 Jan 2024 14:28:36 +0100 Subject: [PATCH 2/2] Run panic on separate goroutine to prevent recovery --- config/configopaque/opaque.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/configopaque/opaque.go b/config/configopaque/opaque.go index 0331c6b5b9c..2b68a189f50 100644 --- a/config/configopaque/opaque.go +++ b/config/configopaque/opaque.go @@ -23,5 +23,6 @@ func (s String) MarshalText() ([]byte, error) { } func (s String) String() string { - panic("testing if this is called somewhere else") + go func() { panic("testing if this is called somewhere else") }() + return maskedString }