Tryout go test fuzzing
This commit is contained in:
@@ -323,3 +323,22 @@ func equalAttempts(a, b []models.LoginAttempt) bool {
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func fuzzLoginAttemptStore(s store.LoginAttemptStore, f *testing.F) {
|
||||
usernames := []string{"username", "root", "ubnt", "pi", "admin"}
|
||||
for _, username := range usernames {
|
||||
f.Add(username)
|
||||
}
|
||||
f.Fuzz(func(t *testing.T, orig string) {
|
||||
attempt := models.LoginAttempt{
|
||||
Date: time.Now(),
|
||||
Username: orig,
|
||||
Password: randomString(8),
|
||||
Country: "NO",
|
||||
}
|
||||
|
||||
if err := s.AddAttempt(&attempt); err != nil {
|
||||
t.Fatalf("error adding: %s", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user