MM-14039 Improving password lockout functionality. (#10254)
* Improving password lockout functionality. * Switching order of mfa password checks to passowrd -> mfa
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
3a71709103
Коммит
9cfcab2307
@@ -1124,7 +1124,7 @@ func TestPatchUser(t *testing.T) {
|
||||
if ruser.Username != user.Username {
|
||||
t.Fatal("Username should not have updated")
|
||||
}
|
||||
if ruser.Password != ""{
|
||||
if ruser.Password != "" {
|
||||
t.Fatal("Password should not be returned")
|
||||
}
|
||||
if ruser.NotifyProps["comment"] != "somethingrandom" {
|
||||
@@ -3100,3 +3100,40 @@ func TestGetUserTermsOfService(t *testing.T) {
|
||||
assert.Equal(t, termsOfService.Id, userTermsOfService.TermsOfServiceId)
|
||||
assert.NotEmpty(t, userTermsOfService.CreateAt)
|
||||
}
|
||||
|
||||
func TestLoginLockout(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
_, resp := th.Client.Logout()
|
||||
CheckNoError(t, resp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.MaximumLoginAttempts = 3 })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableMultifactorAuthentication = true })
|
||||
|
||||
_, resp = th.Client.Login(th.BasicUser.Email, "wrong")
|
||||
CheckErrorMessage(t, resp, "api.user.check_user_password.invalid.app_error")
|
||||
_, resp = th.Client.Login(th.BasicUser.Email, "wrong")
|
||||
CheckErrorMessage(t, resp, "api.user.check_user_password.invalid.app_error")
|
||||
_, resp = th.Client.Login(th.BasicUser.Email, "wrong")
|
||||
CheckErrorMessage(t, resp, "api.user.check_user_password.invalid.app_error")
|
||||
_, resp = th.Client.Login(th.BasicUser.Email, "wrong")
|
||||
CheckErrorMessage(t, resp, "api.user.check_user_login_attempts.too_many.app_error")
|
||||
_, resp = th.Client.Login(th.BasicUser.Email, "wrong")
|
||||
CheckErrorMessage(t, resp, "api.user.check_user_login_attempts.too_many.app_error")
|
||||
|
||||
// Fake user has MFA enabled
|
||||
if result := <-th.Server.Store.User().UpdateMfaActive(th.BasicUser2.Id, true); result.Err != nil {
|
||||
t.Fatal(result.Err)
|
||||
}
|
||||
_, resp = th.Client.LoginWithMFA(th.BasicUser2.Email, th.BasicUser2.Password, "000000")
|
||||
CheckErrorMessage(t, resp, "api.user.check_user_mfa.bad_code.app_error")
|
||||
_, resp = th.Client.LoginWithMFA(th.BasicUser2.Email, th.BasicUser2.Password, "000000")
|
||||
CheckErrorMessage(t, resp, "api.user.check_user_mfa.bad_code.app_error")
|
||||
_, resp = th.Client.LoginWithMFA(th.BasicUser2.Email, th.BasicUser2.Password, "000000")
|
||||
CheckErrorMessage(t, resp, "api.user.check_user_mfa.bad_code.app_error")
|
||||
_, resp = th.Client.LoginWithMFA(th.BasicUser2.Email, th.BasicUser2.Password, "000000")
|
||||
CheckErrorMessage(t, resp, "api.user.check_user_login_attempts.too_many.app_error")
|
||||
_, resp = th.Client.LoginWithMFA(th.BasicUser2.Email, th.BasicUser2.Password, "000000")
|
||||
CheckErrorMessage(t, resp, "api.user.check_user_login_attempts.too_many.app_error")
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user