[MM-29296] model/user: add lock to source (#16054)
* model/user: add lock to source * guard rand creation with locking * use locked random * remove assignment Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
50e29cb47a
Коммит
b30acfdee6
@@ -353,7 +353,9 @@ func TestUserSlice(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGeneratePassword(t *testing.T) {
|
||||
passwordRandomSource = rand.NewSource(12345)
|
||||
passwordRandom = lockedRand{
|
||||
rn: rand.New(rand.NewSource(12345)),
|
||||
}
|
||||
|
||||
t.Run("Should be the minimum length or 4, whichever is less", func(t *testing.T) {
|
||||
password1 := GeneratePassword(5)
|
||||
@@ -372,4 +374,10 @@ func TestGeneratePassword(t *testing.T) {
|
||||
assert.Contains(t, []rune(passwordLowerCaseLetters), []rune(password)[2])
|
||||
assert.Contains(t, []rune(passwordSpecialChars), []rune(password)[3])
|
||||
})
|
||||
|
||||
t.Run("Should not fail on concurrent calls", func(t *testing.T) {
|
||||
for i := 0; i < 10; i++ {
|
||||
go GeneratePassword(10)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user