Merge pull request #1486 from mxinden/staticcheck

config/test: Count `<secret>` occurrences via golang strings
This commit is contained in:
Max Inden 2018-07-30 09:41:51 +02:00 committed by GitHub
commit 4fff29c683
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -257,9 +257,7 @@ func TestHideConfigSecrets(t *testing.T) {
// String method must not reveal authentication credentials.
s := c.String()
secretRe := regexp.MustCompile("<secret>")
matches := secretRe.FindAllStringIndex(s, -1)
if len(matches) != 14 || strings.Contains(s, "mysecret") {
if strings.Count(s, "<secret>") != 14 || strings.Contains(s, "mysecret") {
t.Fatal("config's String method reveals authentication credentials.")
}
}