diff options
Diffstat (limited to 'server/tests/api/check-params/videos.ts')
-rw-r--r-- | server/tests/api/check-params/videos.ts | 75 |
1 files changed, 40 insertions, 35 deletions
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts index 4d7a9a23b..6549063b1 100644 --- a/server/tests/api/check-params/videos.ts +++ b/server/tests/api/check-params/videos.ts | |||
@@ -15,7 +15,6 @@ import { | |||
15 | getMyUserInformation, | 15 | getMyUserInformation, |
16 | getVideo, | 16 | getVideo, |
17 | getVideosList, | 17 | getVideosList, |
18 | immutableAssign, | ||
19 | makeDeleteRequest, | 18 | makeDeleteRequest, |
20 | makeGetRequest, | 19 | makeGetRequest, |
21 | makePutBodyRequest, | 20 | makePutBodyRequest, |
@@ -225,42 +224,42 @@ describe('Test videos API validator', function () { | |||
225 | }) | 224 | }) |
226 | 225 | ||
227 | it('Should fail with a long name', async function () { | 226 | it('Should fail with a long name', async function () { |
228 | const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) }) | 227 | const fields = { ...baseCorrectParams, name: 'super'.repeat(65) } |
229 | const attaches = baseCorrectAttaches | 228 | const attaches = baseCorrectAttaches |
230 | 229 | ||
231 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 230 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
232 | }) | 231 | }) |
233 | 232 | ||
234 | it('Should fail with a bad category', async function () { | 233 | it('Should fail with a bad category', async function () { |
235 | const fields = immutableAssign(baseCorrectParams, { category: 125 }) | 234 | const fields = { ...baseCorrectParams, category: 125 } |
236 | const attaches = baseCorrectAttaches | 235 | const attaches = baseCorrectAttaches |
237 | 236 | ||
238 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 237 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
239 | }) | 238 | }) |
240 | 239 | ||
241 | it('Should fail with a bad licence', async function () { | 240 | it('Should fail with a bad licence', async function () { |
242 | const fields = immutableAssign(baseCorrectParams, { licence: 125 }) | 241 | const fields = { ...baseCorrectParams, licence: 125 } |
243 | const attaches = baseCorrectAttaches | 242 | const attaches = baseCorrectAttaches |
244 | 243 | ||
245 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 244 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
246 | }) | 245 | }) |
247 | 246 | ||
248 | it('Should fail with a bad language', async function () { | 247 | it('Should fail with a bad language', async function () { |
249 | const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) }) | 248 | const fields = { ...baseCorrectParams, language: 'a'.repeat(15) } |
250 | const attaches = baseCorrectAttaches | 249 | const attaches = baseCorrectAttaches |
251 | 250 | ||
252 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 251 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
253 | }) | 252 | }) |
254 | 253 | ||
255 | it('Should fail with a long description', async function () { | 254 | it('Should fail with a long description', async function () { |
256 | const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) }) | 255 | const fields = { ...baseCorrectParams, description: 'super'.repeat(2500) } |
257 | const attaches = baseCorrectAttaches | 256 | const attaches = baseCorrectAttaches |
258 | 257 | ||
259 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 258 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
260 | }) | 259 | }) |
261 | 260 | ||
262 | it('Should fail with a long support text', async function () { | 261 | it('Should fail with a long support text', async function () { |
263 | const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) }) | 262 | const fields = { ...baseCorrectParams, support: 'super'.repeat(201) } |
264 | const attaches = baseCorrectAttaches | 263 | const attaches = baseCorrectAttaches |
265 | 264 | ||
266 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 265 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
@@ -274,7 +273,7 @@ describe('Test videos API validator', function () { | |||
274 | }) | 273 | }) |
275 | 274 | ||
276 | it('Should fail with a bad channel', async function () { | 275 | it('Should fail with a bad channel', async function () { |
277 | const fields = immutableAssign(baseCorrectParams, { channelId: 545454 }) | 276 | const fields = { ...baseCorrectParams, channelId: 545454 } |
278 | const attaches = baseCorrectAttaches | 277 | const attaches = baseCorrectAttaches |
279 | 278 | ||
280 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 279 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
@@ -291,54 +290,56 @@ describe('Test videos API validator', function () { | |||
291 | const res = await getMyUserInformation(server.url, accessTokenUser) | 290 | const res = await getMyUserInformation(server.url, accessTokenUser) |
292 | const customChannelId = res.body.videoChannels[0].id | 291 | const customChannelId = res.body.videoChannels[0].id |
293 | 292 | ||
294 | const fields = immutableAssign(baseCorrectParams, { channelId: customChannelId }) | 293 | const fields = { ...baseCorrectParams, channelId: customChannelId } |
295 | const attaches = baseCorrectAttaches | 294 | const attaches = baseCorrectAttaches |
296 | 295 | ||
297 | await checkUploadVideoParam(server.url, userAccessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 296 | await checkUploadVideoParam(server.url, userAccessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
298 | }) | 297 | }) |
299 | 298 | ||
300 | it('Should fail with too many tags', async function () { | 299 | it('Should fail with too many tags', async function () { |
301 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }) | 300 | const fields = { ...baseCorrectParams, tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] } |
302 | const attaches = baseCorrectAttaches | 301 | const attaches = baseCorrectAttaches |
303 | 302 | ||
304 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 303 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
305 | }) | 304 | }) |
306 | 305 | ||
307 | it('Should fail with a tag length too low', async function () { | 306 | it('Should fail with a tag length too low', async function () { |
308 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] }) | 307 | const fields = { ...baseCorrectParams, tags: [ 'tag1', 't' ] } |
309 | const attaches = baseCorrectAttaches | 308 | const attaches = baseCorrectAttaches |
310 | 309 | ||
311 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 310 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
312 | }) | 311 | }) |
313 | 312 | ||
314 | it('Should fail with a tag length too big', async function () { | 313 | it('Should fail with a tag length too big', async function () { |
315 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }) | 314 | const fields = { ...baseCorrectParams, tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] } |
316 | const attaches = baseCorrectAttaches | 315 | const attaches = baseCorrectAttaches |
317 | 316 | ||
318 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 317 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
319 | }) | 318 | }) |
320 | 319 | ||
321 | it('Should fail with a bad schedule update (miss updateAt)', async function () { | 320 | it('Should fail with a bad schedule update (miss updateAt)', async function () { |
322 | const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } }) | 321 | const fields = { ...baseCorrectParams, scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } } |
323 | const attaches = baseCorrectAttaches | 322 | const attaches = baseCorrectAttaches |
324 | 323 | ||
325 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 324 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
326 | }) | 325 | }) |
327 | 326 | ||
328 | it('Should fail with a bad schedule update (wrong updateAt)', async function () { | 327 | it('Should fail with a bad schedule update (wrong updateAt)', async function () { |
329 | const fields = immutableAssign(baseCorrectParams, { | 328 | const fields = { |
329 | ...baseCorrectParams, | ||
330 | |||
330 | scheduleUpdate: { | 331 | scheduleUpdate: { |
331 | privacy: VideoPrivacy.PUBLIC, | 332 | privacy: VideoPrivacy.PUBLIC, |
332 | updateAt: 'toto' | 333 | updateAt: 'toto' |
333 | } | 334 | } |
334 | }) | 335 | } |
335 | const attaches = baseCorrectAttaches | 336 | const attaches = baseCorrectAttaches |
336 | 337 | ||
337 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 338 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
338 | }) | 339 | }) |
339 | 340 | ||
340 | it('Should fail with a bad originally published at attribute', async function () { | 341 | it('Should fail with a bad originally published at attribute', async function () { |
341 | const fields = immutableAssign(baseCorrectParams, { originallyPublishedAt: 'toto' }) | 342 | const fields = { ...baseCorrectParams, originallyPublishedAt: 'toto' } |
342 | const attaches = baseCorrectAttaches | 343 | const attaches = baseCorrectAttaches |
343 | 344 | ||
344 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 345 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
@@ -413,7 +414,7 @@ describe('Test videos API validator', function () { | |||
413 | }) | 414 | }) |
414 | 415 | ||
415 | it('Should report the appropriate error', async function () { | 416 | it('Should report the appropriate error', async function () { |
416 | const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) }) | 417 | const fields = { ...baseCorrectParams, language: 'a'.repeat(15) } |
417 | const attaches = baseCorrectAttaches | 418 | const attaches = baseCorrectAttaches |
418 | 419 | ||
419 | const attributes = { ...fields, ...attaches } | 420 | const attributes = { ...fields, ...attaches } |
@@ -448,17 +449,21 @@ describe('Test videos API validator', function () { | |||
448 | } | 449 | } |
449 | 450 | ||
450 | { | 451 | { |
451 | const attaches = immutableAssign(baseCorrectAttaches, { | 452 | const attaches = { |
453 | ...baseCorrectAttaches, | ||
454 | |||
452 | videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') | 455 | videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') |
453 | }) | 456 | } |
454 | 457 | ||
455 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode) | 458 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode) |
456 | } | 459 | } |
457 | 460 | ||
458 | { | 461 | { |
459 | const attaches = immutableAssign(baseCorrectAttaches, { | 462 | const attaches = { |
463 | ...baseCorrectAttaches, | ||
464 | |||
460 | videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.ogv') | 465 | videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.ogv') |
461 | }) | 466 | } |
462 | 467 | ||
463 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode) | 468 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode) |
464 | } | 469 | } |
@@ -516,79 +521,79 @@ describe('Test videos API validator', function () { | |||
516 | }) | 521 | }) |
517 | 522 | ||
518 | it('Should fail with a long name', async function () { | 523 | it('Should fail with a long name', async function () { |
519 | const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) }) | 524 | const fields = { ...baseCorrectParams, name: 'super'.repeat(65) } |
520 | 525 | ||
521 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) | 526 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
522 | }) | 527 | }) |
523 | 528 | ||
524 | it('Should fail with a bad category', async function () { | 529 | it('Should fail with a bad category', async function () { |
525 | const fields = immutableAssign(baseCorrectParams, { category: 125 }) | 530 | const fields = { ...baseCorrectParams, category: 125 } |
526 | 531 | ||
527 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) | 532 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
528 | }) | 533 | }) |
529 | 534 | ||
530 | it('Should fail with a bad licence', async function () { | 535 | it('Should fail with a bad licence', async function () { |
531 | const fields = immutableAssign(baseCorrectParams, { licence: 125 }) | 536 | const fields = { ...baseCorrectParams, licence: 125 } |
532 | 537 | ||
533 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) | 538 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
534 | }) | 539 | }) |
535 | 540 | ||
536 | it('Should fail with a bad language', async function () { | 541 | it('Should fail with a bad language', async function () { |
537 | const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) }) | 542 | const fields = { ...baseCorrectParams, language: 'a'.repeat(15) } |
538 | 543 | ||
539 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) | 544 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
540 | }) | 545 | }) |
541 | 546 | ||
542 | it('Should fail with a long description', async function () { | 547 | it('Should fail with a long description', async function () { |
543 | const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) }) | 548 | const fields = { ...baseCorrectParams, description: 'super'.repeat(2500) } |
544 | 549 | ||
545 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) | 550 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
546 | }) | 551 | }) |
547 | 552 | ||
548 | it('Should fail with a long support text', async function () { | 553 | it('Should fail with a long support text', async function () { |
549 | const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) }) | 554 | const fields = { ...baseCorrectParams, support: 'super'.repeat(201) } |
550 | 555 | ||
551 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) | 556 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
552 | }) | 557 | }) |
553 | 558 | ||
554 | it('Should fail with a bad channel', async function () { | 559 | it('Should fail with a bad channel', async function () { |
555 | const fields = immutableAssign(baseCorrectParams, { channelId: 545454 }) | 560 | const fields = { ...baseCorrectParams, channelId: 545454 } |
556 | 561 | ||
557 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) | 562 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
558 | }) | 563 | }) |
559 | 564 | ||
560 | it('Should fail with too many tags', async function () { | 565 | it('Should fail with too many tags', async function () { |
561 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }) | 566 | const fields = { ...baseCorrectParams, tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] } |
562 | 567 | ||
563 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) | 568 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
564 | }) | 569 | }) |
565 | 570 | ||
566 | it('Should fail with a tag length too low', async function () { | 571 | it('Should fail with a tag length too low', async function () { |
567 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] }) | 572 | const fields = { ...baseCorrectParams, tags: [ 'tag1', 't' ] } |
568 | 573 | ||
569 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) | 574 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
570 | }) | 575 | }) |
571 | 576 | ||
572 | it('Should fail with a tag length too big', async function () { | 577 | it('Should fail with a tag length too big', async function () { |
573 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }) | 578 | const fields = { ...baseCorrectParams, tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] } |
574 | 579 | ||
575 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) | 580 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
576 | }) | 581 | }) |
577 | 582 | ||
578 | it('Should fail with a bad schedule update (miss updateAt)', async function () { | 583 | it('Should fail with a bad schedule update (miss updateAt)', async function () { |
579 | const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } }) | 584 | const fields = { ...baseCorrectParams, scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } } |
580 | 585 | ||
581 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) | 586 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
582 | }) | 587 | }) |
583 | 588 | ||
584 | it('Should fail with a bad schedule update (wrong updateAt)', async function () { | 589 | it('Should fail with a bad schedule update (wrong updateAt)', async function () { |
585 | const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { updateAt: 'toto', privacy: VideoPrivacy.PUBLIC } }) | 590 | const fields = { ...baseCorrectParams, scheduleUpdate: { updateAt: 'toto', privacy: VideoPrivacy.PUBLIC } } |
586 | 591 | ||
587 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) | 592 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
588 | }) | 593 | }) |
589 | 594 | ||
590 | it('Should fail with a bad originally published at param', async function () { | 595 | it('Should fail with a bad originally published at param', async function () { |
591 | const fields = immutableAssign(baseCorrectParams, { originallyPublishedAt: 'toto' }) | 596 | const fields = { ...baseCorrectParams, originallyPublishedAt: 'toto' } |
592 | 597 | ||
593 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) | 598 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
594 | }) | 599 | }) |
@@ -672,7 +677,7 @@ describe('Test videos API validator', function () { | |||
672 | it('Should fail with a video of another server') | 677 | it('Should fail with a video of another server') |
673 | 678 | ||
674 | it('Shoud report the appropriate error', async function () { | 679 | it('Shoud report the appropriate error', async function () { |
675 | const fields = immutableAssign(baseCorrectParams, { licence: 125 }) | 680 | const fields = { ...baseCorrectParams, licence: 125 } |
676 | 681 | ||
677 | const res = await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) | 682 | const res = await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
678 | const error = res.body as PeerTubeProblemDocument | 683 | const error = res.body as PeerTubeProblemDocument |