X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fcheck-params%2Fvideo-captions.ts;h=bfce5ca4767524c46fe891a8bc88a28a886768d2;hb=644391bee644c9078695ab042743d108870de7ef;hp=1b3d1aa951c12d6258113a86f3663439ac4482c2;hpb=c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/check-params/video-captions.ts b/server/tests/api/check-params/video-captions.ts index 1b3d1aa95..bfce5ca47 100644 --- a/server/tests/api/check-params/video-captions.ts +++ b/server/tests/api/check-params/video-captions.ts @@ -1,9 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import 'mocha' -import { HttpStatusCode } from '@shared/models' +import { buildAbsoluteFixturePath } from '@shared/core-utils' +import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models' import { - buildAbsoluteFixturePath, cleanupTests, createSingleServer, makeDeleteRequest, @@ -11,8 +10,7 @@ import { makeUploadRequest, PeerTubeServer, setAccessTokensToServers -} from '@shared/extra-utils' -import { VideoCreateResult } from '@shared/models' +} from '@shared/server-commands' describe('Test video captions API validator', function () { const path = '/api/v1/videos/' @@ -20,6 +18,7 @@ describe('Test video captions API validator', function () { let server: PeerTubeServer let userAccessToken: string let video: VideoCreateResult + let privateVideo: VideoCreateResult // --------------------------------------------------------------- @@ -31,6 +30,7 @@ describe('Test video captions API validator', function () { await setAccessTokensToServers([ server ]) video = await server.videos.upload() + privateVideo = await server.videos.upload({ attributes: { privacy: VideoPrivacy.PRIVATE } }) { const user = { @@ -152,7 +152,7 @@ describe('Test video captions API validator', function () { // }) it('Should succeed with a valid captionfile extension and octet-stream mime type', async function () { - await server.captions.createVideoCaption({ + await server.captions.add({ language: 'zh', videoId: video.uuid, fixture: 'subtitle-good.srt', @@ -205,8 +205,32 @@ describe('Test video captions API validator', function () { }) }) + it('Should fail with a private video without token', async function () { + await makeGetRequest({ + url: server.url, + path: path + privateVideo.shortUUID + '/captions', + expectedStatus: HttpStatusCode.UNAUTHORIZED_401 + }) + }) + + it('Should fail with another user token', async function () { + await makeGetRequest({ + url: server.url, + token: userAccessToken, + path: path + privateVideo.shortUUID + '/captions', + expectedStatus: HttpStatusCode.FORBIDDEN_403 + }) + }) + it('Should success with the correct parameters', async function () { await makeGetRequest({ url: server.url, path: path + video.shortUUID + '/captions', expectedStatus: HttpStatusCode.OK_200 }) + + await makeGetRequest({ + url: server.url, + path: path + privateVideo.shortUUID + '/captions', + token: server.accessToken, + expectedStatus: HttpStatusCode.OK_200 + }) }) })