From d4a8e7a65f97bb3257facc13e1ae8ffdbad61ddb Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 28 Jun 2021 17:30:59 +0200 Subject: Support short uuid for GET video/playlist --- server/tests/api/activitypub/client.ts | 98 ++++-- server/tests/api/check-params/abuses.ts | 2 +- server/tests/api/check-params/live.ts | 40 +-- server/tests/api/check-params/redundancy.ts | 38 ++- server/tests/api/check-params/users.ts | 12 +- server/tests/api/check-params/video-blacklist.ts | 12 +- server/tests/api/check-params/video-captions.ts | 38 +-- server/tests/api/check-params/video-comments.ts | 31 +- server/tests/api/check-params/video-playlists.ts | 64 ++-- server/tests/api/check-params/videos.ts | 52 +-- .../api/notifications/moderation-notifications.ts | 30 +- .../tests/api/notifications/user-notifications.ts | 10 +- server/tests/api/server/handle-down.ts | 2 +- server/tests/api/videos/video-playlists.ts | 71 +++-- server/tests/api/videos/video-privacy.ts | 351 +++++++++++---------- 15 files changed, 494 insertions(+), 357 deletions(-) (limited to 'server/tests/api') diff --git a/server/tests/api/activitypub/client.ts b/server/tests/api/activitypub/client.ts index b6c538e19..be94e219c 100644 --- a/server/tests/api/activitypub/client.ts +++ b/server/tests/api/activitypub/client.ts @@ -1,23 +1,65 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import * as chai from 'chai' import 'mocha' +import * as chai from 'chai' +import { VideoPlaylistPrivacy } from '@shared/models' +import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { cleanupTests, + createVideoPlaylist, doubleFollow, flushAndRunMultipleServers, makeActivityPubGetRequest, ServerInfo, setAccessTokensToServers, - uploadVideo + setDefaultVideoChannel, + uploadVideoAndGetId } from '../../../../shared/extra-utils' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' const expect = chai.expect describe('Test activitypub', function () { let servers: ServerInfo[] = [] - let videoUUID: string + let video: { id: number, uuid: string, shortUUID: string } + let playlist: { id: number, uuid: string, shortUUID: string } + + async function testAccount (path: string) { + const res = await makeActivityPubGetRequest(servers[0].url, path) + const object = res.body + + expect(object.type).to.equal('Person') + expect(object.id).to.equal('http://localhost:' + servers[0].port + '/accounts/root') + expect(object.name).to.equal('root') + expect(object.preferredUsername).to.equal('root') + } + + async function testChannel (path: string) { + const res = await makeActivityPubGetRequest(servers[0].url, path) + const object = res.body + + expect(object.type).to.equal('Group') + expect(object.id).to.equal('http://localhost:' + servers[0].port + '/video-channels/root_channel') + expect(object.name).to.equal('Main root channel') + expect(object.preferredUsername).to.equal('root_channel') + } + + async function testVideo (path: string) { + const res = await makeActivityPubGetRequest(servers[0].url, path) + const object = res.body + + expect(object.type).to.equal('Video') + expect(object.id).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + video.uuid) + expect(object.name).to.equal('video') + } + + async function testPlaylist (path: string) { + const res = await makeActivityPubGetRequest(servers[0].url, path) + const object = res.body + + expect(object.type).to.equal('Playlist') + expect(object.id).to.equal('http://localhost:' + servers[0].port + '/video-playlists/' + playlist.uuid) + expect(object.name).to.equal('playlist') + } before(async function () { this.timeout(30000) @@ -25,38 +67,56 @@ describe('Test activitypub', function () { servers = await flushAndRunMultipleServers(2) await setAccessTokensToServers(servers) + await setDefaultVideoChannel(servers) { - const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video' }) - videoUUID = res.body.video.uuid + video = await uploadVideoAndGetId({ server: servers[0], videoName: 'video' }) + } + + { + const playlistAttrs = { displayName: 'playlist', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[0].videoChannel.id } + const resCreate = await createVideoPlaylist({ url: servers[0].url, token: servers[0].accessToken, playlistAttrs }) + playlist = resCreate.body.videoPlaylist } await doubleFollow(servers[0], servers[1]) }) it('Should return the account object', async function () { - const res = await makeActivityPubGetRequest(servers[0].url, '/accounts/root') - const object = res.body + await testAccount('/accounts/root') + await testAccount('/a/root') + }) - expect(object.type).to.equal('Person') - expect(object.id).to.equal('http://localhost:' + servers[0].port + '/accounts/root') - expect(object.name).to.equal('root') - expect(object.preferredUsername).to.equal('root') + it('Should return the channel object', async function () { + await testChannel('/video-channels/root_channel') + await testChannel('/c/root_channel') }) it('Should return the video object', async function () { - const res = await makeActivityPubGetRequest(servers[0].url, '/videos/watch/' + videoUUID) - const object = res.body + await testVideo('/videos/watch/' + video.id) + await testVideo('/videos/watch/' + video.uuid) + await testVideo('/videos/watch/' + video.shortUUID) + await testVideo('/w/' + video.id) + await testVideo('/w/' + video.uuid) + await testVideo('/w/' + video.shortUUID) + }) - expect(object.type).to.equal('Video') - expect(object.id).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID) - expect(object.name).to.equal('video') + it('Should return the playlist object', async function () { + await testPlaylist('/video-playlists/' + playlist.id) + await testPlaylist('/video-playlists/' + playlist.uuid) + await testPlaylist('/video-playlists/' + playlist.shortUUID) + await testPlaylist('/w/p/' + playlist.id) + await testPlaylist('/w/p/' + playlist.uuid) + await testPlaylist('/w/p/' + playlist.shortUUID) + await testPlaylist('/videos/watch/playlist/' + playlist.id) + await testPlaylist('/videos/watch/playlist/' + playlist.uuid) + await testPlaylist('/videos/watch/playlist/' + playlist.shortUUID) }) it('Should redirect to the origin video object', async function () { - const res = await makeActivityPubGetRequest(servers[1].url, '/videos/watch/' + videoUUID, HttpStatusCode.FOUND_302) + const res = await makeActivityPubGetRequest(servers[1].url, '/videos/watch/' + video.uuid, HttpStatusCode.FOUND_302) - expect(res.header.location).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID) + expect(res.header.location).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + video.uuid) }) after(async function () { diff --git a/server/tests/api/check-params/abuses.ts b/server/tests/api/check-params/abuses.ts index 2aa09334c..2054776cc 100644 --- a/server/tests/api/check-params/abuses.ts +++ b/server/tests/api/check-params/abuses.ts @@ -258,7 +258,7 @@ describe('Test abuses API validators', function () { }) it('Should succeed with the correct parameters (basic)', async function () { - const fields: AbuseCreate = { video: { id: server.video.id }, reason: 'my super reason' } + const fields: AbuseCreate = { video: { id: server.video.shortUUID }, reason: 'my super reason' } const res = await makePostBodyRequest({ url: server.url, diff --git a/server/tests/api/check-params/live.ts b/server/tests/api/check-params/live.ts index 32233c9da..933d8abf2 100644 --- a/server/tests/api/check-params/live.ts +++ b/server/tests/api/check-params/live.ts @@ -2,7 +2,7 @@ import 'mocha' import { omit } from 'lodash' -import { LiveVideo, VideoPrivacy } from '@shared/models' +import { LiveVideo, VideoCreateResult, VideoPrivacy } from '@shared/models' import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { buildAbsoluteFixturePath, @@ -31,7 +31,7 @@ describe('Test video lives API validator', function () { let server: ServerInfo let userAccessToken = '' let channelId: number - let videoId: number + let video: VideoCreateResult let videoIdNotLive: number // --------------------------------------------------------------- @@ -230,7 +230,7 @@ describe('Test video lives API validator', function () { statusCodeExpected: HttpStatusCode.OK_200 }) - videoId = res.body.video.id + video = res.body.video }) it('Should forbid if live is disabled', async function () { @@ -326,15 +326,15 @@ describe('Test video lives API validator', function () { describe('When getting live information', function () { it('Should fail without access token', async function () { - await getLive(server.url, '', videoId, HttpStatusCode.UNAUTHORIZED_401) + await getLive(server.url, '', video.id, HttpStatusCode.UNAUTHORIZED_401) }) it('Should fail with a bad access token', async function () { - await getLive(server.url, 'toto', videoId, HttpStatusCode.UNAUTHORIZED_401) + await getLive(server.url, 'toto', video.id, HttpStatusCode.UNAUTHORIZED_401) }) it('Should fail with access token of another user', async function () { - await getLive(server.url, userAccessToken, videoId, HttpStatusCode.FORBIDDEN_403) + await getLive(server.url, userAccessToken, video.id, HttpStatusCode.FORBIDDEN_403) }) it('Should fail with a bad video id', async function () { @@ -350,22 +350,23 @@ describe('Test video lives API validator', function () { }) it('Should succeed with the correct params', async function () { - await getLive(server.url, server.accessToken, videoId) + await getLive(server.url, server.accessToken, video.id) + await getLive(server.url, server.accessToken, video.shortUUID) }) }) describe('When updating live information', async function () { it('Should fail without access token', async function () { - await updateLive(server.url, '', videoId, {}, HttpStatusCode.UNAUTHORIZED_401) + await updateLive(server.url, '', video.id, {}, HttpStatusCode.UNAUTHORIZED_401) }) it('Should fail with a bad access token', async function () { - await updateLive(server.url, 'toto', videoId, {}, HttpStatusCode.UNAUTHORIZED_401) + await updateLive(server.url, 'toto', video.id, {}, HttpStatusCode.UNAUTHORIZED_401) }) it('Should fail with access token of another user', async function () { - await updateLive(server.url, userAccessToken, videoId, {}, HttpStatusCode.FORBIDDEN_403) + await updateLive(server.url, userAccessToken, video.id, {}, HttpStatusCode.FORBIDDEN_403) }) it('Should fail with a bad video id', async function () { @@ -383,11 +384,12 @@ describe('Test video lives API validator', function () { it('Should fail with save replay and permanent live set to true', async function () { const fields = { saveReplay: true, permanentLive: true } - await updateLive(server.url, server.accessToken, videoId, fields, HttpStatusCode.BAD_REQUEST_400) + await updateLive(server.url, server.accessToken, video.id, fields, HttpStatusCode.BAD_REQUEST_400) }) it('Should succeed with the correct params', async function () { - await updateLive(server.url, server.accessToken, videoId, { saveReplay: false }) + await updateLive(server.url, server.accessToken, video.id, { saveReplay: false }) + await updateLive(server.url, server.accessToken, video.shortUUID, { saveReplay: false }) }) it('Should fail to update replay status if replay is not allowed on the instance', async function () { @@ -398,19 +400,19 @@ describe('Test video lives API validator', function () { } }) - await updateLive(server.url, server.accessToken, videoId, { saveReplay: true }, HttpStatusCode.FORBIDDEN_403) + await updateLive(server.url, server.accessToken, video.id, { saveReplay: true }, HttpStatusCode.FORBIDDEN_403) }) it('Should fail to update a live if it has already started', async function () { this.timeout(40000) - const resLive = await getLive(server.url, server.accessToken, videoId) + const resLive = await getLive(server.url, server.accessToken, video.id) const live: LiveVideo = resLive.body const command = sendRTMPStream(live.rtmpUrl, live.streamKey) - await waitUntilLivePublished(server.url, server.accessToken, videoId) - await updateLive(server.url, server.accessToken, videoId, {}, HttpStatusCode.BAD_REQUEST_400) + await waitUntilLivePublished(server.url, server.accessToken, video.id) + await updateLive(server.url, server.accessToken, video.id, {}, HttpStatusCode.BAD_REQUEST_400) await stopFfmpeg(command) }) @@ -418,14 +420,14 @@ describe('Test video lives API validator', function () { it('Should fail to stream twice in the save live', async function () { this.timeout(40000) - const resLive = await getLive(server.url, server.accessToken, videoId) + const resLive = await getLive(server.url, server.accessToken, video.id) const live: LiveVideo = resLive.body const command = sendRTMPStream(live.rtmpUrl, live.streamKey) - await waitUntilLivePublished(server.url, server.accessToken, videoId) + await waitUntilLivePublished(server.url, server.accessToken, video.id) - await runAndTestFfmpegStreamError(server.url, server.accessToken, videoId, true) + await runAndTestFfmpegStreamError(server.url, server.accessToken, video.id, true) await stopFfmpeg(command) }) diff --git a/server/tests/api/check-params/redundancy.ts b/server/tests/api/check-params/redundancy.ts index 71be50a6f..dac6938de 100644 --- a/server/tests/api/check-params/redundancy.ts +++ b/server/tests/api/check-params/redundancy.ts @@ -1,7 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' - +import { VideoCreateResult } from '@shared/models' +import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { checkBadCountPagination, checkBadSortPagination, @@ -9,20 +10,24 @@ import { cleanupTests, createUser, doubleFollow, - flushAndRunMultipleServers, makeDeleteRequest, - makeGetRequest, makePostBodyRequest, + flushAndRunMultipleServers, + getVideo, + makeDeleteRequest, + makeGetRequest, + makePostBodyRequest, makePutBodyRequest, ServerInfo, - setAccessTokensToServers, uploadVideoAndGetId, - userLogin, waitJobs, getVideoIdFromUUID + setAccessTokensToServers, + uploadVideoAndGetId, + userLogin, + waitJobs } from '../../../../shared/extra-utils' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' describe('Test server redundancy API validators', function () { let servers: ServerInfo[] let userAccessToken = null let videoIdLocal: number - let videoIdRemote: number + let videoRemote: VideoCreateResult // --------------------------------------------------------------- @@ -48,7 +53,8 @@ describe('Test server redundancy API validators', function () { await waitJobs(servers) - videoIdRemote = await getVideoIdFromUUID(servers[0].url, remoteUUID) + const resVideo = await getVideo(servers[0].url, remoteUUID) + videoRemote = resVideo.body }) describe('When listing redundancies', function () { @@ -131,7 +137,13 @@ describe('Test server redundancy API validators', function () { }) it('Should succeed with the correct params', async function () { - await makePostBodyRequest({ url, path, token, fields: { videoId: videoIdRemote }, statusCodeExpected: HttpStatusCode.NO_CONTENT_204 }) + await makePostBodyRequest({ + url, + path, + token, + fields: { videoId: videoRemote.shortUUID }, + statusCodeExpected: HttpStatusCode.NO_CONTENT_204 + }) }) it('Should fail if the video is already duplicated', async function () { @@ -139,7 +151,13 @@ describe('Test server redundancy API validators', function () { await waitJobs(servers) - await makePostBodyRequest({ url, path, token, fields: { videoId: videoIdRemote }, statusCodeExpected: HttpStatusCode.CONFLICT_409 }) + await makePostBodyRequest({ + url, + path, + token, + fields: { videoId: videoRemote.uuid }, + statusCodeExpected: HttpStatusCode.CONFLICT_409 + }) }) }) diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index 36482ee17..70a872ce5 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts @@ -2,7 +2,7 @@ import 'mocha' import { omit } from 'lodash' -import { User, UserRole } from '../../../../shared' +import { User, UserRole, VideoCreateResult } from '../../../../shared' import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { addVideoChannel, @@ -45,7 +45,7 @@ describe('Test users API validators', function () { let userId: number let rootId: number let moderatorId: number - let videoId: number + let video: VideoCreateResult let server: ServerInfo let serverWithRegistrationDisabled: ServerInfo let userAccessToken = '' @@ -126,7 +126,7 @@ describe('Test users API validators', function () { { const res = await uploadVideo(server.url, server.accessToken, {}) - videoId = res.body.video.id + video = res.body.video } { @@ -829,7 +829,7 @@ describe('Test users API validators', function () { describe('When getting my video rating', function () { it('Should fail with a non authenticated user', async function () { - await getMyUserVideoRating(server.url, 'fake_token', videoId, HttpStatusCode.UNAUTHORIZED_401) + await getMyUserVideoRating(server.url, 'fake_token', video.id, HttpStatusCode.UNAUTHORIZED_401) }) it('Should fail with an incorrect video uuid', async function () { @@ -841,7 +841,9 @@ describe('Test users API validators', function () { }) it('Should succeed with the correct parameters', async function () { - await getMyUserVideoRating(server.url, server.accessToken, videoId) + await getMyUserVideoRating(server.url, server.accessToken, video.id) + await getMyUserVideoRating(server.url, server.accessToken, video.uuid) + await getMyUserVideoRating(server.url, server.accessToken, video.shortUUID) }) }) diff --git a/server/tests/api/check-params/video-blacklist.ts b/server/tests/api/check-params/video-blacklist.ts index 3d4837d58..ce7f5fa17 100644 --- a/server/tests/api/check-params/video-blacklist.ts +++ b/server/tests/api/check-params/video-blacklist.ts @@ -191,7 +191,7 @@ describe('Test video blacklist API validators', function () { }) it('Should succeed with the correct params', async function () { - const path = basePath + servers[0].video.uuid + '/blacklist' + const path = basePath + servers[0].video.shortUUID + '/blacklist' const fields = { reason: 'hello' } await makePutBodyRequest({ @@ -222,10 +222,14 @@ describe('Test video blacklist API validators', function () { }) it('Should succeed with an admin', async function () { - const res = await getVideoWithToken(servers[0].url, servers[0].accessToken, servers[0].video.uuid, HttpStatusCode.OK_200) - const video: VideoDetails = res.body + const video = servers[0].video - expect(video.blacklisted).to.be.true + for (const id of [ video.id, video.uuid, video.shortUUID ]) { + const res = await getVideoWithToken(servers[0].url, servers[0].accessToken, id, HttpStatusCode.OK_200) + const video: VideoDetails = res.body + + expect(video.blacklisted).to.be.true + } }) }) diff --git a/server/tests/api/check-params/video-captions.ts b/server/tests/api/check-params/video-captions.ts index 1ce2202d2..c0595c04d 100644 --- a/server/tests/api/check-params/video-captions.ts +++ b/server/tests/api/check-params/video-captions.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' - +import { VideoCreateResult } from '@shared/models' import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { buildAbsoluteFixturePath, @@ -23,7 +23,7 @@ describe('Test video captions API validator', function () { let server: ServerInfo let userAccessToken: string - let videoUUID: string + let video: VideoCreateResult // --------------------------------------------------------------- @@ -36,7 +36,7 @@ describe('Test video captions API validator', function () { { const res = await uploadVideo(server.url, server.accessToken, {}) - videoUUID = res.body.video.uuid + video = res.body.video } { @@ -79,7 +79,7 @@ describe('Test video captions API validator', function () { }) it('Should fail with a missing language in path', async function () { - const captionPath = path + videoUUID + '/captions' + const captionPath = path + video.uuid + '/captions' await makeUploadRequest({ method: 'PUT', url: server.url, @@ -91,7 +91,7 @@ describe('Test video captions API validator', function () { }) it('Should fail with an unknown language', async function () { - const captionPath = path + videoUUID + '/captions/15' + const captionPath = path + video.uuid + '/captions/15' await makeUploadRequest({ method: 'PUT', url: server.url, @@ -103,7 +103,7 @@ describe('Test video captions API validator', function () { }) it('Should fail without access token', async function () { - const captionPath = path + videoUUID + '/captions/fr' + const captionPath = path + video.uuid + '/captions/fr' await makeUploadRequest({ method: 'PUT', url: server.url, @@ -115,7 +115,7 @@ describe('Test video captions API validator', function () { }) it('Should fail with a bad access token', async function () { - const captionPath = path + videoUUID + '/captions/fr' + const captionPath = path + video.uuid + '/captions/fr' await makeUploadRequest({ method: 'PUT', url: server.url, @@ -133,7 +133,7 @@ describe('Test video captions API validator', function () { // 'captionfile': buildAbsoluteFixturePath('subtitle-bad.txt') // } // - // const captionPath = path + videoUUID + '/captions/fr' + // const captionPath = path + video.uuid + '/captions/fr' // await makeUploadRequest({ // method: 'PUT', // url: server.url, @@ -151,7 +151,7 @@ describe('Test video captions API validator', function () { // url: server.url, // accessToken: server.accessToken, // language: 'zh', - // videoId: videoUUID, + // videoId: video.uuid, // fixture: 'subtitle-bad.txt', // mimeType: 'application/octet-stream', // statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 @@ -163,7 +163,7 @@ describe('Test video captions API validator', function () { url: server.url, accessToken: server.accessToken, language: 'zh', - videoId: videoUUID, + videoId: video.uuid, fixture: 'subtitle-good.srt', mimeType: 'application/octet-stream' }) @@ -175,7 +175,7 @@ describe('Test video captions API validator', function () { // 'captionfile': buildAbsoluteFixturePath('subtitle-bad.srt') // } // - // const captionPath = path + videoUUID + '/captions/fr' + // const captionPath = path + video.uuid + '/captions/fr' // await makeUploadRequest({ // method: 'PUT', // url: server.url, @@ -188,7 +188,7 @@ describe('Test video captions API validator', function () { // }) it('Should success with the correct parameters', async function () { - const captionPath = path + videoUUID + '/captions/fr' + const captionPath = path + video.uuid + '/captions/fr' await makeUploadRequest({ method: 'PUT', url: server.url, @@ -215,7 +215,7 @@ describe('Test video captions API validator', function () { }) it('Should success with the correct parameters', async function () { - await makeGetRequest({ url: server.url, path: path + videoUUID + '/captions', statusCodeExpected: HttpStatusCode.OK_200 }) + await makeGetRequest({ url: server.url, path: path + video.shortUUID + '/captions', statusCodeExpected: HttpStatusCode.OK_200 }) }) }) @@ -246,27 +246,27 @@ describe('Test video captions API validator', function () { }) it('Should fail with a missing language', async function () { - const captionPath = path + videoUUID + '/captions' + const captionPath = path + video.shortUUID + '/captions' await makeDeleteRequest({ url: server.url, path: captionPath, token: server.accessToken }) }) it('Should fail with an unknown language', async function () { - const captionPath = path + videoUUID + '/captions/15' + const captionPath = path + video.shortUUID + '/captions/15' await makeDeleteRequest({ url: server.url, path: captionPath, token: server.accessToken }) }) it('Should fail without access token', async function () { - const captionPath = path + videoUUID + '/captions/fr' + const captionPath = path + video.shortUUID + '/captions/fr' await makeDeleteRequest({ url: server.url, path: captionPath, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) }) it('Should fail with a bad access token', async function () { - const captionPath = path + videoUUID + '/captions/fr' + const captionPath = path + video.shortUUID + '/captions/fr' await makeDeleteRequest({ url: server.url, path: captionPath, token: 'coucou', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) }) it('Should fail with another user', async function () { - const captionPath = path + videoUUID + '/captions/fr' + const captionPath = path + video.shortUUID + '/captions/fr' await makeDeleteRequest({ url: server.url, path: captionPath, @@ -276,7 +276,7 @@ describe('Test video captions API validator', function () { }) it('Should success with the correct parameters', async function () { - const captionPath = path + videoUUID + '/captions/fr' + const captionPath = path + video.shortUUID + '/captions/fr' await makeDeleteRequest({ url: server.url, path: captionPath, diff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.ts index 659a10c41..a38420851 100644 --- a/server/tests/api/check-params/video-comments.ts +++ b/server/tests/api/check-params/video-comments.ts @@ -1,7 +1,9 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import * as chai from 'chai' import 'mocha' +import * as chai from 'chai' +import { VideoCreateResult } from '@shared/models' +import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { cleanupTests, createUser, @@ -20,7 +22,6 @@ import { checkBadStartPagination } from '../../../../shared/extra-utils/requests/check-api-params' import { addVideoCommentThread } from '../../../../shared/extra-utils/videos/video-comments' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' const expect = chai.expect @@ -28,7 +29,7 @@ describe('Test video comments API validator', function () { let pathThread: string let pathComment: string let server: ServerInfo - let videoUUID: string + let video: VideoCreateResult let userAccessToken: string let userAccessToken2: string let commentId: number @@ -44,14 +45,14 @@ describe('Test video comments API validator', function () { { const res = await uploadVideo(server.url, server.accessToken, {}) - videoUUID = res.body.video.uuid - pathThread = '/api/v1/videos/' + videoUUID + '/comment-threads' + video = res.body.video + pathThread = '/api/v1/videos/' + video.uuid + '/comment-threads' } { - const res = await addVideoCommentThread(server.url, server.accessToken, videoUUID, 'coucou') + const res = await addVideoCommentThread(server.url, server.accessToken, video.uuid, 'coucou') commentId = res.body.comment.id - pathComment = '/api/v1/videos/' + videoUUID + '/comments/' + commentId + pathComment = '/api/v1/videos/' + video.uuid + '/comments/' + commentId } { @@ -101,7 +102,7 @@ describe('Test video comments API validator', function () { it('Should fail with an incorrect thread id', async function () { await makeGetRequest({ url: server.url, - path: '/api/v1/videos/' + videoUUID + '/comment-threads/156', + path: '/api/v1/videos/' + video.shortUUID + '/comment-threads/156', statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) }) @@ -109,7 +110,7 @@ describe('Test video comments API validator', function () { it('Should success with the correct params', async function () { await makeGetRequest({ url: server.url, - path: '/api/v1/videos/' + videoUUID + '/comment-threads/' + commentId, + path: '/api/v1/videos/' + video.shortUUID + '/comment-threads/' + commentId, statusCodeExpected: HttpStatusCode.OK_200 }) }) @@ -225,7 +226,7 @@ describe('Test video comments API validator', function () { }) it('Should fail with an incorrect comment', async function () { - const path = '/api/v1/videos/' + videoUUID + '/comments/124' + const path = '/api/v1/videos/' + video.uuid + '/comments/124' const fields = { text: 'super comment' } @@ -272,7 +273,7 @@ describe('Test video comments API validator', function () { }) it('Should fail with an incorrect comment', async function () { - const path = '/api/v1/videos/' + videoUUID + '/comments/124' + const path = '/api/v1/videos/' + video.uuid + '/comments/124' await makeDeleteRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) }) @@ -280,11 +281,11 @@ describe('Test video comments API validator', function () { let commentToDelete: number { - const res = await addVideoCommentThread(server.url, userAccessToken, videoUUID, 'hello') + const res = await addVideoCommentThread(server.url, userAccessToken, video.uuid, 'hello') commentToDelete = res.body.comment.id } - const path = '/api/v1/videos/' + videoUUID + '/comments/' + commentToDelete + const path = '/api/v1/videos/' + video.uuid + '/comments/' + commentToDelete await makeDeleteRequest({ url: server.url, path, token: userAccessToken2, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) await makeDeleteRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.NO_CONTENT_204 }) @@ -323,8 +324,8 @@ describe('Test video comments API validator', function () { describe('When a video has comments disabled', function () { before(async function () { const res = await uploadVideo(server.url, server.accessToken, { commentsEnabled: false }) - videoUUID = res.body.video.uuid - pathThread = '/api/v1/videos/' + videoUUID + '/comment-threads' + video = res.body.video + pathThread = '/api/v1/videos/' + video.uuid + '/comment-threads' }) it('Should return an empty thread list', async function () { diff --git a/server/tests/api/check-params/video-playlists.ts b/server/tests/api/check-params/video-playlists.ts index bbea88354..18253d11a 100644 --- a/server/tests/api/check-params/video-playlists.ts +++ b/server/tests/api/check-params/video-playlists.ts @@ -1,8 +1,13 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' +import { VideoPlaylistCreateResult, VideoPlaylistPrivacy, VideoPlaylistType } from '@shared/models' +import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { addVideoInPlaylist, + checkBadCountPagination, + checkBadSortPagination, + checkBadStartPagination, cleanupTests, createVideoPlaylist, deleteVideoPlaylist, @@ -21,20 +26,14 @@ import { updateVideoPlaylistElement, uploadVideoAndGetId } from '../../../../shared/extra-utils' -import { - checkBadCountPagination, - checkBadSortPagination, - checkBadStartPagination -} from '../../../../shared/extra-utils/requests/check-api-params' -import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' -import { VideoPlaylistType } from '../../../../shared/models/videos/playlist/video-playlist-type.model' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' describe('Test video playlists API validator', function () { let server: ServerInfo let userAccessToken: string - let playlistUUID: string + + let playlist: VideoPlaylistCreateResult let privatePlaylistUUID: string + let watchLaterPlaylistId: number let videoId: number let playlistElementId: number @@ -67,7 +66,7 @@ describe('Test video playlists API validator', function () { videoChannelId: server.videoChannel.id } }) - playlistUUID = res.body.videoPlaylist.uuid + playlist = res.body.videoPlaylist } { @@ -150,15 +149,15 @@ describe('Test video playlists API validator', function () { const path = '/api/v1/video-playlists/' it('Should fail with a bad start pagination', async function () { - await checkBadStartPagination(server.url, path + playlistUUID + '/videos', server.accessToken) + await checkBadStartPagination(server.url, path + playlist.shortUUID + '/videos', server.accessToken) }) it('Should fail with a bad count pagination', async function () { - await checkBadCountPagination(server.url, path + playlistUUID + '/videos', server.accessToken) + await checkBadCountPagination(server.url, path + playlist.shortUUID + '/videos', server.accessToken) }) it('Should success with the correct parameters', async function () { - await makeGetRequest({ url: server.url, path: path + playlistUUID + '/videos', statusCodeExpected: HttpStatusCode.OK_200 }) + await makeGetRequest({ url: server.url, path: path + playlist.shortUUID + '/videos', statusCodeExpected: HttpStatusCode.OK_200 }) }) }) @@ -177,6 +176,7 @@ describe('Test video playlists API validator', function () { token: server.accessToken, playlistAttrs: { displayName: 'super playlist', + videoChannelId: server.videoChannel.id, privacy: VideoPlaylistPrivacy.UNLISTED } }) @@ -187,7 +187,7 @@ describe('Test video playlists API validator', function () { }) it('Should succeed with the correct params', async function () { - await getVideoPlaylist(server.url, playlistUUID, HttpStatusCode.OK_200) + await getVideoPlaylist(server.url, playlist.uuid, HttpStatusCode.OK_200) }) }) @@ -213,7 +213,7 @@ describe('Test video playlists API validator', function () { const params = getBase({}, { token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) await createVideoPlaylist(params) - await updateVideoPlaylist(getUpdate(params, playlistUUID)) + await updateVideoPlaylist(getUpdate(params, playlist.shortUUID)) }) it('Should fail without displayName', async function () { @@ -226,42 +226,42 @@ describe('Test video playlists API validator', function () { const params = getBase({ displayName: 's'.repeat(300) }) await createVideoPlaylist(params) - await updateVideoPlaylist(getUpdate(params, playlistUUID)) + await updateVideoPlaylist(getUpdate(params, playlist.shortUUID)) }) it('Should fail with an incorrect description', async function () { const params = getBase({ description: 't' }) await createVideoPlaylist(params) - await updateVideoPlaylist(getUpdate(params, playlistUUID)) + await updateVideoPlaylist(getUpdate(params, playlist.shortUUID)) }) it('Should fail with an incorrect privacy', async function () { const params = getBase({ privacy: 45 }) await createVideoPlaylist(params) - await updateVideoPlaylist(getUpdate(params, playlistUUID)) + await updateVideoPlaylist(getUpdate(params, playlist.shortUUID)) }) it('Should fail with an unknown video channel id', async function () { const params = getBase({ videoChannelId: 42 }, { expectedStatus: HttpStatusCode.NOT_FOUND_404 }) await createVideoPlaylist(params) - await updateVideoPlaylist(getUpdate(params, playlistUUID)) + await updateVideoPlaylist(getUpdate(params, playlist.shortUUID)) }) it('Should fail with an incorrect thumbnail file', async function () { const params = getBase({ thumbnailfile: 'video_short.mp4' }) await createVideoPlaylist(params) - await updateVideoPlaylist(getUpdate(params, playlistUUID)) + await updateVideoPlaylist(getUpdate(params, playlist.shortUUID)) }) it('Should fail with a thumbnail file too big', async function () { const params = getBase({ thumbnailfile: 'preview-big.png' }) await createVideoPlaylist(params) - await updateVideoPlaylist(getUpdate(params, playlistUUID)) + await updateVideoPlaylist(getUpdate(params, playlist.shortUUID)) }) it('Should fail to set "public" a playlist not assigned to a channel', async function () { @@ -272,8 +272,8 @@ describe('Test video playlists API validator', function () { await createVideoPlaylist(params) await createVideoPlaylist(params2) await updateVideoPlaylist(getUpdate(params, privatePlaylistUUID)) - await updateVideoPlaylist(getUpdate(params2, playlistUUID)) - await updateVideoPlaylist(getUpdate(params3, playlistUUID)) + await updateVideoPlaylist(getUpdate(params2, playlist.shortUUID)) + await updateVideoPlaylist(getUpdate(params3, playlist.shortUUID)) }) it('Should fail with an unknown playlist to update', async function () { @@ -286,7 +286,7 @@ describe('Test video playlists API validator', function () { it('Should fail to update a playlist of another user', async function () { await updateVideoPlaylist(getUpdate( getBase({}, { token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }), - playlistUUID + playlist.shortUUID )) }) @@ -305,7 +305,7 @@ describe('Test video playlists API validator', function () { { const params = getBase({}, { expectedStatus: HttpStatusCode.NO_CONTENT_204 }) - await updateVideoPlaylist(getUpdate(params, playlistUUID)) + await updateVideoPlaylist(getUpdate(params, playlist.shortUUID)) } }) }) @@ -316,7 +316,7 @@ describe('Test video playlists API validator', function () { expectedStatus: HttpStatusCode.BAD_REQUEST_400, url: server.url, token: server.accessToken, - playlistId: playlistUUID, + playlistId: playlist.id, elementAttrs: Object.assign({ videoId, startTimestamp: 2, @@ -381,7 +381,7 @@ describe('Test video playlists API validator', function () { stopTimestamp: 2 }, elementAttrs), playlistElementId, - playlistId: playlistUUID, + playlistId: playlist.id, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }, wrapper) } @@ -451,7 +451,7 @@ describe('Test video playlists API validator', function () { return Object.assign({ url: server.url, token: server.accessToken, - playlistId: playlistUUID, + playlistId: playlist.shortUUID, elementAttrs: Object.assign({ startPosition: 1, insertAfterPosition: 2, @@ -469,7 +469,7 @@ describe('Test video playlists API validator', function () { await addVideoInPlaylist({ url: server.url, token: server.accessToken, - playlistId: playlistUUID, + playlistId: playlist.shortUUID, elementAttrs: { videoId: id } }) } @@ -606,7 +606,7 @@ describe('Test video playlists API validator', function () { url: server.url, token: server.accessToken, playlistElementId, - playlistId: playlistUUID, + playlistId: playlist.uuid, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }, wrapper) } @@ -662,7 +662,7 @@ describe('Test video playlists API validator', function () { }) it('Should fail with a playlist of another user', async function () { - await deleteVideoPlaylist(server.url, userAccessToken, playlistUUID, HttpStatusCode.FORBIDDEN_403) + await deleteVideoPlaylist(server.url, userAccessToken, playlist.uuid, HttpStatusCode.FORBIDDEN_403) }) it('Should fail with the watch later playlist', async function () { @@ -670,7 +670,7 @@ describe('Test video playlists API validator', function () { }) it('Should succeed with the correct params', async function () { - await deleteVideoPlaylist(server.url, server.accessToken, playlistUUID) + await deleteVideoPlaylist(server.url, server.accessToken, playlist.uuid) }) }) 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' import { omit } from 'lodash' import { join } from 'path' import { randomInt } from '@shared/core-utils' -import { PeerTubeProblemDocument } from '@shared/models' +import { PeerTubeProblemDocument, VideoCreateResult } from '@shared/models' import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { checkUploadVideoParam, @@ -42,7 +42,7 @@ describe('Test videos API validator', function () { let accountName: string let channelId: number let channelName: string - let videoId + let video: VideoCreateResult // --------------------------------------------------------------- @@ -490,7 +490,7 @@ describe('Test videos API validator', function () { before(async function () { const res = await getVideosList(server.url) - videoId = res.body.data[0].uuid + video = res.body.data[0] }) it('Should fail with nothing', async function () { @@ -518,79 +518,79 @@ describe('Test videos API validator', function () { it('Should fail with a long name', async function () { const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) }) - await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) + await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) }) it('Should fail with a bad category', async function () { const fields = immutableAssign(baseCorrectParams, { category: 125 }) - await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) + await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) }) it('Should fail with a bad licence', async function () { const fields = immutableAssign(baseCorrectParams, { licence: 125 }) - await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) + await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) }) it('Should fail with a bad language', async function () { const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) }) - await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) + await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) }) it('Should fail with a long description', async function () { const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) }) - await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) + await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) }) it('Should fail with a long support text', async function () { const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) }) - await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) + await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) }) it('Should fail with a bad channel', async function () { const fields = immutableAssign(baseCorrectParams, { channelId: 545454 }) - await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) + await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) }) it('Should fail with too many tags', async function () { const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }) - await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) + await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) }) it('Should fail with a tag length too low', async function () { const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] }) - await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) + await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) }) it('Should fail with a tag length too big', async function () { const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }) - await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) + await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) }) it('Should fail with a bad schedule update (miss updateAt)', async function () { const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } }) - await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) + await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) }) it('Should fail with a bad schedule update (wrong updateAt)', async function () { const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { updateAt: 'toto', privacy: VideoPrivacy.PUBLIC } }) - await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) + await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) }) it('Should fail with a bad originally published at param', async function () { const fields = immutableAssign(baseCorrectParams, { originallyPublishedAt: 'toto' }) - await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) + await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) }) it('Should fail with an incorrect thumbnail file', async function () { @@ -602,7 +602,7 @@ describe('Test videos API validator', function () { await makeUploadRequest({ url: server.url, method: 'PUT', - path: path + videoId, + path: path + video.shortUUID, token: server.accessToken, fields, attaches @@ -618,7 +618,7 @@ describe('Test videos API validator', function () { await makeUploadRequest({ url: server.url, method: 'PUT', - path: path + videoId, + path: path + video.shortUUID, token: server.accessToken, fields, attaches @@ -634,7 +634,7 @@ describe('Test videos API validator', function () { await makeUploadRequest({ url: server.url, method: 'PUT', - path: path + videoId, + path: path + video.shortUUID, token: server.accessToken, fields, attaches @@ -650,7 +650,7 @@ describe('Test videos API validator', function () { await makeUploadRequest({ url: server.url, method: 'PUT', - path: path + videoId, + path: path + video.shortUUID, token: server.accessToken, fields, attaches @@ -662,7 +662,7 @@ describe('Test videos API validator', function () { await makePutBodyRequest({ url: server.url, - path: path + videoId, + path: path + video.shortUUID, token: userAccessToken, fields, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 @@ -674,7 +674,7 @@ describe('Test videos API validator', function () { it('Shoud report the appropriate error', async function () { const fields = immutableAssign(baseCorrectParams, { licence: 125 }) - const res = await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) + const res = await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) const error = res.body as PeerTubeProblemDocument 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 () { await makePutBodyRequest({ url: server.url, - path: path + videoId, + path: path + video.shortUUID, token: server.accessToken, fields, statusCodeExpected: HttpStatusCode.NO_CONTENT_204 @@ -739,7 +739,7 @@ describe('Test videos API validator', function () { }) it('Should succeed with the correct parameters', async function () { - await getVideo(server.url, videoId) + await getVideo(server.url, video.shortUUID) }) }) @@ -810,7 +810,7 @@ describe('Test videos API validator', function () { }) it('Should fail with a video of another user without the appropriate right', async function () { - await removeVideo(server.url, userAccessToken, videoId, HttpStatusCode.FORBIDDEN_403) + await removeVideo(server.url, userAccessToken, video.uuid, HttpStatusCode.FORBIDDEN_403) }) it('Should fail with a video of another server') @@ -832,7 +832,7 @@ describe('Test videos API validator', function () { }) it('Should succeed with the correct parameters', async function () { - await removeVideo(server.url, server.accessToken, videoId) + await removeVideo(server.url, server.accessToken, video.uuid) }) }) diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts index 4ce6675b6..3425480ae 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' -import { v4 as uuidv4 } from 'uuid' +import { buildUUID } from '@server/helpers/uuid' import { AbuseState } from '@shared/models' import { addAbuseMessage, @@ -85,7 +85,7 @@ describe('Test moderation notifications', function () { it('Should send a notification to moderators on local video abuse', async function () { this.timeout(20000) - const name = 'video for abuse ' + uuidv4() + const name = 'video for abuse ' + buildUUID() const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) const video = resVideo.body.video @@ -98,7 +98,7 @@ describe('Test moderation notifications', function () { it('Should send a notification to moderators on remote video abuse', async function () { this.timeout(20000) - const name = 'video for abuse ' + uuidv4() + const name = 'video for abuse ' + buildUUID() const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) const video = resVideo.body.video @@ -114,10 +114,10 @@ describe('Test moderation notifications', function () { it('Should send a notification to moderators on local comment abuse', async function () { this.timeout(20000) - const name = 'video for abuse ' + uuidv4() + const name = 'video for abuse ' + buildUUID() const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) const video = resVideo.body.video - const resComment = await addVideoCommentThread(servers[0].url, userAccessToken, video.id, 'comment abuse ' + uuidv4()) + const resComment = await addVideoCommentThread(servers[0].url, userAccessToken, video.id, 'comment abuse ' + buildUUID()) const comment = resComment.body.comment await waitJobs(servers) @@ -131,10 +131,10 @@ describe('Test moderation notifications', function () { it('Should send a notification to moderators on remote comment abuse', async function () { this.timeout(20000) - const name = 'video for abuse ' + uuidv4() + const name = 'video for abuse ' + buildUUID() const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) const video = resVideo.body.video - await addVideoCommentThread(servers[0].url, userAccessToken, video.id, 'comment abuse ' + uuidv4()) + await addVideoCommentThread(servers[0].url, userAccessToken, video.id, 'comment abuse ' + buildUUID()) await waitJobs(servers) @@ -188,7 +188,7 @@ describe('Test moderation notifications', function () { token: userAccessToken } - const name = 'abuse ' + uuidv4() + const name = 'abuse ' + buildUUID() const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) const video = resVideo.body.video @@ -236,7 +236,7 @@ describe('Test moderation notifications', function () { token: servers[0].accessToken } - const name = 'abuse ' + uuidv4() + const name = 'abuse ' + buildUUID() const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) const video = resVideo.body.video @@ -307,7 +307,7 @@ describe('Test moderation notifications', function () { it('Should send a notification to video owner on blacklist', async function () { this.timeout(10000) - const name = 'video for abuse ' + uuidv4() + const name = 'video for abuse ' + buildUUID() const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) const uuid = resVideo.body.video.uuid @@ -320,7 +320,7 @@ describe('Test moderation notifications', function () { it('Should send a notification to video owner on unblacklist', async function () { this.timeout(10000) - const name = 'video for abuse ' + uuidv4() + const name = 'video for abuse ' + buildUUID() const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) const uuid = resVideo.body.video.uuid @@ -507,7 +507,7 @@ describe('Test moderation notifications', function () { it('Should send notification to moderators on new video with auto-blacklist', async function () { this.timeout(40000) - videoName = 'video with auto-blacklist ' + uuidv4() + videoName = 'video with auto-blacklist ' + buildUUID() const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: videoName }) videoUUID = resVideo.body.video.uuid @@ -553,7 +553,7 @@ describe('Test moderation notifications', function () { const updateAt = new Date(new Date().getTime() + 1000000) - const name = 'video with auto-blacklist and future schedule ' + uuidv4() + const name = 'video with auto-blacklist and future schedule ' + buildUUID() const data = { name, @@ -586,7 +586,7 @@ describe('Test moderation notifications', function () { // In 2 seconds const updateAt = new Date(new Date().getTime() + 2000) - const name = 'video with schedule done and still auto-blacklisted ' + uuidv4() + const name = 'video with schedule done and still auto-blacklisted ' + buildUUID() const data = { name, @@ -609,7 +609,7 @@ describe('Test moderation notifications', function () { it('Should not send a notification to moderators on new video without auto-blacklist', async function () { this.timeout(60000) - const name = 'video without auto-blacklist ' + uuidv4() + const name = 'video without auto-blacklist ' + buildUUID() // admin with blacklist right will not be auto-blacklisted const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name }) diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts index 7e88d979b..e981c1718 100644 --- a/server/tests/api/notifications/user-notifications.ts +++ b/server/tests/api/notifications/user-notifications.ts @@ -2,7 +2,7 @@ import 'mocha' import * as chai from 'chai' -import { v4 as uuidv4 } from 'uuid' +import { buildUUID } from '@server/helpers/uuid' import { cleanupTests, updateMyUser, @@ -207,7 +207,7 @@ describe('Test user notifications', function () { it('Should send a new video notification after a video import', async function () { this.timeout(100000) - const name = 'video import ' + uuidv4() + const name = 'video import ' + buildUUID() const attributes = { name, @@ -278,7 +278,7 @@ describe('Test user notifications', function () { it('Should send a notification when an imported video is transcoded', async function () { this.timeout(50000) - const name = 'video import ' + uuidv4() + const name = 'video import ' + buildUUID() const attributes = { name, @@ -347,7 +347,7 @@ describe('Test user notifications', function () { it('Should send a notification when the video import failed', async function () { this.timeout(70000) - const name = 'video import ' + uuidv4() + const name = 'video import ' + buildUUID() const attributes = { name, @@ -365,7 +365,7 @@ describe('Test user notifications', function () { it('Should send a notification when the video import succeeded', async function () { this.timeout(70000) - const name = 'video import ' + uuidv4() + const name = 'video import ' + buildUUID() const attributes = { name, diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts index fe4a0e100..d57d72f5e 100644 --- a/server/tests/api/server/handle-down.ts +++ b/server/tests/api/server/handle-down.ts @@ -47,7 +47,7 @@ describe('Test handle downs', function () { let missedVideo2: Video let unlistedVideo: Video - const videoIdsServer1: number[] = [] + const videoIdsServer1: string[] = [] const videoAttributes = { name: 'my super name for server 1', diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts index 9dad58c8c..da8de054b 100644 --- a/server/tests/api/videos/video-playlists.ts +++ b/server/tests/api/videos/video-playlists.ts @@ -56,7 +56,7 @@ import { removeServerFromServerBlocklist } from '../../../../shared/extra-utils/users/blocklist' import { User } from '../../../../shared/models/users' -import { VideoPrivacy } from '../../../../shared/models/videos' +import { VideoPlaylistCreateResult, VideoPrivacy } from '../../../../shared/models/videos' import { VideoExistInPlaylist } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model' import { VideoPlaylistElement, VideoPlaylistElementType } from '../../../../shared/models/videos/playlist/video-playlist-element.model' import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' @@ -427,31 +427,45 @@ describe('Test video playlists', function () { expect(data).to.have.lengthOf(0) } }) + }) - it('Should not list unlisted or private playlists', async function () { + describe('Playlist rights', function () { + let unlistedPlaylist: VideoPlaylistCreateResult + let privatePlaylist: VideoPlaylistCreateResult + + before(async function () { this.timeout(30000) - await createVideoPlaylist({ - url: servers[1].url, - token: servers[1].accessToken, - playlistAttrs: { - displayName: 'playlist unlisted', - privacy: VideoPlaylistPrivacy.UNLISTED - } - }) + { + const res = await createVideoPlaylist({ + url: servers[1].url, + token: servers[1].accessToken, + playlistAttrs: { + displayName: 'playlist unlisted', + privacy: VideoPlaylistPrivacy.UNLISTED, + videoChannelId: servers[1].videoChannel.id + } + }) + unlistedPlaylist = res.body.videoPlaylist + } - await createVideoPlaylist({ - url: servers[1].url, - token: servers[1].accessToken, - playlistAttrs: { - displayName: 'playlist private', - privacy: VideoPlaylistPrivacy.PRIVATE - } - }) + { + const res = await createVideoPlaylist({ + url: servers[1].url, + token: servers[1].accessToken, + playlistAttrs: { + displayName: 'playlist private', + privacy: VideoPlaylistPrivacy.PRIVATE + } + }) + privatePlaylist = res.body.videoPlaylist + } await waitJobs(servers) await wait(3000) + }) + it('Should not list unlisted or private playlists', async function () { for (const server of servers) { const results = [ await getAccountPlaylistsList(server.url, 'root@localhost:' + servers[1].port, 0, 5, '-createdAt'), @@ -469,6 +483,27 @@ describe('Test video playlists', function () { } } }) + + it('Should not get unlisted playlist using only the id', async function () { + await getVideoPlaylist(servers[1].url, unlistedPlaylist.id, 404) + }) + + it('Should get unlisted plyaylist using uuid or shortUUID', async function () { + await getVideoPlaylist(servers[1].url, unlistedPlaylist.uuid) + await getVideoPlaylist(servers[1].url, unlistedPlaylist.shortUUID) + }) + + it('Should not get private playlist without token', async function () { + for (const id of [ privatePlaylist.id, privatePlaylist.uuid, privatePlaylist.shortUUID ]) { + await getVideoPlaylist(servers[1].url, id, 401) + } + }) + + it('Should get private playlist with a token', async function () { + for (const id of [ privatePlaylist.id, privatePlaylist.uuid, privatePlaylist.shortUUID ]) { + await getVideoPlaylistWithToken(servers[1].url, servers[1].accessToken, id) + } + }) }) describe('Update playlists', function () { diff --git a/server/tests/api/videos/video-privacy.ts b/server/tests/api/videos/video-privacy.ts index fed6ca0e0..950aeb7cf 100644 --- a/server/tests/api/videos/video-privacy.ts +++ b/server/tests/api/videos/video-privacy.ts @@ -1,8 +1,9 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import * as chai from 'chai' import 'mocha' -import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' +import * as chai from 'chai' +import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' +import { Video, VideoCreateResult } from '@shared/models' import { cleanupTests, flushAndRunServer, @@ -13,12 +14,11 @@ import { uploadVideo } from '../../../../shared/extra-utils/index' import { doubleFollow } from '../../../../shared/extra-utils/server/follows' +import { waitJobs } from '../../../../shared/extra-utils/server/jobs' import { userLogin } from '../../../../shared/extra-utils/users/login' import { createUser } from '../../../../shared/extra-utils/users/users' import { getMyVideos, getVideo, getVideoWithToken, updateVideo } from '../../../../shared/extra-utils/videos/videos' -import { waitJobs } from '../../../../shared/extra-utils/server/jobs' -import { Video } from '@shared/models' -import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' +import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' const expect = chai.expect @@ -32,7 +32,7 @@ describe('Test video privacy', function () { let internalVideoId: number let internalVideoUUID: string - let unlistedVideoUUID: string + let unlistedVideo: VideoCreateResult let nonFederatedUnlistedVideoUUID: string let now: number @@ -59,231 +59,246 @@ describe('Test video privacy', function () { await doubleFollow(servers[0], servers[1]) }) - it('Should upload a private and internal videos on server 1', async function () { - this.timeout(10000) + describe('Private and internal videos', function () { - for (const privacy of [ VideoPrivacy.PRIVATE, VideoPrivacy.INTERNAL ]) { - const attributes = { privacy } - await uploadVideo(servers[0].url, servers[0].accessToken, attributes) - } + it('Should upload a private and internal videos on server 1', async function () { + this.timeout(10000) - await waitJobs(servers) - }) + for (const privacy of [ VideoPrivacy.PRIVATE, VideoPrivacy.INTERNAL ]) { + const attributes = { privacy } + await uploadVideo(servers[0].url, servers[0].accessToken, attributes) + } - it('Should not have these private and internal videos on server 2', async function () { - const res = await getVideosList(servers[1].url) + await waitJobs(servers) + }) - expect(res.body.total).to.equal(0) - expect(res.body.data).to.have.lengthOf(0) - }) + it('Should not have these private and internal videos on server 2', async function () { + const res = await getVideosList(servers[1].url) - it('Should not list the private and internal videos for an unauthenticated user on server 1', async function () { - const res = await getVideosList(servers[0].url) + expect(res.body.total).to.equal(0) + expect(res.body.data).to.have.lengthOf(0) + }) - expect(res.body.total).to.equal(0) - expect(res.body.data).to.have.lengthOf(0) - }) + it('Should not list the private and internal videos for an unauthenticated user on server 1', async function () { + const res = await getVideosList(servers[0].url) + + expect(res.body.total).to.equal(0) + expect(res.body.data).to.have.lengthOf(0) + }) - it('Should not list the private video and list the internal video for an authenticated user on server 1', async function () { - const res = await getVideosListWithToken(servers[0].url, servers[0].accessToken) + it('Should not list the private video and list the internal video for an authenticated user on server 1', async function () { + const res = await getVideosListWithToken(servers[0].url, servers[0].accessToken) - expect(res.body.total).to.equal(1) - expect(res.body.data).to.have.lengthOf(1) + expect(res.body.total).to.equal(1) + expect(res.body.data).to.have.lengthOf(1) - expect(res.body.data[0].privacy.id).to.equal(VideoPrivacy.INTERNAL) - }) + expect(res.body.data[0].privacy.id).to.equal(VideoPrivacy.INTERNAL) + }) - it('Should list my (private and internal) videos', async function () { - const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 10) + it('Should list my (private and internal) videos', async function () { + const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 10) - expect(res.body.total).to.equal(2) - expect(res.body.data).to.have.lengthOf(2) + expect(res.body.total).to.equal(2) + expect(res.body.data).to.have.lengthOf(2) - const videos: Video[] = res.body.data + const videos: Video[] = res.body.data - const privateVideo = videos.find(v => v.privacy.id === VideoPrivacy.PRIVATE) - privateVideoId = privateVideo.id - privateVideoUUID = privateVideo.uuid + const privateVideo = videos.find(v => v.privacy.id === VideoPrivacy.PRIVATE) + privateVideoId = privateVideo.id + privateVideoUUID = privateVideo.uuid - const internalVideo = videos.find(v => v.privacy.id === VideoPrivacy.INTERNAL) - internalVideoId = internalVideo.id - internalVideoUUID = internalVideo.uuid - }) + const internalVideo = videos.find(v => v.privacy.id === VideoPrivacy.INTERNAL) + internalVideoId = internalVideo.id + internalVideoUUID = internalVideo.uuid + }) - it('Should not be able to watch the private/internal video with non authenticated user', async function () { - await getVideo(servers[0].url, privateVideoUUID, HttpStatusCode.UNAUTHORIZED_401) - await getVideo(servers[0].url, internalVideoUUID, HttpStatusCode.UNAUTHORIZED_401) - }) + it('Should not be able to watch the private/internal video with non authenticated user', async function () { + await getVideo(servers[0].url, privateVideoUUID, HttpStatusCode.UNAUTHORIZED_401) + await getVideo(servers[0].url, internalVideoUUID, HttpStatusCode.UNAUTHORIZED_401) + }) - it('Should not be able to watch the private video with another user', async function () { - this.timeout(10000) + it('Should not be able to watch the private video with another user', async function () { + this.timeout(10000) - const user = { - username: 'hello', - password: 'super password' - } - await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) + const user = { + username: 'hello', + password: 'super password' + } + await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) - anotherUserToken = await userLogin(servers[0], user) - await getVideoWithToken(servers[0].url, anotherUserToken, privateVideoUUID, HttpStatusCode.FORBIDDEN_403) - }) + anotherUserToken = await userLogin(servers[0], user) + await getVideoWithToken(servers[0].url, anotherUserToken, privateVideoUUID, HttpStatusCode.FORBIDDEN_403) + }) - it('Should be able to watch the internal video with another user', async function () { - await getVideoWithToken(servers[0].url, anotherUserToken, internalVideoUUID, HttpStatusCode.OK_200) - }) + it('Should be able to watch the internal video with another user', async function () { + await getVideoWithToken(servers[0].url, anotherUserToken, internalVideoUUID, HttpStatusCode.OK_200) + }) - it('Should be able to watch the private video with the correct user', async function () { - await getVideoWithToken(servers[0].url, servers[0].accessToken, privateVideoUUID, HttpStatusCode.OK_200) + it('Should be able to watch the private video with the correct user', async function () { + await getVideoWithToken(servers[0].url, servers[0].accessToken, privateVideoUUID, HttpStatusCode.OK_200) + }) }) - it('Should upload an unlisted video on server 2', async function () { - this.timeout(60000) + describe('Unlisted videos', function () { - const attributes = { - name: 'unlisted video', - privacy: VideoPrivacy.UNLISTED - } - await uploadVideo(servers[1].url, servers[1].accessToken, attributes) + it('Should upload an unlisted video on server 2', async function () { + this.timeout(60000) - // Server 2 has transcoding enabled - await waitJobs(servers) - }) + const attributes = { + name: 'unlisted video', + privacy: VideoPrivacy.UNLISTED + } + await uploadVideo(servers[1].url, servers[1].accessToken, attributes) - it('Should not have this unlisted video listed on server 1 and 2', async function () { - for (const server of servers) { - const res = await getVideosList(server.url) + // Server 2 has transcoding enabled + await waitJobs(servers) + }) - expect(res.body.total).to.equal(0) - expect(res.body.data).to.have.lengthOf(0) - } - }) + it('Should not have this unlisted video listed on server 1 and 2', async function () { + for (const server of servers) { + const res = await getVideosList(server.url) - it('Should list my (unlisted) videos', async function () { - const res = await getMyVideos(servers[1].url, servers[1].accessToken, 0, 1) + expect(res.body.total).to.equal(0) + expect(res.body.data).to.have.lengthOf(0) + } + }) - expect(res.body.total).to.equal(1) - expect(res.body.data).to.have.lengthOf(1) + it('Should list my (unlisted) videos', async function () { + const res = await getMyVideos(servers[1].url, servers[1].accessToken, 0, 1) - unlistedVideoUUID = res.body.data[0].uuid - }) + expect(res.body.total).to.equal(1) + expect(res.body.data).to.have.lengthOf(1) - it('Should be able to get this unlisted video', async function () { - for (const server of servers) { - const res = await getVideo(server.url, unlistedVideoUUID) + unlistedVideo = res.body.data[0] + }) - expect(res.body.name).to.equal('unlisted video') - } - }) + it('Should not be able to get this unlisted video using its id', async function () { + await getVideo(servers[1].url, unlistedVideo.id, 404) + }) - it('Should upload a non-federating unlisted video to server 1', async function () { - this.timeout(30000) + it('Should be able to get this unlisted video using its uuid/shortUUID', async function () { + for (const server of servers) { + for (const id of [ unlistedVideo.uuid, unlistedVideo.shortUUID ]) { + const res = await getVideo(server.url, id) - const attributes = { - name: 'unlisted video', - privacy: VideoPrivacy.UNLISTED - } - await uploadVideo(servers[0].url, servers[0].accessToken, attributes) + expect(res.body.name).to.equal('unlisted video') + } + } + }) - await waitJobs(servers) - }) + it('Should upload a non-federating unlisted video to server 1', async function () { + this.timeout(30000) + + const attributes = { + name: 'unlisted video', + privacy: VideoPrivacy.UNLISTED + } + await uploadVideo(servers[0].url, servers[0].accessToken, attributes) - it('Should list my new unlisted video', async function () { - const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 3) + await waitJobs(servers) + }) - expect(res.body.total).to.equal(3) - expect(res.body.data).to.have.lengthOf(3) + it('Should list my new unlisted video', async function () { + const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 3) - nonFederatedUnlistedVideoUUID = res.body.data[0].uuid - }) + expect(res.body.total).to.equal(3) + expect(res.body.data).to.have.lengthOf(3) - it('Should be able to get non-federated unlisted video from origin', async function () { - const res = await getVideo(servers[0].url, nonFederatedUnlistedVideoUUID) + nonFederatedUnlistedVideoUUID = res.body.data[0].uuid + }) - expect(res.body.name).to.equal('unlisted video') - }) + it('Should be able to get non-federated unlisted video from origin', async function () { + const res = await getVideo(servers[0].url, nonFederatedUnlistedVideoUUID) - it('Should not be able to get non-federated unlisted video from federated server', async function () { - await getVideo(servers[1].url, nonFederatedUnlistedVideoUUID, HttpStatusCode.NOT_FOUND_404) + expect(res.body.name).to.equal('unlisted video') + }) + + it('Should not be able to get non-federated unlisted video from federated server', async function () { + await getVideo(servers[1].url, nonFederatedUnlistedVideoUUID, HttpStatusCode.NOT_FOUND_404) + }) }) - it('Should update the private and internal videos to public on server 1', async function () { - this.timeout(10000) + describe('Privacy update', function () { - now = Date.now() + it('Should update the private and internal videos to public on server 1', async function () { + this.timeout(10000) - { - const attribute = { - name: 'private video becomes public', - privacy: VideoPrivacy.PUBLIC - } + now = Date.now() - await updateVideo(servers[0].url, servers[0].accessToken, privateVideoId, attribute) - } + { + const attribute = { + name: 'private video becomes public', + privacy: VideoPrivacy.PUBLIC + } - { - const attribute = { - name: 'internal video becomes public', - privacy: VideoPrivacy.PUBLIC + await updateVideo(servers[0].url, servers[0].accessToken, privateVideoId, attribute) } - await updateVideo(servers[0].url, servers[0].accessToken, internalVideoId, attribute) - } - await waitJobs(servers) - }) + { + const attribute = { + name: 'internal video becomes public', + privacy: VideoPrivacy.PUBLIC + } + await updateVideo(servers[0].url, servers[0].accessToken, internalVideoId, attribute) + } - it('Should have this new public video listed on server 1 and 2', async function () { - for (const server of servers) { - const res = await getVideosList(server.url) - expect(res.body.total).to.equal(2) - expect(res.body.data).to.have.lengthOf(2) + await waitJobs(servers) + }) - const videos: Video[] = res.body.data - const privateVideo = videos.find(v => v.name === 'private video becomes public') - const internalVideo = videos.find(v => v.name === 'internal video becomes public') + it('Should have this new public video listed on server 1 and 2', async function () { + for (const server of servers) { + const res = await getVideosList(server.url) + expect(res.body.total).to.equal(2) + expect(res.body.data).to.have.lengthOf(2) - expect(privateVideo).to.not.be.undefined - expect(internalVideo).to.not.be.undefined + const videos: Video[] = res.body.data + const privateVideo = videos.find(v => v.name === 'private video becomes public') + const internalVideo = videos.find(v => v.name === 'internal video becomes public') - expect(new Date(privateVideo.publishedAt).getTime()).to.be.at.least(now) - // We don't change the publish date of internal videos - expect(new Date(internalVideo.publishedAt).getTime()).to.be.below(now) + expect(privateVideo).to.not.be.undefined + expect(internalVideo).to.not.be.undefined - expect(privateVideo.privacy.id).to.equal(VideoPrivacy.PUBLIC) - expect(internalVideo.privacy.id).to.equal(VideoPrivacy.PUBLIC) - } - }) + expect(new Date(privateVideo.publishedAt).getTime()).to.be.at.least(now) + // We don't change the publish date of internal videos + expect(new Date(internalVideo.publishedAt).getTime()).to.be.below(now) - it('Should set these videos as private and internal', async function () { - this.timeout(10000) + expect(privateVideo.privacy.id).to.equal(VideoPrivacy.PUBLIC) + expect(internalVideo.privacy.id).to.equal(VideoPrivacy.PUBLIC) + } + }) - await updateVideo(servers[0].url, servers[0].accessToken, internalVideoId, { privacy: VideoPrivacy.PRIVATE }) - await updateVideo(servers[0].url, servers[0].accessToken, privateVideoId, { privacy: VideoPrivacy.INTERNAL }) + it('Should set these videos as private and internal', async function () { + this.timeout(10000) - await waitJobs(servers) + await updateVideo(servers[0].url, servers[0].accessToken, internalVideoId, { privacy: VideoPrivacy.PRIVATE }) + await updateVideo(servers[0].url, servers[0].accessToken, privateVideoId, { privacy: VideoPrivacy.INTERNAL }) - for (const server of servers) { - const res = await getVideosList(server.url) + await waitJobs(servers) - expect(res.body.total).to.equal(0) - expect(res.body.data).to.have.lengthOf(0) - } + for (const server of servers) { + const res = await getVideosList(server.url) + + expect(res.body.total).to.equal(0) + expect(res.body.data).to.have.lengthOf(0) + } - { - const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 5) - const videos = res.body.data + { + const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 5) + const videos = res.body.data - expect(res.body.total).to.equal(3) - expect(videos).to.have.lengthOf(3) + expect(res.body.total).to.equal(3) + expect(videos).to.have.lengthOf(3) - const privateVideo = videos.find(v => v.name === 'private video becomes public') - const internalVideo = videos.find(v => v.name === 'internal video becomes public') + const privateVideo = videos.find(v => v.name === 'private video becomes public') + const internalVideo = videos.find(v => v.name === 'internal video becomes public') - expect(privateVideo).to.not.be.undefined - expect(internalVideo).to.not.be.undefined + expect(privateVideo).to.not.be.undefined + expect(internalVideo).to.not.be.undefined - expect(privateVideo.privacy.id).to.equal(VideoPrivacy.INTERNAL) - expect(internalVideo.privacy.id).to.equal(VideoPrivacy.PRIVATE) - } + expect(privateVideo.privacy.id).to.equal(VideoPrivacy.INTERNAL) + expect(internalVideo.privacy.id).to.equal(VideoPrivacy.PRIVATE) + } + }) }) after(async function () { -- cgit v1.2.3