Skip to content

Commit

Permalink
Fix test case (invalid sample code)
Browse files Browse the repository at this point in the history
  • Loading branch information
gcmurphy committed Jan 11, 2017
1 parent d1e67fc commit 1e736c8
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions rules/hardcoded_credentials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

0 comments on commit 1e736c8

Please sign in to comment.