From b426edd4854adc6e65844d8c54b8998e792b5778 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 11 Feb 2019 09:30:29 +0100 Subject: Cleanup reset user password by admin And add some tests --- server/tests/api/check-params/users.ts | 18 ++++++++++++++++++ server/tests/api/users/users.ts | 16 ++++++++++++++++ 2 files changed, 34 insertions(+) (limited to 'server/tests') diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index a3e8e2e9c..13be8b460 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts @@ -464,6 +464,24 @@ describe('Test users API validators', function () { await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields }) }) + it('Should fail with a too small password', async function () { + const fields = { + currentPassword: 'my super password', + password: 'bla' + } + + await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields }) + }) + + it('Should fail with a too long password', async function () { + const fields = { + currentPassword: 'my super password', + password: 'super'.repeat(61) + } + + await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields }) + }) + it('Should fail with an non authenticated user', async function () { const fields = { videoQuota: 42 diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts index ad98ab1c7..c4465d541 100644 --- a/server/tests/api/users/users.ts +++ b/server/tests/api/users/users.ts @@ -501,6 +501,22 @@ describe('Test users', function () { accessTokenUser = await userLogin(server, user) }) + it('Should be able to update another user password', async function () { + await updateUser({ + url: server.url, + userId, + accessToken, + password: 'password updated' + }) + + await getMyUserVideoQuotaUsed(server.url, accessTokenUser, 401) + + await userLogin(server, user, 400) + + user.password = 'password updated' + accessTokenUser = await userLogin(server, user) + }) + it('Should be able to list video blacklist by a moderator', async function () { await getBlacklistedVideosList(server.url, accessTokenUser) }) -- cgit v1.2.3