Перенести пользователей в PostgreSQL и добавить пароли
This commit is contained in:
@@ -39,6 +39,28 @@ func TestNewValidatesUsername(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// The contract counts the password length in Unicode code points, not bytes.
|
||||
func TestValidatePasswordCountsCodePoints(t *testing.T) {
|
||||
valid := []string{
|
||||
strings.Repeat("я", 12),
|
||||
strings.Repeat("👋", 128),
|
||||
"pass:word:with:colons",
|
||||
" spaced but long enough ",
|
||||
}
|
||||
for _, p := range valid {
|
||||
if err := user.ValidatePassword(p); err != nil {
|
||||
t.Errorf("password of %d code points must be accepted: %v", len([]rune(p)), err)
|
||||
}
|
||||
}
|
||||
invalid := []string{"", strings.Repeat(" ", 12), strings.Repeat("\t", 20), strings.Repeat("я", 11), strings.Repeat("👋", 129)}
|
||||
for _, p := range invalid {
|
||||
err := user.ValidatePassword(p)
|
||||
if apperr.KindOf(err) != apperr.KindInvalid || !strings.Contains(err.Error(), "password") {
|
||||
t.Errorf("password %q must be rejected as invalid naming the field, got %v", p, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewValidatesDisplayNameByCodePoints(t *testing.T) {
|
||||
valid := []string{"A", "Алиса", strings.Repeat("я", 100), "👋 hi"}
|
||||
for _, name := range valid {
|
||||
|
||||
Reference in New Issue
Block a user