diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-15 10:02:54 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:18 +0200 |
commit | d23dd9fbfc4d26026352c10f81d2795ceaf2908a (patch) | |
tree | da82286d423c5e834a1ee2dcd5970076b8263cf1 /server/tests/api/check-params/videos.ts | |
parent | 7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0 (diff) | |
download | PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.tar.gz PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.tar.zst PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.zip |
Introduce videos command
Diffstat (limited to 'server/tests/api/check-params/videos.ts')
-rw-r--r-- | server/tests/api/check-params/videos.ts | 109 |
1 files changed, 51 insertions, 58 deletions
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts index 855b09f39..8f9f33b8c 100644 --- a/server/tests/api/check-params/videos.ts +++ b/server/tests/api/check-params/videos.ts | |||
@@ -4,30 +4,23 @@ import 'mocha' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { omit } from 'lodash' | 5 | import { omit } from 'lodash' |
6 | import { join } from 'path' | 6 | import { join } from 'path' |
7 | import { randomInt } from '@shared/core-utils' | 7 | import { HttpStatusCode, randomInt } from '@shared/core-utils' |
8 | import { PeerTubeProblemDocument, VideoCreateResult } from '@shared/models' | ||
9 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
10 | import { | 8 | import { |
9 | checkBadCountPagination, | ||
10 | checkBadSortPagination, | ||
11 | checkBadStartPagination, | ||
11 | checkUploadVideoParam, | 12 | checkUploadVideoParam, |
12 | cleanupTests, | 13 | cleanupTests, |
13 | flushAndRunServer, | 14 | flushAndRunServer, |
14 | getVideo, | ||
15 | getVideosList, | ||
16 | makeDeleteRequest, | 15 | makeDeleteRequest, |
17 | makeGetRequest, | 16 | makeGetRequest, |
18 | makePutBodyRequest, | 17 | makePutBodyRequest, |
19 | makeUploadRequest, | 18 | makeUploadRequest, |
20 | removeVideo, | ||
21 | root, | 19 | root, |
22 | ServerInfo, | 20 | ServerInfo, |
23 | setAccessTokensToServers | 21 | setAccessTokensToServers |
24 | } from '../../../../shared/extra-utils' | 22 | } from '@shared/extra-utils' |
25 | import { | 23 | import { PeerTubeProblemDocument, VideoCreateResult, VideoPrivacy } from '@shared/models' |
26 | checkBadCountPagination, | ||
27 | checkBadSortPagination, | ||
28 | checkBadStartPagination | ||
29 | } from '../../../../shared/extra-utils/requests/check-api-params' | ||
30 | import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' | ||
31 | 24 | ||
32 | const expect = chai.expect | 25 | const expect = chai.expect |
33 | 26 | ||
@@ -210,70 +203,70 @@ describe('Test videos API validator', function () { | |||
210 | it('Should fail with nothing', async function () { | 203 | it('Should fail with nothing', async function () { |
211 | const fields = {} | 204 | const fields = {} |
212 | const attaches = {} | 205 | const attaches = {} |
213 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 206 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
214 | }) | 207 | }) |
215 | 208 | ||
216 | it('Should fail without name', async function () { | 209 | it('Should fail without name', async function () { |
217 | const fields = omit(baseCorrectParams, 'name') | 210 | const fields = omit(baseCorrectParams, 'name') |
218 | const attaches = baseCorrectAttaches | 211 | const attaches = baseCorrectAttaches |
219 | 212 | ||
220 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 213 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
221 | }) | 214 | }) |
222 | 215 | ||
223 | it('Should fail with a long name', async function () { | 216 | it('Should fail with a long name', async function () { |
224 | const fields = { ...baseCorrectParams, name: 'super'.repeat(65) } | 217 | const fields = { ...baseCorrectParams, name: 'super'.repeat(65) } |
225 | const attaches = baseCorrectAttaches | 218 | const attaches = baseCorrectAttaches |
226 | 219 | ||
227 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 220 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
228 | }) | 221 | }) |
229 | 222 | ||
230 | it('Should fail with a bad category', async function () { | 223 | it('Should fail with a bad category', async function () { |
231 | const fields = { ...baseCorrectParams, category: 125 } | 224 | const fields = { ...baseCorrectParams, category: 125 } |
232 | const attaches = baseCorrectAttaches | 225 | const attaches = baseCorrectAttaches |
233 | 226 | ||
234 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 227 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
235 | }) | 228 | }) |
236 | 229 | ||
237 | it('Should fail with a bad licence', async function () { | 230 | it('Should fail with a bad licence', async function () { |
238 | const fields = { ...baseCorrectParams, licence: 125 } | 231 | const fields = { ...baseCorrectParams, licence: 125 } |
239 | const attaches = baseCorrectAttaches | 232 | const attaches = baseCorrectAttaches |
240 | 233 | ||
241 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 234 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
242 | }) | 235 | }) |
243 | 236 | ||
244 | it('Should fail with a bad language', async function () { | 237 | it('Should fail with a bad language', async function () { |
245 | const fields = { ...baseCorrectParams, language: 'a'.repeat(15) } | 238 | const fields = { ...baseCorrectParams, language: 'a'.repeat(15) } |
246 | const attaches = baseCorrectAttaches | 239 | const attaches = baseCorrectAttaches |
247 | 240 | ||
248 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 241 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
249 | }) | 242 | }) |
250 | 243 | ||
251 | it('Should fail with a long description', async function () { | 244 | it('Should fail with a long description', async function () { |
252 | const fields = { ...baseCorrectParams, description: 'super'.repeat(2500) } | 245 | const fields = { ...baseCorrectParams, description: 'super'.repeat(2500) } |
253 | const attaches = baseCorrectAttaches | 246 | const attaches = baseCorrectAttaches |
254 | 247 | ||
255 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 248 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
256 | }) | 249 | }) |
257 | 250 | ||
258 | it('Should fail with a long support text', async function () { | 251 | it('Should fail with a long support text', async function () { |
259 | const fields = { ...baseCorrectParams, support: 'super'.repeat(201) } | 252 | const fields = { ...baseCorrectParams, support: 'super'.repeat(201) } |
260 | const attaches = baseCorrectAttaches | 253 | const attaches = baseCorrectAttaches |
261 | 254 | ||
262 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 255 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
263 | }) | 256 | }) |
264 | 257 | ||
265 | it('Should fail without a channel', async function () { | 258 | it('Should fail without a channel', async function () { |
266 | const fields = omit(baseCorrectParams, 'channelId') | 259 | const fields = omit(baseCorrectParams, 'channelId') |
267 | const attaches = baseCorrectAttaches | 260 | const attaches = baseCorrectAttaches |
268 | 261 | ||
269 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 262 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
270 | }) | 263 | }) |
271 | 264 | ||
272 | it('Should fail with a bad channel', async function () { | 265 | it('Should fail with a bad channel', async function () { |
273 | const fields = { ...baseCorrectParams, channelId: 545454 } | 266 | const fields = { ...baseCorrectParams, channelId: 545454 } |
274 | const attaches = baseCorrectAttaches | 267 | const attaches = baseCorrectAttaches |
275 | 268 | ||
276 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 269 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
277 | }) | 270 | }) |
278 | 271 | ||
279 | it('Should fail with another user channel', async function () { | 272 | it('Should fail with another user channel', async function () { |
@@ -290,35 +283,35 @@ describe('Test videos API validator', function () { | |||
290 | const fields = { ...baseCorrectParams, channelId: customChannelId } | 283 | const fields = { ...baseCorrectParams, channelId: customChannelId } |
291 | const attaches = baseCorrectAttaches | 284 | const attaches = baseCorrectAttaches |
292 | 285 | ||
293 | await checkUploadVideoParam(server.url, userAccessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 286 | await checkUploadVideoParam(server, userAccessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
294 | }) | 287 | }) |
295 | 288 | ||
296 | it('Should fail with too many tags', async function () { | 289 | it('Should fail with too many tags', async function () { |
297 | const fields = { ...baseCorrectParams, tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] } | 290 | const fields = { ...baseCorrectParams, tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] } |
298 | const attaches = baseCorrectAttaches | 291 | const attaches = baseCorrectAttaches |
299 | 292 | ||
300 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 293 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
301 | }) | 294 | }) |
302 | 295 | ||
303 | it('Should fail with a tag length too low', async function () { | 296 | it('Should fail with a tag length too low', async function () { |
304 | const fields = { ...baseCorrectParams, tags: [ 'tag1', 't' ] } | 297 | const fields = { ...baseCorrectParams, tags: [ 'tag1', 't' ] } |
305 | const attaches = baseCorrectAttaches | 298 | const attaches = baseCorrectAttaches |
306 | 299 | ||
307 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 300 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
308 | }) | 301 | }) |
309 | 302 | ||
310 | it('Should fail with a tag length too big', async function () { | 303 | it('Should fail with a tag length too big', async function () { |
311 | const fields = { ...baseCorrectParams, tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] } | 304 | const fields = { ...baseCorrectParams, tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] } |
312 | const attaches = baseCorrectAttaches | 305 | const attaches = baseCorrectAttaches |
313 | 306 | ||
314 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 307 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
315 | }) | 308 | }) |
316 | 309 | ||
317 | it('Should fail with a bad schedule update (miss updateAt)', async function () { | 310 | it('Should fail with a bad schedule update (miss updateAt)', async function () { |
318 | const fields = { ...baseCorrectParams, scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } } | 311 | const fields = { ...baseCorrectParams, scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } } |
319 | const attaches = baseCorrectAttaches | 312 | const attaches = baseCorrectAttaches |
320 | 313 | ||
321 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 314 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
322 | }) | 315 | }) |
323 | 316 | ||
324 | it('Should fail with a bad schedule update (wrong updateAt)', async function () { | 317 | it('Should fail with a bad schedule update (wrong updateAt)', async function () { |
@@ -332,20 +325,20 @@ describe('Test videos API validator', function () { | |||
332 | } | 325 | } |
333 | const attaches = baseCorrectAttaches | 326 | const attaches = baseCorrectAttaches |
334 | 327 | ||
335 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 328 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
336 | }) | 329 | }) |
337 | 330 | ||
338 | it('Should fail with a bad originally published at attribute', async function () { | 331 | it('Should fail with a bad originally published at attribute', async function () { |
339 | const fields = { ...baseCorrectParams, originallyPublishedAt: 'toto' } | 332 | const fields = { ...baseCorrectParams, originallyPublishedAt: 'toto' } |
340 | const attaches = baseCorrectAttaches | 333 | const attaches = baseCorrectAttaches |
341 | 334 | ||
342 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 335 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
343 | }) | 336 | }) |
344 | 337 | ||
345 | it('Should fail without an input file', async function () { | 338 | it('Should fail without an input file', async function () { |
346 | const fields = baseCorrectParams | 339 | const fields = baseCorrectParams |
347 | const attaches = {} | 340 | const attaches = {} |
348 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 341 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
349 | }) | 342 | }) |
350 | 343 | ||
351 | it('Should fail with an incorrect input file', async function () { | 344 | it('Should fail with an incorrect input file', async function () { |
@@ -353,7 +346,7 @@ describe('Test videos API validator', function () { | |||
353 | let attaches = { fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short_fake.webm') } | 346 | let attaches = { fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short_fake.webm') } |
354 | 347 | ||
355 | await checkUploadVideoParam( | 348 | await checkUploadVideoParam( |
356 | server.url, | 349 | server, |
357 | server.accessToken, | 350 | server.accessToken, |
358 | { ...fields, ...attaches }, | 351 | { ...fields, ...attaches }, |
359 | HttpStatusCode.UNPROCESSABLE_ENTITY_422, | 352 | HttpStatusCode.UNPROCESSABLE_ENTITY_422, |
@@ -362,7 +355,7 @@ describe('Test videos API validator', function () { | |||
362 | 355 | ||
363 | attaches = { fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mkv') } | 356 | attaches = { fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mkv') } |
364 | await checkUploadVideoParam( | 357 | await checkUploadVideoParam( |
365 | server.url, | 358 | server, |
366 | server.accessToken, | 359 | server.accessToken, |
367 | { ...fields, ...attaches }, | 360 | { ...fields, ...attaches }, |
368 | HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415, | 361 | HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415, |
@@ -377,7 +370,7 @@ describe('Test videos API validator', function () { | |||
377 | fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') | 370 | fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') |
378 | } | 371 | } |
379 | 372 | ||
380 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 373 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
381 | }) | 374 | }) |
382 | 375 | ||
383 | it('Should fail with a big thumbnail file', async function () { | 376 | it('Should fail with a big thumbnail file', async function () { |
@@ -387,7 +380,7 @@ describe('Test videos API validator', function () { | |||
387 | fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') | 380 | fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') |
388 | } | 381 | } |
389 | 382 | ||
390 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 383 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
391 | }) | 384 | }) |
392 | 385 | ||
393 | it('Should fail with an incorrect preview file', async function () { | 386 | it('Should fail with an incorrect preview file', async function () { |
@@ -397,7 +390,7 @@ describe('Test videos API validator', function () { | |||
397 | fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') | 390 | fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') |
398 | } | 391 | } |
399 | 392 | ||
400 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 393 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
401 | }) | 394 | }) |
402 | 395 | ||
403 | it('Should fail with a big preview file', async function () { | 396 | it('Should fail with a big preview file', async function () { |
@@ -407,7 +400,7 @@ describe('Test videos API validator', function () { | |||
407 | fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') | 400 | fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') |
408 | } | 401 | } |
409 | 402 | ||
410 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 403 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
411 | }) | 404 | }) |
412 | 405 | ||
413 | it('Should report the appropriate error', async function () { | 406 | it('Should report the appropriate error', async function () { |
@@ -415,9 +408,9 @@ describe('Test videos API validator', function () { | |||
415 | const attaches = baseCorrectAttaches | 408 | const attaches = baseCorrectAttaches |
416 | 409 | ||
417 | const attributes = { ...fields, ...attaches } | 410 | const attributes = { ...fields, ...attaches } |
418 | const res = await checkUploadVideoParam(server.url, server.accessToken, attributes, HttpStatusCode.BAD_REQUEST_400, mode) | 411 | const body = await checkUploadVideoParam(server, server.accessToken, attributes, HttpStatusCode.BAD_REQUEST_400, mode) |
419 | 412 | ||
420 | const error = res.body as PeerTubeProblemDocument | 413 | const error = body as unknown as PeerTubeProblemDocument |
421 | 414 | ||
422 | if (mode === 'legacy') { | 415 | if (mode === 'legacy') { |
423 | expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/uploadLegacy') | 416 | expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/uploadLegacy') |
@@ -442,7 +435,7 @@ describe('Test videos API validator', function () { | |||
442 | 435 | ||
443 | { | 436 | { |
444 | const attaches = baseCorrectAttaches | 437 | const attaches = baseCorrectAttaches |
445 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode) | 438 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode) |
446 | } | 439 | } |
447 | 440 | ||
448 | { | 441 | { |
@@ -452,7 +445,7 @@ describe('Test videos API validator', function () { | |||
452 | videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') | 445 | videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') |
453 | } | 446 | } |
454 | 447 | ||
455 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode) | 448 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode) |
456 | } | 449 | } |
457 | 450 | ||
458 | { | 451 | { |
@@ -462,7 +455,7 @@ describe('Test videos API validator', function () { | |||
462 | videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.ogv') | 455 | videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.ogv') |
463 | } | 456 | } |
464 | 457 | ||
465 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode) | 458 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode) |
466 | } | 459 | } |
467 | }) | 460 | }) |
468 | } | 461 | } |
@@ -491,8 +484,8 @@ describe('Test videos API validator', function () { | |||
491 | } | 484 | } |
492 | 485 | ||
493 | before(async function () { | 486 | before(async function () { |
494 | const res = await getVideosList(server.url) | 487 | const { data } = await server.videosCommand.list() |
495 | video = res.body.data[0] | 488 | video = data[0] |
496 | }) | 489 | }) |
497 | 490 | ||
498 | it('Should fail with nothing', async function () { | 491 | it('Should fail with nothing', async function () { |
@@ -717,16 +710,16 @@ describe('Test videos API validator', function () { | |||
717 | }) | 710 | }) |
718 | 711 | ||
719 | it('Should fail without a correct uuid', async function () { | 712 | it('Should fail without a correct uuid', async function () { |
720 | await getVideo(server.url, 'coucou', HttpStatusCode.BAD_REQUEST_400) | 713 | await server.videosCommand.get({ id: 'coucou', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
721 | }) | 714 | }) |
722 | 715 | ||
723 | it('Should return 404 with an incorrect video', async function () { | 716 | it('Should return 404 with an incorrect video', async function () { |
724 | await getVideo(server.url, '4da6fde3-88f7-4d16-b119-108df5630b06', HttpStatusCode.NOT_FOUND_404) | 717 | await server.videosCommand.get({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 }) |
725 | }) | 718 | }) |
726 | 719 | ||
727 | it('Shoud report the appropriate error', async function () { | 720 | it('Shoud report the appropriate error', async function () { |
728 | const res = await getVideo(server.url, 'hi', HttpStatusCode.BAD_REQUEST_400) | 721 | const body = await server.videosCommand.get({ id: 'hi', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
729 | const error = res.body as PeerTubeProblemDocument | 722 | const error = body as unknown as PeerTubeProblemDocument |
730 | 723 | ||
731 | expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/getVideo') | 724 | expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/getVideo') |
732 | 725 | ||
@@ -741,16 +734,16 @@ describe('Test videos API validator', function () { | |||
741 | }) | 734 | }) |
742 | 735 | ||
743 | it('Should succeed with the correct parameters', async function () { | 736 | it('Should succeed with the correct parameters', async function () { |
744 | await getVideo(server.url, video.shortUUID) | 737 | await server.videosCommand.get({ id: video.shortUUID }) |
745 | }) | 738 | }) |
746 | }) | 739 | }) |
747 | 740 | ||
748 | describe('When rating a video', function () { | 741 | describe('When rating a video', function () { |
749 | let videoId | 742 | let videoId: number |
750 | 743 | ||
751 | before(async function () { | 744 | before(async function () { |
752 | const res = await getVideosList(server.url) | 745 | const { data } = await server.videosCommand.list() |
753 | videoId = res.body.data[0].id | 746 | videoId = data[0].id |
754 | }) | 747 | }) |
755 | 748 | ||
756 | it('Should fail without a valid uuid', async function () { | 749 | it('Should fail without a valid uuid', async function () { |
@@ -804,22 +797,22 @@ describe('Test videos API validator', function () { | |||
804 | }) | 797 | }) |
805 | 798 | ||
806 | it('Should fail without a correct uuid', async function () { | 799 | it('Should fail without a correct uuid', async function () { |
807 | await removeVideo(server.url, server.accessToken, 'hello', HttpStatusCode.BAD_REQUEST_400) | 800 | await server.videosCommand.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
808 | }) | 801 | }) |
809 | 802 | ||
810 | it('Should fail with a video which does not exist', async function () { | 803 | it('Should fail with a video which does not exist', async function () { |
811 | await removeVideo(server.url, server.accessToken, '4da6fde3-88f7-4d16-b119-108df5630b06', HttpStatusCode.NOT_FOUND_404) | 804 | await server.videosCommand.remove({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 }) |
812 | }) | 805 | }) |
813 | 806 | ||
814 | it('Should fail with a video of another user without the appropriate right', async function () { | 807 | it('Should fail with a video of another user without the appropriate right', async function () { |
815 | await removeVideo(server.url, userAccessToken, video.uuid, HttpStatusCode.FORBIDDEN_403) | 808 | await server.videosCommand.remove({ token: userAccessToken, id: video.uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
816 | }) | 809 | }) |
817 | 810 | ||
818 | it('Should fail with a video of another server') | 811 | it('Should fail with a video of another server') |
819 | 812 | ||
820 | it('Shoud report the appropriate error', async function () { | 813 | it('Shoud report the appropriate error', async function () { |
821 | const res = await removeVideo(server.url, server.accessToken, 'hello', HttpStatusCode.BAD_REQUEST_400) | 814 | const body = await server.videosCommand.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
822 | const error = res.body as PeerTubeProblemDocument | 815 | const error = body as unknown as PeerTubeProblemDocument |
823 | 816 | ||
824 | expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/delVideo') | 817 | expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/delVideo') |
825 | 818 | ||
@@ -834,7 +827,7 @@ describe('Test videos API validator', function () { | |||
834 | }) | 827 | }) |
835 | 828 | ||
836 | it('Should succeed with the correct parameters', async function () { | 829 | it('Should succeed with the correct parameters', async function () { |
837 | await removeVideo(server.url, server.accessToken, video.uuid) | 830 | await server.videosCommand.remove({ id: video.uuid }) |
838 | }) | 831 | }) |
839 | }) | 832 | }) |
840 | 833 | ||