aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/users
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/users')
-rw-r--r--server/tests/api/users/users.ts31
1 files changed, 26 insertions, 5 deletions
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts
index c9e8eb6f9..77aa00f60 100644
--- a/server/tests/api/users/users.ts
+++ b/server/tests/api/users/users.ts
@@ -7,7 +7,7 @@ import {
7 createUser, flushTests, getBlacklistedVideosList, getMyUserInformation, getMyUserVideoQuotaUsed, getMyUserVideoRating, 7 createUser, flushTests, getBlacklistedVideosList, getMyUserInformation, getMyUserVideoQuotaUsed, getMyUserVideoRating,
8 getUserInformation, getUsersList, getUsersListPaginationAndSort, getVideosList, killallServers, login, makePutBodyRequest, rateVideo, 8 getUserInformation, getUsersList, getUsersListPaginationAndSort, getVideosList, killallServers, login, makePutBodyRequest, rateVideo,
9 registerUser, removeUser, removeVideo, runServer, ServerInfo, testImage, updateMyAvatar, updateMyUser, updateUser, uploadVideo, userLogin, 9 registerUser, removeUser, removeVideo, runServer, ServerInfo, testImage, updateMyAvatar, updateMyUser, updateUser, uploadVideo, userLogin,
10 deleteMe 10 deleteMe, blockUser, unblockUser
11} from '../../utils/index' 11} from '../../utils/index'
12import { follow } from '../../utils/server/follows' 12import { follow } from '../../utils/server/follows'
13import { setAccessTokensToServers } from '../../utils/users/login' 13import { setAccessTokensToServers } from '../../utils/users/login'
@@ -45,28 +45,28 @@ describe('Test users', function () {
45 const client = { id: 'client', secret: server.client.secret } 45 const client = { id: 'client', secret: server.client.secret }
46 const res = await login(server.url, client, server.user, 400) 46 const res = await login(server.url, client, server.user, 400)
47 47
48 expect(res.body.error).to.equal('Authentication failed.') 48 expect(res.body.error).to.contain('client is invalid')
49 }) 49 })
50 50
51 it('Should not login with an invalid client secret', async function () { 51 it('Should not login with an invalid client secret', async function () {
52 const client = { id: server.client.id, secret: 'coucou' } 52 const client = { id: server.client.id, secret: 'coucou' }
53 const res = await login(server.url, client, server.user, 400) 53 const res = await login(server.url, client, server.user, 400)
54 54
55 expect(res.body.error).to.equal('Authentication failed.') 55 expect(res.body.error).to.contain('client is invalid')
56 }) 56 })
57 57
58 it('Should not login with an invalid username', async function () { 58 it('Should not login with an invalid username', async function () {
59 const user = { username: 'captain crochet', password: server.user.password } 59 const user = { username: 'captain crochet', password: server.user.password }
60 const res = await login(server.url, server.client, user, 400) 60 const res = await login(server.url, server.client, user, 400)
61 61
62 expect(res.body.error).to.equal('Authentication failed.') 62 expect(res.body.error).to.contain('credentials are invalid')
63 }) 63 })
64 64
65 it('Should not login with an invalid password', async function () { 65 it('Should not login with an invalid password', async function () {
66 const user = { username: server.user.username, password: 'mew_three' } 66 const user = { username: server.user.username, password: 'mew_three' }
67 const res = await login(server.url, server.client, user, 400) 67 const res = await login(server.url, server.client, user, 400)
68 68
69 expect(res.body.error).to.equal('Authentication failed.') 69 expect(res.body.error).to.contain('credentials are invalid')
70 }) 70 })
71 71
72 it('Should not be able to upload a video', async function () { 72 it('Should not be able to upload a video', async function () {
@@ -493,6 +493,27 @@ describe('Test users', function () {
493 } 493 }
494 }) 494 })
495 495
496 it('Should block and unblock a user', async function () {
497 const user16 = {
498 username: 'user_16',
499 password: 'my super password'
500 }
501 const resUser = await createUser(server.url, server.accessToken, user16.username, user16.password)
502 const user16Id = resUser.body.user.id
503
504 accessToken = await userLogin(server, user16)
505
506 await getMyUserInformation(server.url, accessToken, 200)
507 await blockUser(server.url, user16Id, server.accessToken)
508
509 await getMyUserInformation(server.url, accessToken, 401)
510 await userLogin(server, user16, 400)
511
512 await unblockUser(server.url, user16Id, server.accessToken)
513 accessToken = await userLogin(server, user16)
514 await getMyUserInformation(server.url, accessToken, 200)
515 })
516
496 after(async function () { 517 after(async function () {
497 killallServers([ server ]) 518 killallServers([ server ])
498 519