[MM-57942] Fix a panic on password is too long (#27449)
* return error from bcrypt, handle gracefully; remove dead code * linting * linting * i18n * fix test * fill out translations
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
5d2bf1ea1c
Коммит
cc5e87ae24
@@ -9,6 +9,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@@ -47,12 +49,19 @@ func TestUserDeepCopy(t *testing.T) {
|
||||
|
||||
func TestUserPreSave(t *testing.T) {
|
||||
user := User{Password: "test"}
|
||||
user.PreSave()
|
||||
err := user.PreSave()
|
||||
require.Nil(t, err)
|
||||
user.Etag(true, true)
|
||||
assert.NotNil(t, user.Timezone, "Timezone is nil")
|
||||
assert.Equal(t, user.Timezone["useAutomaticTimezone"], "true", "Timezone is not set to default")
|
||||
}
|
||||
|
||||
func TestUserPreSavePwdTooLong(t *testing.T) {
|
||||
user := User{Password: strings.Repeat("1234567890", 8)}
|
||||
err := user.PreSave()
|
||||
assert.ErrorIs(t, err, bcrypt.ErrPasswordTooLong)
|
||||
}
|
||||
|
||||
func TestUserPreUpdate(t *testing.T) {
|
||||
user := User{Password: "test"}
|
||||
user.PreUpdate()
|
||||
|
||||
Ссылка в новой задаче
Block a user