X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fcheck-params%2Fvideo-comments.ts;h=55019884487824479dfccc4327131e1a0ae7fbc9;hb=8a6828b1664ce3fc535d23c54ed22bab35588d06;hp=8d63fe70c7bb1505f24a66ea81474bf3b96f0eed;hpb=84c8d9866890f479faf0168c29be5eb7816ccc8e;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.ts index 8d63fe70c..550198844 100644 --- a/server/tests/api/check-params/video-comments.ts +++ b/server/tests/api/check-params/video-comments.ts @@ -1,11 +1,9 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import 'mocha' -import * as chai from 'chai' +import { expect } from 'chai' +import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' +import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models' import { - checkBadCountPagination, - checkBadSortPagination, - checkBadStartPagination, cleanupTests, createSingleServer, makeDeleteRequest, @@ -13,18 +11,19 @@ import { makePostBodyRequest, PeerTubeServer, setAccessTokensToServers -} from '@shared/extra-utils' -import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models' - -const expect = chai.expect +} from '@shared/server-commands' describe('Test video comments API validator', function () { let pathThread: string let pathComment: string + let server: PeerTubeServer + let video: VideoCreateResult + let userAccessToken: string let userAccessToken2: string + let commentId: number let privateCommentId: number let privateVideo: VideoCreateResult @@ -205,9 +204,8 @@ describe('Test video comments API validator', function () { it('Should fail with an incorrect video', async function () { const path = '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comment-threads' - const fields = { - text: 'super comment' - } + const fields = { text: 'super comment' } + await makePostBodyRequest({ url: server.url, path, @@ -217,10 +215,21 @@ describe('Test video comments API validator', function () { }) }) + it('Should fail with a private video of another user', async function () { + const fields = { text: 'super comment' } + + await makePostBodyRequest({ + url: server.url, + path: '/api/v1/videos/' + privateVideo.shortUUID + '/comment-threads', + token: userAccessToken, + fields, + expectedStatus: HttpStatusCode.FORBIDDEN_403 + }) + }) + it('Should succeed with the correct parameters', async function () { - const fields = { - text: 'super comment' - } + const fields = { text: 'super comment' } + await makePostBodyRequest({ url: server.url, path: pathThread, @@ -232,6 +241,7 @@ describe('Test video comments API validator', function () { }) describe('When adding a comment to a thread', function () { + it('Should fail with a non authenticated user', async function () { const fields = { text: 'text' @@ -278,6 +288,18 @@ describe('Test video comments API validator', function () { }) }) + it('Should fail with a private video of another user', async function () { + const fields = { text: 'super comment' } + + await makePostBodyRequest({ + url: server.url, + path: '/api/v1/videos/' + privateVideo.uuid + '/comments/' + privateCommentId, + token: userAccessToken, + fields, + expectedStatus: HttpStatusCode.FORBIDDEN_403 + }) + }) + it('Should fail with an incorrect comment', async function () { const path = '/api/v1/videos/' + video.uuid + '/comments/124' const fields = {