Add functionality to update password with password hash (#15343)

* Add functionality to update password with password hash

This can be used to update a user's password with a direct password
hash instead of providing the password in plaintext.

* Use test helper for local mode
Этот коммит содержится в:
Gabe Jackson
2020-08-26 11:28:00 -04:00
коммит произвёл GitHub
родитель e83462637e
Коммит 90ef61f74c
19 изменённых файлов: 243 добавлений и 137 удалений

Просмотреть файл

@@ -2806,6 +2806,29 @@ func TestUpdateUserPassword(t *testing.T) {
CheckNoError(t, resp)
}
func TestUpdateUserHashedPassword(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
client := th.Client
password := "SuperSecurePass23!"
passwordHash := "$2a$10$CiS1iWVPUj7rQNdY6XW53.DmaPLsETIvmW2p0asp4Dqpofs10UL5W"
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
pass, resp := client.UpdateUserHashedPassword(th.BasicUser.Id, passwordHash)
CheckNoError(t, resp)
require.True(t, pass)
})
_, resp := client.Login(th.BasicUser.Email, password)
CheckNoError(t, resp)
// Standard users should never be updating their passwords with already-
// hashed passwords.
pass, resp := client.UpdateUserHashedPassword(th.BasicUser.Id, passwordHash)
CheckUnauthorizedStatus(t, resp)
require.False(t, pass)
}
func TestResetPassword(t *testing.T) {
t.Skip("test disabled during old build server changes, should be investigated")