package gpaste_test import ( "math/rand" "testing" "git.t-juice.club/torjus/gpaste" ) func TestUser(t *testing.T) { t.Run("Password", func(t *testing.T) { userMap := make(map[string]string) for i := 0; i < 10; i++ { userMap[randomString(8)] = randomString(16) } for username, password := range userMap { user := &gpaste.User{Username: username} if err := user.SetPassword(password); err != nil { t.Fatalf("Error setting password: %s", err) } if err := user.ValidatePassword(password); err != nil { t.Fatalf("Error validating password: %s", err) } } }) } func randomString(length int) string { const charset = "abcdefghijklmnopqrstabcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" b := make([]byte, length) for i := range b { b[i] = charset[rand.Intn(len(charset))] } return string(b) }