X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fvideos%2Fvideo-privacy.ts;h=38e93bbe631361d23c9a05f55e6e7636feee6672;hb=daf6e4801052d3ca6be2fafd20bae2323b1ce175;hp=e630ca84af2f6d303b41d22afcdc45f682d345eb;hpb=22a73cb879a5cc775d4bec3d72fa9c9cf52e5175;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/videos/video-privacy.ts b/server/tests/api/videos/video-privacy.ts index e630ca84a..38e93bbe6 100644 --- a/server/tests/api/videos/video-privacy.ts +++ b/server/tests/api/videos/video-privacy.ts @@ -1,12 +1,13 @@ -/* tslint:disable:no-unused-expression */ +/* 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 { cleanupTests, - flushAndRunMultipleServers, - getVideosList, getVideosListWithToken, + flushAndRunServer, + getVideosList, + getVideosListWithToken, ServerInfo, setAccessTokensToServers, uploadVideo @@ -21,7 +22,7 @@ import { Video } from '@shared/models' const expect = chai.expect describe('Test video privacy', function () { - let servers: ServerInfo[] = [] + const servers: ServerInfo[] = [] let anotherUserToken: string let privateVideoId: number @@ -31,14 +32,24 @@ describe('Test video privacy', function () { let internalVideoUUID: string let unlistedVideoUUID: string + let nonFederatedUnlistedVideoUUID: string let now: number + const dontFederateUnlistedConfig = { + federation: { + videos: { + federate_unlisted: false + } + } + } + before(async function () { this.timeout(50000) // Run servers - servers = await flushAndRunMultipleServers(2) + servers.push(await flushAndRunServer(1, dontFederateUnlistedConfig)) + servers.push(await flushAndRunServer(2)) // Get the access tokens await setAccessTokensToServers(servers) @@ -110,7 +121,7 @@ describe('Test video privacy', function () { username: 'hello', password: 'super password' } - await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: user.username, password: user.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, 403) @@ -163,6 +174,37 @@ describe('Test video privacy', function () { } }) + 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) + + await waitJobs(servers) + }) + + it('Should list my new unlisted video', async function () { + const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 3) + + expect(res.body.total).to.equal(3) + expect(res.body.data).to.have.lengthOf(3) + + nonFederatedUnlistedVideoUUID = res.body.data[0].uuid + }) + + it('Should be able to get non-federated unlisted video from origin', async function () { + const res = await getVideo(servers[0].url, nonFederatedUnlistedVideoUUID) + + 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, 404) + }) + it('Should update the private and internal videos to public on server 1', async function () { this.timeout(10000) @@ -174,7 +216,7 @@ describe('Test video privacy', function () { privacy: VideoPrivacy.PUBLIC } - await updateVideo(servers[ 0 ].url, servers[ 0 ].accessToken, privateVideoId, attribute) + await updateVideo(servers[0].url, servers[0].accessToken, privateVideoId, attribute) } { @@ -182,7 +224,7 @@ describe('Test video privacy', function () { name: 'internal video becomes public', privacy: VideoPrivacy.PUBLIC } - await updateVideo(servers[ 0 ].url, servers[ 0 ].accessToken, internalVideoId, attribute) + await updateVideo(servers[0].url, servers[0].accessToken, internalVideoId, attribute) } await waitJobs(servers) @@ -229,8 +271,8 @@ describe('Test video privacy', function () { const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 5) const videos = res.body.data - expect(res.body.total).to.equal(2) - expect(videos).to.have.lengthOf(2) + 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')