aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/config.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-21 15:51:30 +0200
committerChocobozzz <me@florianbigard.com>2021-07-21 15:51:30 +0200
commita24bd1ed41b43790bab6ba789580bb4e85f07d85 (patch)
treea54b0f6c921ba83a6e909cd0ced325b2d4b8863c /server/tests/api/check-params/config.ts
parent5f26f13b3c16ac5ae0a3b0a7142d84a9528cf565 (diff)
parentc63830f15403ac4e750829f27d8bbbdc9a59282c (diff)
downloadPeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.gz
PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.zst
PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.zip
Merge branch 'next' into develop
Diffstat (limited to 'server/tests/api/check-params/config.ts')
-rw-r--r--server/tests/api/check-params/config.ts65
1 files changed, 33 insertions, 32 deletions
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts
index 9549070ef..87cb2287e 100644
--- a/server/tests/api/check-params/config.ts
+++ b/server/tests/api/check-params/config.ts
@@ -1,26 +1,21 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import { omit } from 'lodash'
4import 'mocha' 3import 'mocha'
5import { CustomConfig } from '../../../../shared/models/server/custom-config.model' 4import { omit } from 'lodash'
6
7import { 5import {
8 cleanupTests, 6 cleanupTests,
9 createUser, 7 createSingleServer,
10 flushAndRunServer,
11 immutableAssign,
12 makeDeleteRequest, 8 makeDeleteRequest,
13 makeGetRequest, 9 makeGetRequest,
14 makePutBodyRequest, 10 makePutBodyRequest,
15 ServerInfo, 11 PeerTubeServer,
16 setAccessTokensToServers, 12 setAccessTokensToServers
17 userLogin 13} from '@shared/extra-utils'
18} from '../../../../shared/extra-utils' 14import { CustomConfig, HttpStatusCode } from '@shared/models'
19import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
20 15
21describe('Test config API validators', function () { 16describe('Test config API validators', function () {
22 const path = '/api/v1/config/custom' 17 const path = '/api/v1/config/custom'
23 let server: ServerInfo 18 let server: PeerTubeServer
24 let userAccessToken: string 19 let userAccessToken: string
25 const updateParams: CustomConfig = { 20 const updateParams: CustomConfig = {
26 instance: { 21 instance: {
@@ -201,7 +196,7 @@ describe('Test config API validators', function () {
201 before(async function () { 196 before(async function () {
202 this.timeout(30000) 197 this.timeout(30000)
203 198
204 server = await flushAndRunServer(1) 199 server = await createSingleServer(1)
205 200
206 await setAccessTokensToServers([ server ]) 201 await setAccessTokensToServers([ server ])
207 202
@@ -209,8 +204,8 @@ describe('Test config API validators', function () {
209 username: 'user1', 204 username: 'user1',
210 password: 'password' 205 password: 'password'
211 } 206 }
212 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) 207 await server.users.create({ username: user.username, password: user.password })
213 userAccessToken = await userLogin(server, user) 208 userAccessToken = await server.login.getAccessToken(user)
214 }) 209 })
215 210
216 describe('When getting the configuration', function () { 211 describe('When getting the configuration', function () {
@@ -218,7 +213,7 @@ describe('Test config API validators', function () {
218 await makeGetRequest({ 213 await makeGetRequest({
219 url: server.url, 214 url: server.url,
220 path, 215 path,
221 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 216 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
222 }) 217 })
223 }) 218 })
224 219
@@ -227,7 +222,7 @@ describe('Test config API validators', function () {
227 url: server.url, 222 url: server.url,
228 path, 223 path,
229 token: userAccessToken, 224 token: userAccessToken,
230 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 225 expectedStatus: HttpStatusCode.FORBIDDEN_403
231 }) 226 })
232 }) 227 })
233 }) 228 })
@@ -238,7 +233,7 @@ describe('Test config API validators', function () {
238 url: server.url, 233 url: server.url,
239 path, 234 path,
240 fields: updateParams, 235 fields: updateParams,
241 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 236 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
242 }) 237 })
243 }) 238 })
244 239
@@ -248,7 +243,7 @@ describe('Test config API validators', function () {
248 path, 243 path,
249 fields: updateParams, 244 fields: updateParams,
250 token: userAccessToken, 245 token: userAccessToken,
251 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 246 expectedStatus: HttpStatusCode.FORBIDDEN_403
252 }) 247 })
253 }) 248 })
254 249
@@ -260,47 +255,53 @@ describe('Test config API validators', function () {
260 path, 255 path,
261 fields: newUpdateParams, 256 fields: newUpdateParams,
262 token: server.accessToken, 257 token: server.accessToken,
263 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 258 expectedStatus: HttpStatusCode.BAD_REQUEST_400
264 }) 259 })
265 }) 260 })
266 261
267 it('Should fail with a bad default NSFW policy', async function () { 262 it('Should fail with a bad default NSFW policy', async function () {
268 const newUpdateParams = immutableAssign(updateParams, { 263 const newUpdateParams = {
264 ...updateParams,
265
269 instance: { 266 instance: {
270 defaultNSFWPolicy: 'hello' 267 defaultNSFWPolicy: 'hello'
271 } 268 }
272 }) 269 }
273 270
274 await makePutBodyRequest({ 271 await makePutBodyRequest({
275 url: server.url, 272 url: server.url,
276 path, 273 path,
277 fields: newUpdateParams, 274 fields: newUpdateParams,
278 token: server.accessToken, 275 token: server.accessToken,
279 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 276 expectedStatus: HttpStatusCode.BAD_REQUEST_400
280 }) 277 })
281 }) 278 })
282 279
283 it('Should fail if email disabled and signup requires email verification', async function () { 280 it('Should fail if email disabled and signup requires email verification', async function () {
284 // opposite scenario - success when enable enabled - covered via tests/api/users/user-verification.ts 281 // opposite scenario - success when enable enabled - covered via tests/api/users/user-verification.ts
285 const newUpdateParams = immutableAssign(updateParams, { 282 const newUpdateParams = {
283 ...updateParams,
284
286 signup: { 285 signup: {
287 enabled: true, 286 enabled: true,
288 limit: 5, 287 limit: 5,
289 requiresEmailVerification: true 288 requiresEmailVerification: true
290 } 289 }
291 }) 290 }
292 291
293 await makePutBodyRequest({ 292 await makePutBodyRequest({
294 url: server.url, 293 url: server.url,
295 path, 294 path,
296 fields: newUpdateParams, 295 fields: newUpdateParams,
297 token: server.accessToken, 296 token: server.accessToken,
298 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 297 expectedStatus: HttpStatusCode.BAD_REQUEST_400
299 }) 298 })
300 }) 299 })
301 300
302 it('Should fail with a disabled webtorrent & hls transcoding', async function () { 301 it('Should fail with a disabled webtorrent & hls transcoding', async function () {
303 const newUpdateParams = immutableAssign(updateParams, { 302 const newUpdateParams = {
303 ...updateParams,
304
304 transcoding: { 305 transcoding: {
305 hls: { 306 hls: {
306 enabled: false 307 enabled: false
@@ -309,14 +310,14 @@ describe('Test config API validators', function () {
309 enabled: false 310 enabled: false
310 } 311 }
311 } 312 }
312 }) 313 }
313 314
314 await makePutBodyRequest({ 315 await makePutBodyRequest({
315 url: server.url, 316 url: server.url,
316 path, 317 path,
317 fields: newUpdateParams, 318 fields: newUpdateParams,
318 token: server.accessToken, 319 token: server.accessToken,
319 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 320 expectedStatus: HttpStatusCode.BAD_REQUEST_400
320 }) 321 })
321 }) 322 })
322 323
@@ -326,7 +327,7 @@ describe('Test config API validators', function () {
326 path, 327 path,
327 fields: updateParams, 328 fields: updateParams,
328 token: server.accessToken, 329 token: server.accessToken,
329 statusCodeExpected: HttpStatusCode.OK_200 330 expectedStatus: HttpStatusCode.OK_200
330 }) 331 })
331 }) 332 })
332 }) 333 })
@@ -336,7 +337,7 @@ describe('Test config API validators', function () {
336 await makeDeleteRequest({ 337 await makeDeleteRequest({
337 url: server.url, 338 url: server.url,
338 path, 339 path,
339 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 340 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
340 }) 341 })
341 }) 342 })
342 343
@@ -345,7 +346,7 @@ describe('Test config API validators', function () {
345 url: server.url, 346 url: server.url,
346 path, 347 path,
347 token: userAccessToken, 348 token: userAccessToken,
348 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 349 expectedStatus: HttpStatusCode.FORBIDDEN_403
349 }) 350 })
350 }) 351 })
351 }) 352 })