aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/videos.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/check-params/videos.ts')
-rw-r--r--server/tests/api/check-params/videos.ts52
1 files changed, 26 insertions, 26 deletions
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts
index a6eecb13a..4d7a9a23b 100644
--- a/server/tests/api/check-params/videos.ts
+++ b/server/tests/api/check-params/videos.ts
@@ -5,7 +5,7 @@ import * as chai from 'chai'
5import { omit } from 'lodash' 5import { omit } from 'lodash'
6import { join } from 'path' 6import { join } from 'path'
7import { randomInt } from '@shared/core-utils' 7import { randomInt } from '@shared/core-utils'
8import { PeerTubeProblemDocument } from '@shared/models' 8import { PeerTubeProblemDocument, VideoCreateResult } from '@shared/models'
9import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 9import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
10import { 10import {
11 checkUploadVideoParam, 11 checkUploadVideoParam,
@@ -42,7 +42,7 @@ describe('Test videos API validator', function () {
42 let accountName: string 42 let accountName: string
43 let channelId: number 43 let channelId: number
44 let channelName: string 44 let channelName: string
45 let videoId 45 let video: VideoCreateResult
46 46
47 // --------------------------------------------------------------- 47 // ---------------------------------------------------------------
48 48
@@ -490,7 +490,7 @@ describe('Test videos API validator', function () {
490 490
491 before(async function () { 491 before(async function () {
492 const res = await getVideosList(server.url) 492 const res = await getVideosList(server.url)
493 videoId = res.body.data[0].uuid 493 video = res.body.data[0]
494 }) 494 })
495 495
496 it('Should fail with nothing', async function () { 496 it('Should fail with nothing', async function () {
@@ -518,79 +518,79 @@ describe('Test videos API validator', function () {
518 it('Should fail with a long name', async function () { 518 it('Should fail with a long name', async function () {
519 const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) }) 519 const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) })
520 520
521 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 521 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
522 }) 522 })
523 523
524 it('Should fail with a bad category', async function () { 524 it('Should fail with a bad category', async function () {
525 const fields = immutableAssign(baseCorrectParams, { category: 125 }) 525 const fields = immutableAssign(baseCorrectParams, { category: 125 })
526 526
527 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 527 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
528 }) 528 })
529 529
530 it('Should fail with a bad licence', async function () { 530 it('Should fail with a bad licence', async function () {
531 const fields = immutableAssign(baseCorrectParams, { licence: 125 }) 531 const fields = immutableAssign(baseCorrectParams, { licence: 125 })
532 532
533 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 533 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
534 }) 534 })
535 535
536 it('Should fail with a bad language', async function () { 536 it('Should fail with a bad language', async function () {
537 const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) }) 537 const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) })
538 538
539 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 539 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
540 }) 540 })
541 541
542 it('Should fail with a long description', async function () { 542 it('Should fail with a long description', async function () {
543 const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) }) 543 const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) })
544 544
545 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 545 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
546 }) 546 })
547 547
548 it('Should fail with a long support text', async function () { 548 it('Should fail with a long support text', async function () {
549 const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) }) 549 const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) })
550 550
551 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 551 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
552 }) 552 })
553 553
554 it('Should fail with a bad channel', async function () { 554 it('Should fail with a bad channel', async function () {
555 const fields = immutableAssign(baseCorrectParams, { channelId: 545454 }) 555 const fields = immutableAssign(baseCorrectParams, { channelId: 545454 })
556 556
557 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 557 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
558 }) 558 })
559 559
560 it('Should fail with too many tags', async function () { 560 it('Should fail with too many tags', async function () {
561 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }) 561 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] })
562 562
563 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 563 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
564 }) 564 })
565 565
566 it('Should fail with a tag length too low', async function () { 566 it('Should fail with a tag length too low', async function () {
567 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] }) 567 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] })
568 568
569 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 569 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
570 }) 570 })
571 571
572 it('Should fail with a tag length too big', async function () { 572 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' ] }) 573 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] })
574 574
575 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 575 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
576 }) 576 })
577 577
578 it('Should fail with a bad schedule update (miss updateAt)', async function () { 578 it('Should fail with a bad schedule update (miss updateAt)', async function () {
579 const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } }) 579 const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } })
580 580
581 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 581 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
582 }) 582 })
583 583
584 it('Should fail with a bad schedule update (wrong updateAt)', async function () { 584 it('Should fail with a bad schedule update (wrong updateAt)', async function () {
585 const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { updateAt: 'toto', privacy: VideoPrivacy.PUBLIC } }) 585 const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { updateAt: 'toto', privacy: VideoPrivacy.PUBLIC } })
586 586
587 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 587 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
588 }) 588 })
589 589
590 it('Should fail with a bad originally published at param', async function () { 590 it('Should fail with a bad originally published at param', async function () {
591 const fields = immutableAssign(baseCorrectParams, { originallyPublishedAt: 'toto' }) 591 const fields = immutableAssign(baseCorrectParams, { originallyPublishedAt: 'toto' })
592 592
593 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 593 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
594 }) 594 })
595 595
596 it('Should fail with an incorrect thumbnail file', async function () { 596 it('Should fail with an incorrect thumbnail file', async function () {
@@ -602,7 +602,7 @@ describe('Test videos API validator', function () {
602 await makeUploadRequest({ 602 await makeUploadRequest({
603 url: server.url, 603 url: server.url,
604 method: 'PUT', 604 method: 'PUT',
605 path: path + videoId, 605 path: path + video.shortUUID,
606 token: server.accessToken, 606 token: server.accessToken,
607 fields, 607 fields,
608 attaches 608 attaches
@@ -618,7 +618,7 @@ describe('Test videos API validator', function () {
618 await makeUploadRequest({ 618 await makeUploadRequest({
619 url: server.url, 619 url: server.url,
620 method: 'PUT', 620 method: 'PUT',
621 path: path + videoId, 621 path: path + video.shortUUID,
622 token: server.accessToken, 622 token: server.accessToken,
623 fields, 623 fields,
624 attaches 624 attaches
@@ -634,7 +634,7 @@ describe('Test videos API validator', function () {
634 await makeUploadRequest({ 634 await makeUploadRequest({
635 url: server.url, 635 url: server.url,
636 method: 'PUT', 636 method: 'PUT',
637 path: path + videoId, 637 path: path + video.shortUUID,
638 token: server.accessToken, 638 token: server.accessToken,
639 fields, 639 fields,
640 attaches 640 attaches
@@ -650,7 +650,7 @@ describe('Test videos API validator', function () {
650 await makeUploadRequest({ 650 await makeUploadRequest({
651 url: server.url, 651 url: server.url,
652 method: 'PUT', 652 method: 'PUT',
653 path: path + videoId, 653 path: path + video.shortUUID,
654 token: server.accessToken, 654 token: server.accessToken,
655 fields, 655 fields,
656 attaches 656 attaches
@@ -662,7 +662,7 @@ describe('Test videos API validator', function () {
662 662
663 await makePutBodyRequest({ 663 await makePutBodyRequest({
664 url: server.url, 664 url: server.url,
665 path: path + videoId, 665 path: path + video.shortUUID,
666 token: userAccessToken, 666 token: userAccessToken,
667 fields, 667 fields,
668 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 668 statusCodeExpected: HttpStatusCode.FORBIDDEN_403
@@ -674,7 +674,7 @@ describe('Test videos API validator', function () {
674 it('Shoud report the appropriate error', async function () { 674 it('Shoud report the appropriate error', async function () {
675 const fields = immutableAssign(baseCorrectParams, { licence: 125 }) 675 const fields = immutableAssign(baseCorrectParams, { licence: 125 })
676 676
677 const res = await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 677 const res = await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
678 const error = res.body as PeerTubeProblemDocument 678 const error = res.body as PeerTubeProblemDocument
679 679
680 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/putVideo') 680 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/putVideo')
@@ -694,7 +694,7 @@ describe('Test videos API validator', function () {
694 694
695 await makePutBodyRequest({ 695 await makePutBodyRequest({
696 url: server.url, 696 url: server.url,
697 path: path + videoId, 697 path: path + video.shortUUID,
698 token: server.accessToken, 698 token: server.accessToken,
699 fields, 699 fields,
700 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 700 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
@@ -739,7 +739,7 @@ describe('Test videos API validator', function () {
739 }) 739 })
740 740
741 it('Should succeed with the correct parameters', async function () { 741 it('Should succeed with the correct parameters', async function () {
742 await getVideo(server.url, videoId) 742 await getVideo(server.url, video.shortUUID)
743 }) 743 })
744 }) 744 })
745 745
@@ -810,7 +810,7 @@ describe('Test videos API validator', function () {
810 }) 810 })
811 811
812 it('Should fail with a video of another user without the appropriate right', async function () { 812 it('Should fail with a video of another user without the appropriate right', async function () {
813 await removeVideo(server.url, userAccessToken, videoId, HttpStatusCode.FORBIDDEN_403) 813 await removeVideo(server.url, userAccessToken, video.uuid, HttpStatusCode.FORBIDDEN_403)
814 }) 814 })
815 815
816 it('Should fail with a video of another server') 816 it('Should fail with a video of another server')
@@ -832,7 +832,7 @@ describe('Test videos API validator', function () {
832 }) 832 })
833 833
834 it('Should succeed with the correct parameters', async function () { 834 it('Should succeed with the correct parameters', async function () {
835 await removeVideo(server.url, server.accessToken, videoId) 835 await removeVideo(server.url, server.accessToken, video.uuid)
836 }) 836 })
837 }) 837 })
838 838