aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-10-27 17:27:06 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-10-27 17:27:06 +0200
commit757f0da370a992cf07afd20d3829b2748c76cc15 (patch)
treedf093661b11be5d810e8853712774bf777946609 /server/tests/utils
parent954605a804da399317ca62afa2fb9244afa11ebf (diff)
downloadPeerTube-757f0da370a992cf07afd20d3829b2748c76cc15.tar.gz
PeerTube-757f0da370a992cf07afd20d3829b2748c76cc15.tar.zst
PeerTube-757f0da370a992cf07afd20d3829b2748c76cc15.zip
Add tests to user roles
Diffstat (limited to 'server/tests/utils')
-rw-r--r--server/tests/utils/users.ts16
1 files changed, 14 insertions, 2 deletions
diff --git a/server/tests/utils/users.ts b/server/tests/utils/users.ts
index e5f3eb1b3..12569dd42 100644
--- a/server/tests/utils/users.ts
+++ b/server/tests/utils/users.ts
@@ -1,10 +1,21 @@
1import * as request from 'supertest' 1import * as request from 'supertest'
2 2
3function createUser (url: string, accessToken: string, username: string, password: string, videoQuota = 1000000, specialStatus = 204) { 3import { UserRole } from '../../../shared'
4
5function createUser (
6 url: string,
7 accessToken: string,
8 username: string,
9 password: string,
10 videoQuota = 1000000,
11 role: UserRole = UserRole.USER,
12 specialStatus = 204
13) {
4 const path = '/api/v1/users' 14 const path = '/api/v1/users'
5 const body = { 15 const body = {
6 username, 16 username,
7 password, 17 password,
18 role,
8 email: username + '@example.com', 19 email: username + '@example.com',
9 videoQuota 20 videoQuota
10 } 21 }
@@ -114,12 +125,13 @@ function updateMyUser (url: string, accessToken: string, newPassword: string, di
114 .expect(204) 125 .expect(204)
115} 126}
116 127
117function updateUser (url: string, userId: number, accessToken: string, email: string, videoQuota: number) { 128function updateUser (url: string, userId: number, accessToken: string, email: string, videoQuota: number, role: UserRole) {
118 const path = '/api/v1/users/' + userId 129 const path = '/api/v1/users/' + userId
119 130
120 const toSend = {} 131 const toSend = {}
121 if (email !== undefined && email !== null) toSend['email'] = email 132 if (email !== undefined && email !== null) toSend['email'] = email
122 if (videoQuota !== undefined && videoQuota !== null) toSend['videoQuota'] = videoQuota 133 if (videoQuota !== undefined && videoQuota !== null) toSend['videoQuota'] = videoQuota
134 if (role !== undefined && role !== null) toSend['role'] = role
123 135
124 return request(url) 136 return request(url)
125 .put(path) 137 .put(path)