Перенести пользователей в PostgreSQL и добавить пароли

This commit is contained in:
2026-10-06 14:54:34 +03:00
parent 46c00436a0
commit 618d3919d1
17 changed files with 482 additions and 219 deletions
+22
View File
@@ -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 {