diff --git a/rules/hardcoded_credentials_test.go b/rules/hardcoded_credentials_test.go index 3999d7f..966ee10 100644 --- a/rules/hardcoded_credentials_test.go +++ b/rules/hardcoded_credentials_test.go @@ -120,11 +120,27 @@ func TestHardcodedConstInteger(t *testing.T) { package main const ( - ATNStateSomethingElse = 1, - ATNStateTokenStart = 42, + ATNStateSomethingElse = 1 + ATNStateTokenStart = 42 ) func main() { println(ATNStateTokenStart) }`, analyzer) checkTestResults(t, issues, 0, "Potential hardcoded credentials") } + +func TestHardcodedConstString(t *testing.T) { + config := map[string]interface{}{"ignoreNosec": false} + analyzer := gas.NewAnalyzer(config, nil) + analyzer.AddRule(NewHardcodedCredentials(config)) + issues := gasTestRunner(` + package main + + const ( + ATNStateTokenStart = "foo bar" + ) + func main() { + println(ATNStateTokenStart) + }`, analyzer) + checkTestResults(t, issues, 1, "Potential hardcoded credentials") +}