diff options
author | Levi Bard <taktaktaktaktaktaktaktaktaktak@gmail.com> | 2020-06-03 09:42:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-03 09:42:07 +0200 |
commit | 3092e9bbb05fe292fd13bc685b89069c3dda55d9 (patch) | |
tree | 42b9d04dd7749e835e09cb912677aaad21333a5d /server/tests/api/videos/video-privacy.ts | |
parent | 78646451c9896db3c2239270cd7e100305749f41 (diff) | |
download | PeerTube-3092e9bbb05fe292fd13bc685b89069c3dda55d9.tar.gz PeerTube-3092e9bbb05fe292fd13bc685b89069c3dda55d9.tar.zst PeerTube-3092e9bbb05fe292fd13bc685b89069c3dda55d9.zip |
Make federation of unlisted videos an instance-level server preference (#2802)
* Add preference for federating unlisted videos
* Connect unlisted video federation with new preference
* Apply pull request feedback
* Fix lint issues
* Remove preference for federating unlisted videos from web admin interface
Diffstat (limited to 'server/tests/api/videos/video-privacy.ts')
-rw-r--r-- | server/tests/api/videos/video-privacy.ts | 51 |
1 files changed, 46 insertions, 5 deletions
diff --git a/server/tests/api/videos/video-privacy.ts b/server/tests/api/videos/video-privacy.ts index 4bbbb90f3..38e93bbe6 100644 --- a/server/tests/api/videos/video-privacy.ts +++ b/server/tests/api/videos/video-privacy.ts | |||
@@ -5,7 +5,7 @@ import 'mocha' | |||
5 | import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' | 5 | import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' |
6 | import { | 6 | import { |
7 | cleanupTests, | 7 | cleanupTests, |
8 | flushAndRunMultipleServers, | 8 | flushAndRunServer, |
9 | getVideosList, | 9 | getVideosList, |
10 | getVideosListWithToken, | 10 | getVideosListWithToken, |
11 | ServerInfo, | 11 | ServerInfo, |
@@ -22,7 +22,7 @@ import { Video } from '@shared/models' | |||
22 | const expect = chai.expect | 22 | const expect = chai.expect |
23 | 23 | ||
24 | describe('Test video privacy', function () { | 24 | describe('Test video privacy', function () { |
25 | let servers: ServerInfo[] = [] | 25 | const servers: ServerInfo[] = [] |
26 | let anotherUserToken: string | 26 | let anotherUserToken: string |
27 | 27 | ||
28 | let privateVideoId: number | 28 | let privateVideoId: number |
@@ -32,14 +32,24 @@ describe('Test video privacy', function () { | |||
32 | let internalVideoUUID: string | 32 | let internalVideoUUID: string |
33 | 33 | ||
34 | let unlistedVideoUUID: string | 34 | let unlistedVideoUUID: string |
35 | let nonFederatedUnlistedVideoUUID: string | ||
35 | 36 | ||
36 | let now: number | 37 | let now: number |
37 | 38 | ||
39 | const dontFederateUnlistedConfig = { | ||
40 | federation: { | ||
41 | videos: { | ||
42 | federate_unlisted: false | ||
43 | } | ||
44 | } | ||
45 | } | ||
46 | |||
38 | before(async function () { | 47 | before(async function () { |
39 | this.timeout(50000) | 48 | this.timeout(50000) |
40 | 49 | ||
41 | // Run servers | 50 | // Run servers |
42 | servers = await flushAndRunMultipleServers(2) | 51 | servers.push(await flushAndRunServer(1, dontFederateUnlistedConfig)) |
52 | servers.push(await flushAndRunServer(2)) | ||
43 | 53 | ||
44 | // Get the access tokens | 54 | // Get the access tokens |
45 | await setAccessTokensToServers(servers) | 55 | await setAccessTokensToServers(servers) |
@@ -164,6 +174,37 @@ describe('Test video privacy', function () { | |||
164 | } | 174 | } |
165 | }) | 175 | }) |
166 | 176 | ||
177 | it('Should upload a non-federating unlisted video to server 1', async function () { | ||
178 | this.timeout(30000) | ||
179 | |||
180 | const attributes = { | ||
181 | name: 'unlisted video', | ||
182 | privacy: VideoPrivacy.UNLISTED | ||
183 | } | ||
184 | await uploadVideo(servers[0].url, servers[0].accessToken, attributes) | ||
185 | |||
186 | await waitJobs(servers) | ||
187 | }) | ||
188 | |||
189 | it('Should list my new unlisted video', async function () { | ||
190 | const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 3) | ||
191 | |||
192 | expect(res.body.total).to.equal(3) | ||
193 | expect(res.body.data).to.have.lengthOf(3) | ||
194 | |||
195 | nonFederatedUnlistedVideoUUID = res.body.data[0].uuid | ||
196 | }) | ||
197 | |||
198 | it('Should be able to get non-federated unlisted video from origin', async function () { | ||
199 | const res = await getVideo(servers[0].url, nonFederatedUnlistedVideoUUID) | ||
200 | |||
201 | expect(res.body.name).to.equal('unlisted video') | ||
202 | }) | ||
203 | |||
204 | it('Should not be able to get non-federated unlisted video from federated server', async function () { | ||
205 | await getVideo(servers[1].url, nonFederatedUnlistedVideoUUID, 404) | ||
206 | }) | ||
207 | |||
167 | it('Should update the private and internal videos to public on server 1', async function () { | 208 | it('Should update the private and internal videos to public on server 1', async function () { |
168 | this.timeout(10000) | 209 | this.timeout(10000) |
169 | 210 | ||
@@ -230,8 +271,8 @@ describe('Test video privacy', function () { | |||
230 | const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 5) | 271 | const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 5) |
231 | const videos = res.body.data | 272 | const videos = res.body.data |
232 | 273 | ||
233 | expect(res.body.total).to.equal(2) | 274 | expect(res.body.total).to.equal(3) |
234 | expect(videos).to.have.lengthOf(2) | 275 | expect(videos).to.have.lengthOf(3) |
235 | 276 | ||
236 | const privateVideo = videos.find(v => v.name === 'private video becomes public') | 277 | const privateVideo = videos.find(v => v.name === 'private video becomes public') |
237 | const internalVideo = videos.find(v => v.name === 'internal video becomes public') | 278 | const internalVideo = videos.find(v => v.name === 'internal video becomes public') |