aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils/users.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/utils/users.ts')
-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)