aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/users/users.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-23 09:15:36 +0100
committerChocobozzz <me@florianbigard.com>2018-01-23 09:49:57 +0100
commitf8b8c36b2a92bfee435747ab5a0283924be76281 (patch)
tree99e17a5c9413614071ae63d72e9b9557fc8cef43 /server/tests/api/users/users.ts
parent59c48d49c5f06a46c342b4e7f86fbd1ed9894bd6 (diff)
downloadPeerTube-f8b8c36b2a92bfee435747ab5a0283924be76281.tar.gz
PeerTube-f8b8c36b2a92bfee435747ab5a0283924be76281.tar.zst
PeerTube-f8b8c36b2a92bfee435747ab5a0283924be76281.zip
Destroy user token when changing its role
Diffstat (limited to 'server/tests/api/users/users.ts')
-rw-r--r--server/tests/api/users/users.ts37
1 files changed, 20 insertions, 17 deletions
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts
index 6bb5fd698..c23b58089 100644
--- a/server/tests/api/users/users.ts
+++ b/server/tests/api/users/users.ts
@@ -4,10 +4,9 @@ import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { UserRole } from '../../../../shared/index' 5import { UserRole } from '../../../../shared/index'
6import { 6import {
7 createUser, flushTests, getBlacklistedVideosList, getMyUserInformation, getMyUserVideoQuotaUsed, getMyUserVideoRating, getUserInformation, 7 createUser, flushTests, getBlacklistedVideosList, getMyUserInformation, getMyUserVideoQuotaUsed, getMyUserVideoRating,
8 getUsersList, 8 getUserInformation, getUsersList, getUsersListPaginationAndSort, getVideosList, killallServers, login, makePutBodyRequest, rateVideo,
9 getUsersListPaginationAndSort, getVideosList, killallServers, login, makePutBodyRequest, rateVideo, registerUser, removeUser, removeVideo, 9 registerUser, removeUser, removeVideo, runServer, ServerInfo, testImage, updateMyAvatar, updateMyUser, updateUser, uploadVideo, userLogin
10 runServer, ServerInfo, serverLogin, testImage, updateMyAvatar, updateMyUser, updateUser, uploadVideo
11} from '../../utils/index' 10} from '../../utils/index'
12import { follow } from '../../utils/server/follows' 11import { follow } from '../../utils/server/follows'
13import { setAccessTokensToServers } from '../../utils/users/login' 12import { setAccessTokensToServers } from '../../utils/users/login'
@@ -21,6 +20,10 @@ describe('Test users', function () {
21 let accessTokenUser: string 20 let accessTokenUser: string
22 let videoId: number 21 let videoId: number
23 let userId: number 22 let userId: number
23 const user = {
24 username: 'user_1',
25 password: 'super password'
26 }
24 27
25 before(async function () { 28 before(async function () {
26 this.timeout(30000) 29 this.timeout(30000)
@@ -152,16 +155,11 @@ describe('Test users', function () {
152 it('Should be able to upload a video again') 155 it('Should be able to upload a video again')
153 156
154 it('Should be able to create a new user', async function () { 157 it('Should be able to create a new user', async function () {
155 await createUser(server.url, accessToken, 'user_1', 'super password', 2 * 1024 * 1024) 158 await createUser(server.url, accessToken, user.username,user.password, 2 * 1024 * 1024)
156 }) 159 })
157 160
158 it('Should be able to login with this user', async function () { 161 it('Should be able to login with this user', async function () {
159 server.user = { 162 accessTokenUser = await userLogin(server, user)
160 username: 'user_1',
161 password: 'super password'
162 }
163
164 accessTokenUser = await serverLogin(server)
165 }) 163 })
166 164
167 it('Should be able to get the user information', async function () { 165 it('Should be able to get the user information', async function () {
@@ -297,9 +295,9 @@ describe('Test users', function () {
297 accessToken: accessTokenUser, 295 accessToken: accessTokenUser,
298 newPassword: 'new password' 296 newPassword: 'new password'
299 }) 297 })
300 server.user.password = 'new password' 298 user.password = 'new password'
301 299
302 await login(server.url, server.client, server.user, 200) 300 await userLogin(server, user, 200)
303 }) 301 })
304 302
305 it('Should be able to change the NSFW display attribute', async function () { 303 it('Should be able to change the NSFW display attribute', async function () {
@@ -386,6 +384,12 @@ describe('Test users', function () {
386 expect(user.id).to.be.a('number') 384 expect(user.id).to.be.a('number')
387 }) 385 })
388 386
387 it('Should have removed the user token', async function () {
388 await getMyUserVideoQuotaUsed(server.url, accessTokenUser, 401)
389
390 accessTokenUser = await userLogin(server, user)
391 })
392
389 it('Should not be able to delete a user by a moderator', async function () { 393 it('Should not be able to delete a user by a moderator', async function () {
390 await removeUser(server.url, 2, accessTokenUser, 403) 394 await removeUser(server.url, 2, accessTokenUser, 403)
391 }) 395 })
@@ -399,8 +403,7 @@ describe('Test users', function () {
399 }) 403 })
400 404
401 it('Should not be able to login with this user', async function () { 405 it('Should not be able to login with this user', async function () {
402 // server.user is already set to user 1 406 await userLogin(server, user, 400)
403 await login(server.url, server.client, server.user, 400)
404 }) 407 })
405 408
406 it('Should not have videos of this user', async function () { 409 it('Should not have videos of this user', async function () {
@@ -417,12 +420,12 @@ describe('Test users', function () {
417 }) 420 })
418 421
419 it('Should be able to login with this registered user', async function () { 422 it('Should be able to login with this registered user', async function () {
420 server.user = { 423 const user15 = {
421 username: 'user_15', 424 username: 'user_15',
422 password: 'my super password' 425 password: 'my super password'
423 } 426 }
424 427
425 accessToken = await serverLogin(server) 428 accessToken = await userLogin(server, user15)
426 }) 429 })
427 430
428 it('Should have the correct video quota', async function () { 431 it('Should have the correct video quota', async function () {