Tryout go test fuzzing

This commit is contained in:
2022-09-01 03:59:18 +02:00
parent fce78d234d
commit 38ff8949b9
3 changed files with 40 additions and 0 deletions

View File

@@ -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)
}
})
}