diff --git a/internal/cmd/scraper/scraper_test.go b/internal/cmd/scraper/scraper_test.go index 5caddb5d..b979e91d 100644 --- a/internal/cmd/scraper/scraper_test.go +++ b/internal/cmd/scraper/scraper_test.go @@ -4,10 +4,12 @@ package scraper import ( + "bytes" "fmt" "strings" "testing" + "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" ) @@ -41,3 +43,26 @@ func TestLicenseKeyMasking(t *testing.T) { assert.Equal(t, licenseKeyString, unmasked) }) } + +func TestLogrusDebugPrintMasksLicenseKey(t *testing.T) { + + const licenseKey = "SECRET_LICENSE_KEY" + + cfg := Config{ + LicenseKey: licenseKey, + } + + var b bytes.Buffer + + logrus.SetOutput(&b) + logrus.SetLevel(logrus.DebugLevel) + logrus.Debugf("Config: %#v", cfg) + + msg := b.String() + if strings.Contains(msg, licenseKey) { + t.Error("Log output contains the license key") + } + if !strings.Contains(msg, maskedLicenseKey) { + t.Error("Log output does not contain the masked licenseKey") + } +}