diff options
author | Chocobozzz <me@florianbigard.com> | 2021-06-28 17:30:59 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-06-29 14:56:35 +0200 |
commit | d4a8e7a65f97bb3257facc13e1ae8ffdbad61ddb (patch) | |
tree | a4cb07318100031951c3dffc61f4f2cb95d2cbd0 /server/tests/api/videos | |
parent | 62ddc31a9e4b92d7d27898ccfc363f68ab044139 (diff) | |
download | PeerTube-d4a8e7a65f97bb3257facc13e1ae8ffdbad61ddb.tar.gz PeerTube-d4a8e7a65f97bb3257facc13e1ae8ffdbad61ddb.tar.zst PeerTube-d4a8e7a65f97bb3257facc13e1ae8ffdbad61ddb.zip |
Support short uuid for GET video/playlist
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r-- | server/tests/api/videos/video-playlists.ts | 71 | ||||
-rw-r--r-- | server/tests/api/videos/video-privacy.ts | 351 |
2 files changed, 236 insertions, 186 deletions
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 { | |||
56 | removeServerFromServerBlocklist | 56 | removeServerFromServerBlocklist |
57 | } from '../../../../shared/extra-utils/users/blocklist' | 57 | } from '../../../../shared/extra-utils/users/blocklist' |
58 | import { User } from '../../../../shared/models/users' | 58 | import { User } from '../../../../shared/models/users' |
59 | import { VideoPrivacy } from '../../../../shared/models/videos' | 59 | import { VideoPlaylistCreateResult, VideoPrivacy } from '../../../../shared/models/videos' |
60 | import { VideoExistInPlaylist } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model' | 60 | import { VideoExistInPlaylist } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model' |
61 | import { VideoPlaylistElement, VideoPlaylistElementType } from '../../../../shared/models/videos/playlist/video-playlist-element.model' | 61 | import { VideoPlaylistElement, VideoPlaylistElementType } from '../../../../shared/models/videos/playlist/video-playlist-element.model' |
62 | import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' | 62 | import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' |
@@ -427,31 +427,45 @@ describe('Test video playlists', function () { | |||
427 | expect(data).to.have.lengthOf(0) | 427 | expect(data).to.have.lengthOf(0) |
428 | } | 428 | } |
429 | }) | 429 | }) |
430 | }) | ||
430 | 431 | ||
431 | it('Should not list unlisted or private playlists', async function () { | 432 | describe('Playlist rights', function () { |
433 | let unlistedPlaylist: VideoPlaylistCreateResult | ||
434 | let privatePlaylist: VideoPlaylistCreateResult | ||
435 | |||
436 | before(async function () { | ||
432 | this.timeout(30000) | 437 | this.timeout(30000) |
433 | 438 | ||
434 | await createVideoPlaylist({ | 439 | { |
435 | url: servers[1].url, | 440 | const res = await createVideoPlaylist({ |
436 | token: servers[1].accessToken, | 441 | url: servers[1].url, |
437 | playlistAttrs: { | 442 | token: servers[1].accessToken, |
438 | displayName: 'playlist unlisted', | 443 | playlistAttrs: { |
439 | privacy: VideoPlaylistPrivacy.UNLISTED | 444 | displayName: 'playlist unlisted', |
440 | } | 445 | privacy: VideoPlaylistPrivacy.UNLISTED, |
441 | }) | 446 | videoChannelId: servers[1].videoChannel.id |
447 | } | ||
448 | }) | ||
449 | unlistedPlaylist = res.body.videoPlaylist | ||
450 | } | ||
442 | 451 | ||
443 | await createVideoPlaylist({ | 452 | { |
444 | url: servers[1].url, | 453 | const res = await createVideoPlaylist({ |
445 | token: servers[1].accessToken, | 454 | url: servers[1].url, |
446 | playlistAttrs: { | 455 | token: servers[1].accessToken, |
447 | displayName: 'playlist private', | 456 | playlistAttrs: { |
448 | privacy: VideoPlaylistPrivacy.PRIVATE | 457 | displayName: 'playlist private', |
449 | } | 458 | privacy: VideoPlaylistPrivacy.PRIVATE |
450 | }) | 459 | } |
460 | }) | ||
461 | privatePlaylist = res.body.videoPlaylist | ||
462 | } | ||
451 | 463 | ||
452 | await waitJobs(servers) | 464 | await waitJobs(servers) |
453 | await wait(3000) | 465 | await wait(3000) |
466 | }) | ||
454 | 467 | ||
468 | it('Should not list unlisted or private playlists', async function () { | ||
455 | for (const server of servers) { | 469 | for (const server of servers) { |
456 | const results = [ | 470 | const results = [ |
457 | await getAccountPlaylistsList(server.url, 'root@localhost:' + servers[1].port, 0, 5, '-createdAt'), | 471 | await getAccountPlaylistsList(server.url, 'root@localhost:' + servers[1].port, 0, 5, '-createdAt'), |
@@ -469,6 +483,27 @@ describe('Test video playlists', function () { | |||
469 | } | 483 | } |
470 | } | 484 | } |
471 | }) | 485 | }) |
486 | |||
487 | it('Should not get unlisted playlist using only the id', async function () { | ||
488 | await getVideoPlaylist(servers[1].url, unlistedPlaylist.id, 404) | ||
489 | }) | ||
490 | |||
491 | it('Should get unlisted plyaylist using uuid or shortUUID', async function () { | ||
492 | await getVideoPlaylist(servers[1].url, unlistedPlaylist.uuid) | ||
493 | await getVideoPlaylist(servers[1].url, unlistedPlaylist.shortUUID) | ||
494 | }) | ||
495 | |||
496 | it('Should not get private playlist without token', async function () { | ||
497 | for (const id of [ privatePlaylist.id, privatePlaylist.uuid, privatePlaylist.shortUUID ]) { | ||
498 | await getVideoPlaylist(servers[1].url, id, 401) | ||
499 | } | ||
500 | }) | ||
501 | |||
502 | it('Should get private playlist with a token', async function () { | ||
503 | for (const id of [ privatePlaylist.id, privatePlaylist.uuid, privatePlaylist.shortUUID ]) { | ||
504 | await getVideoPlaylistWithToken(servers[1].url, servers[1].accessToken, id) | ||
505 | } | ||
506 | }) | ||
472 | }) | 507 | }) |
473 | 508 | ||
474 | describe('Update playlists', function () { | 509 | 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 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | ||
4 | import 'mocha' | 3 | import 'mocha' |
5 | import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' | 4 | import * as chai from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | ||
6 | import { Video, VideoCreateResult } from '@shared/models' | ||
6 | import { | 7 | import { |
7 | cleanupTests, | 8 | cleanupTests, |
8 | flushAndRunServer, | 9 | flushAndRunServer, |
@@ -13,12 +14,11 @@ import { | |||
13 | uploadVideo | 14 | uploadVideo |
14 | } from '../../../../shared/extra-utils/index' | 15 | } from '../../../../shared/extra-utils/index' |
15 | import { doubleFollow } from '../../../../shared/extra-utils/server/follows' | 16 | import { doubleFollow } from '../../../../shared/extra-utils/server/follows' |
17 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | ||
16 | import { userLogin } from '../../../../shared/extra-utils/users/login' | 18 | import { userLogin } from '../../../../shared/extra-utils/users/login' |
17 | import { createUser } from '../../../../shared/extra-utils/users/users' | 19 | import { createUser } from '../../../../shared/extra-utils/users/users' |
18 | import { getMyVideos, getVideo, getVideoWithToken, updateVideo } from '../../../../shared/extra-utils/videos/videos' | 20 | import { getMyVideos, getVideo, getVideoWithToken, updateVideo } from '../../../../shared/extra-utils/videos/videos' |
19 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | 21 | import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' |
20 | import { Video } from '@shared/models' | ||
21 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | ||
22 | 22 | ||
23 | const expect = chai.expect | 23 | const expect = chai.expect |
24 | 24 | ||
@@ -32,7 +32,7 @@ describe('Test video privacy', function () { | |||
32 | let internalVideoId: number | 32 | let internalVideoId: number |
33 | let internalVideoUUID: string | 33 | let internalVideoUUID: string |
34 | 34 | ||
35 | let unlistedVideoUUID: string | 35 | let unlistedVideo: VideoCreateResult |
36 | let nonFederatedUnlistedVideoUUID: string | 36 | let nonFederatedUnlistedVideoUUID: string |
37 | 37 | ||
38 | let now: number | 38 | let now: number |
@@ -59,231 +59,246 @@ describe('Test video privacy', function () { | |||
59 | await doubleFollow(servers[0], servers[1]) | 59 | await doubleFollow(servers[0], servers[1]) |
60 | }) | 60 | }) |
61 | 61 | ||
62 | it('Should upload a private and internal videos on server 1', async function () { | 62 | describe('Private and internal videos', function () { |
63 | this.timeout(10000) | ||
64 | 63 | ||
65 | for (const privacy of [ VideoPrivacy.PRIVATE, VideoPrivacy.INTERNAL ]) { | 64 | it('Should upload a private and internal videos on server 1', async function () { |
66 | const attributes = { privacy } | 65 | this.timeout(10000) |
67 | await uploadVideo(servers[0].url, servers[0].accessToken, attributes) | ||
68 | } | ||
69 | 66 | ||
70 | await waitJobs(servers) | 67 | for (const privacy of [ VideoPrivacy.PRIVATE, VideoPrivacy.INTERNAL ]) { |
71 | }) | 68 | const attributes = { privacy } |
69 | await uploadVideo(servers[0].url, servers[0].accessToken, attributes) | ||
70 | } | ||
72 | 71 | ||
73 | it('Should not have these private and internal videos on server 2', async function () { | 72 | await waitJobs(servers) |
74 | const res = await getVideosList(servers[1].url) | 73 | }) |
75 | 74 | ||
76 | expect(res.body.total).to.equal(0) | 75 | it('Should not have these private and internal videos on server 2', async function () { |
77 | expect(res.body.data).to.have.lengthOf(0) | 76 | const res = await getVideosList(servers[1].url) |
78 | }) | ||
79 | 77 | ||
80 | it('Should not list the private and internal videos for an unauthenticated user on server 1', async function () { | 78 | expect(res.body.total).to.equal(0) |
81 | const res = await getVideosList(servers[0].url) | 79 | expect(res.body.data).to.have.lengthOf(0) |
80 | }) | ||
82 | 81 | ||
83 | expect(res.body.total).to.equal(0) | 82 | it('Should not list the private and internal videos for an unauthenticated user on server 1', async function () { |
84 | expect(res.body.data).to.have.lengthOf(0) | 83 | const res = await getVideosList(servers[0].url) |
85 | }) | 84 | |
85 | expect(res.body.total).to.equal(0) | ||
86 | expect(res.body.data).to.have.lengthOf(0) | ||
87 | }) | ||
86 | 88 | ||
87 | it('Should not list the private video and list the internal video for an authenticated user on server 1', async function () { | 89 | it('Should not list the private video and list the internal video for an authenticated user on server 1', async function () { |
88 | const res = await getVideosListWithToken(servers[0].url, servers[0].accessToken) | 90 | const res = await getVideosListWithToken(servers[0].url, servers[0].accessToken) |
89 | 91 | ||
90 | expect(res.body.total).to.equal(1) | 92 | expect(res.body.total).to.equal(1) |
91 | expect(res.body.data).to.have.lengthOf(1) | 93 | expect(res.body.data).to.have.lengthOf(1) |
92 | 94 | ||
93 | expect(res.body.data[0].privacy.id).to.equal(VideoPrivacy.INTERNAL) | 95 | expect(res.body.data[0].privacy.id).to.equal(VideoPrivacy.INTERNAL) |
94 | }) | 96 | }) |
95 | 97 | ||
96 | it('Should list my (private and internal) videos', async function () { | 98 | it('Should list my (private and internal) videos', async function () { |
97 | const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 10) | 99 | const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 10) |
98 | 100 | ||
99 | expect(res.body.total).to.equal(2) | 101 | expect(res.body.total).to.equal(2) |
100 | expect(res.body.data).to.have.lengthOf(2) | 102 | expect(res.body.data).to.have.lengthOf(2) |
101 | 103 | ||
102 | const videos: Video[] = res.body.data | 104 | const videos: Video[] = res.body.data |
103 | 105 | ||
104 | const privateVideo = videos.find(v => v.privacy.id === VideoPrivacy.PRIVATE) | 106 | const privateVideo = videos.find(v => v.privacy.id === VideoPrivacy.PRIVATE) |
105 | privateVideoId = privateVideo.id | 107 | privateVideoId = privateVideo.id |
106 | privateVideoUUID = privateVideo.uuid | 108 | privateVideoUUID = privateVideo.uuid |
107 | 109 | ||
108 | const internalVideo = videos.find(v => v.privacy.id === VideoPrivacy.INTERNAL) | 110 | const internalVideo = videos.find(v => v.privacy.id === VideoPrivacy.INTERNAL) |
109 | internalVideoId = internalVideo.id | 111 | internalVideoId = internalVideo.id |
110 | internalVideoUUID = internalVideo.uuid | 112 | internalVideoUUID = internalVideo.uuid |
111 | }) | 113 | }) |
112 | 114 | ||
113 | it('Should not be able to watch the private/internal video with non authenticated user', async function () { | 115 | it('Should not be able to watch the private/internal video with non authenticated user', async function () { |
114 | await getVideo(servers[0].url, privateVideoUUID, HttpStatusCode.UNAUTHORIZED_401) | 116 | await getVideo(servers[0].url, privateVideoUUID, HttpStatusCode.UNAUTHORIZED_401) |
115 | await getVideo(servers[0].url, internalVideoUUID, HttpStatusCode.UNAUTHORIZED_401) | 117 | await getVideo(servers[0].url, internalVideoUUID, HttpStatusCode.UNAUTHORIZED_401) |
116 | }) | 118 | }) |
117 | 119 | ||
118 | it('Should not be able to watch the private video with another user', async function () { | 120 | it('Should not be able to watch the private video with another user', async function () { |
119 | this.timeout(10000) | 121 | this.timeout(10000) |
120 | 122 | ||
121 | const user = { | 123 | const user = { |
122 | username: 'hello', | 124 | username: 'hello', |
123 | password: 'super password' | 125 | password: 'super password' |
124 | } | 126 | } |
125 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) | 127 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) |
126 | 128 | ||
127 | anotherUserToken = await userLogin(servers[0], user) | 129 | anotherUserToken = await userLogin(servers[0], user) |
128 | await getVideoWithToken(servers[0].url, anotherUserToken, privateVideoUUID, HttpStatusCode.FORBIDDEN_403) | 130 | await getVideoWithToken(servers[0].url, anotherUserToken, privateVideoUUID, HttpStatusCode.FORBIDDEN_403) |
129 | }) | 131 | }) |
130 | 132 | ||
131 | it('Should be able to watch the internal video with another user', async function () { | 133 | it('Should be able to watch the internal video with another user', async function () { |
132 | await getVideoWithToken(servers[0].url, anotherUserToken, internalVideoUUID, HttpStatusCode.OK_200) | 134 | await getVideoWithToken(servers[0].url, anotherUserToken, internalVideoUUID, HttpStatusCode.OK_200) |
133 | }) | 135 | }) |
134 | 136 | ||
135 | it('Should be able to watch the private video with the correct user', async function () { | 137 | it('Should be able to watch the private video with the correct user', async function () { |
136 | await getVideoWithToken(servers[0].url, servers[0].accessToken, privateVideoUUID, HttpStatusCode.OK_200) | 138 | await getVideoWithToken(servers[0].url, servers[0].accessToken, privateVideoUUID, HttpStatusCode.OK_200) |
139 | }) | ||
137 | }) | 140 | }) |
138 | 141 | ||
139 | it('Should upload an unlisted video on server 2', async function () { | 142 | describe('Unlisted videos', function () { |
140 | this.timeout(60000) | ||
141 | 143 | ||
142 | const attributes = { | 144 | it('Should upload an unlisted video on server 2', async function () { |
143 | name: 'unlisted video', | 145 | this.timeout(60000) |
144 | privacy: VideoPrivacy.UNLISTED | ||
145 | } | ||
146 | await uploadVideo(servers[1].url, servers[1].accessToken, attributes) | ||
147 | 146 | ||
148 | // Server 2 has transcoding enabled | 147 | const attributes = { |
149 | await waitJobs(servers) | 148 | name: 'unlisted video', |
150 | }) | 149 | privacy: VideoPrivacy.UNLISTED |
150 | } | ||
151 | await uploadVideo(servers[1].url, servers[1].accessToken, attributes) | ||
151 | 152 | ||
152 | it('Should not have this unlisted video listed on server 1 and 2', async function () { | 153 | // Server 2 has transcoding enabled |
153 | for (const server of servers) { | 154 | await waitJobs(servers) |
154 | const res = await getVideosList(server.url) | 155 | }) |
155 | 156 | ||
156 | expect(res.body.total).to.equal(0) | 157 | it('Should not have this unlisted video listed on server 1 and 2', async function () { |
157 | expect(res.body.data).to.have.lengthOf(0) | 158 | for (const server of servers) { |
158 | } | 159 | const res = await getVideosList(server.url) |
159 | }) | ||
160 | 160 | ||
161 | it('Should list my (unlisted) videos', async function () { | 161 | expect(res.body.total).to.equal(0) |
162 | const res = await getMyVideos(servers[1].url, servers[1].accessToken, 0, 1) | 162 | expect(res.body.data).to.have.lengthOf(0) |
163 | } | ||
164 | }) | ||
163 | 165 | ||
164 | expect(res.body.total).to.equal(1) | 166 | it('Should list my (unlisted) videos', async function () { |
165 | expect(res.body.data).to.have.lengthOf(1) | 167 | const res = await getMyVideos(servers[1].url, servers[1].accessToken, 0, 1) |
166 | 168 | ||
167 | unlistedVideoUUID = res.body.data[0].uuid | 169 | expect(res.body.total).to.equal(1) |
168 | }) | 170 | expect(res.body.data).to.have.lengthOf(1) |
169 | 171 | ||
170 | it('Should be able to get this unlisted video', async function () { | 172 | unlistedVideo = res.body.data[0] |
171 | for (const server of servers) { | 173 | }) |
172 | const res = await getVideo(server.url, unlistedVideoUUID) | ||
173 | 174 | ||
174 | expect(res.body.name).to.equal('unlisted video') | 175 | it('Should not be able to get this unlisted video using its id', async function () { |
175 | } | 176 | await getVideo(servers[1].url, unlistedVideo.id, 404) |
176 | }) | 177 | }) |
177 | 178 | ||
178 | it('Should upload a non-federating unlisted video to server 1', async function () { | 179 | it('Should be able to get this unlisted video using its uuid/shortUUID', async function () { |
179 | this.timeout(30000) | 180 | for (const server of servers) { |
181 | for (const id of [ unlistedVideo.uuid, unlistedVideo.shortUUID ]) { | ||
182 | const res = await getVideo(server.url, id) | ||
180 | 183 | ||
181 | const attributes = { | 184 | expect(res.body.name).to.equal('unlisted video') |
182 | name: 'unlisted video', | 185 | } |
183 | privacy: VideoPrivacy.UNLISTED | 186 | } |
184 | } | 187 | }) |
185 | await uploadVideo(servers[0].url, servers[0].accessToken, attributes) | ||
186 | 188 | ||
187 | await waitJobs(servers) | 189 | it('Should upload a non-federating unlisted video to server 1', async function () { |
188 | }) | 190 | this.timeout(30000) |
191 | |||
192 | const attributes = { | ||
193 | name: 'unlisted video', | ||
194 | privacy: VideoPrivacy.UNLISTED | ||
195 | } | ||
196 | await uploadVideo(servers[0].url, servers[0].accessToken, attributes) | ||
189 | 197 | ||
190 | it('Should list my new unlisted video', async function () { | 198 | await waitJobs(servers) |
191 | const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 3) | 199 | }) |
192 | 200 | ||
193 | expect(res.body.total).to.equal(3) | 201 | it('Should list my new unlisted video', async function () { |
194 | expect(res.body.data).to.have.lengthOf(3) | 202 | const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 3) |
195 | 203 | ||
196 | nonFederatedUnlistedVideoUUID = res.body.data[0].uuid | 204 | expect(res.body.total).to.equal(3) |
197 | }) | 205 | expect(res.body.data).to.have.lengthOf(3) |
198 | 206 | ||
199 | it('Should be able to get non-federated unlisted video from origin', async function () { | 207 | nonFederatedUnlistedVideoUUID = res.body.data[0].uuid |
200 | const res = await getVideo(servers[0].url, nonFederatedUnlistedVideoUUID) | 208 | }) |
201 | 209 | ||
202 | expect(res.body.name).to.equal('unlisted video') | 210 | it('Should be able to get non-federated unlisted video from origin', async function () { |
203 | }) | 211 | const res = await getVideo(servers[0].url, nonFederatedUnlistedVideoUUID) |
204 | 212 | ||
205 | it('Should not be able to get non-federated unlisted video from federated server', async function () { | 213 | expect(res.body.name).to.equal('unlisted video') |
206 | await getVideo(servers[1].url, nonFederatedUnlistedVideoUUID, HttpStatusCode.NOT_FOUND_404) | 214 | }) |
215 | |||
216 | it('Should not be able to get non-federated unlisted video from federated server', async function () { | ||
217 | await getVideo(servers[1].url, nonFederatedUnlistedVideoUUID, HttpStatusCode.NOT_FOUND_404) | ||
218 | }) | ||
207 | }) | 219 | }) |
208 | 220 | ||
209 | it('Should update the private and internal videos to public on server 1', async function () { | 221 | describe('Privacy update', function () { |
210 | this.timeout(10000) | ||
211 | 222 | ||
212 | now = Date.now() | 223 | it('Should update the private and internal videos to public on server 1', async function () { |
224 | this.timeout(10000) | ||
213 | 225 | ||
214 | { | 226 | now = Date.now() |
215 | const attribute = { | ||
216 | name: 'private video becomes public', | ||
217 | privacy: VideoPrivacy.PUBLIC | ||
218 | } | ||
219 | 227 | ||
220 | await updateVideo(servers[0].url, servers[0].accessToken, privateVideoId, attribute) | 228 | { |
221 | } | 229 | const attribute = { |
230 | name: 'private video becomes public', | ||
231 | privacy: VideoPrivacy.PUBLIC | ||
232 | } | ||
222 | 233 | ||
223 | { | 234 | await updateVideo(servers[0].url, servers[0].accessToken, privateVideoId, attribute) |
224 | const attribute = { | ||
225 | name: 'internal video becomes public', | ||
226 | privacy: VideoPrivacy.PUBLIC | ||
227 | } | 235 | } |
228 | await updateVideo(servers[0].url, servers[0].accessToken, internalVideoId, attribute) | ||
229 | } | ||
230 | 236 | ||
231 | await waitJobs(servers) | 237 | { |
232 | }) | 238 | const attribute = { |
239 | name: 'internal video becomes public', | ||
240 | privacy: VideoPrivacy.PUBLIC | ||
241 | } | ||
242 | await updateVideo(servers[0].url, servers[0].accessToken, internalVideoId, attribute) | ||
243 | } | ||
233 | 244 | ||
234 | it('Should have this new public video listed on server 1 and 2', async function () { | 245 | await waitJobs(servers) |
235 | for (const server of servers) { | 246 | }) |
236 | const res = await getVideosList(server.url) | ||
237 | expect(res.body.total).to.equal(2) | ||
238 | expect(res.body.data).to.have.lengthOf(2) | ||
239 | 247 | ||
240 | const videos: Video[] = res.body.data | 248 | it('Should have this new public video listed on server 1 and 2', async function () { |
241 | const privateVideo = videos.find(v => v.name === 'private video becomes public') | 249 | for (const server of servers) { |
242 | const internalVideo = videos.find(v => v.name === 'internal video becomes public') | 250 | const res = await getVideosList(server.url) |
251 | expect(res.body.total).to.equal(2) | ||
252 | expect(res.body.data).to.have.lengthOf(2) | ||
243 | 253 | ||
244 | expect(privateVideo).to.not.be.undefined | 254 | const videos: Video[] = res.body.data |
245 | expect(internalVideo).to.not.be.undefined | 255 | const privateVideo = videos.find(v => v.name === 'private video becomes public') |
256 | const internalVideo = videos.find(v => v.name === 'internal video becomes public') | ||
246 | 257 | ||
247 | expect(new Date(privateVideo.publishedAt).getTime()).to.be.at.least(now) | 258 | expect(privateVideo).to.not.be.undefined |
248 | // We don't change the publish date of internal videos | 259 | expect(internalVideo).to.not.be.undefined |
249 | expect(new Date(internalVideo.publishedAt).getTime()).to.be.below(now) | ||
250 | 260 | ||
251 | expect(privateVideo.privacy.id).to.equal(VideoPrivacy.PUBLIC) | 261 | expect(new Date(privateVideo.publishedAt).getTime()).to.be.at.least(now) |
252 | expect(internalVideo.privacy.id).to.equal(VideoPrivacy.PUBLIC) | 262 | // We don't change the publish date of internal videos |
253 | } | 263 | expect(new Date(internalVideo.publishedAt).getTime()).to.be.below(now) |
254 | }) | ||
255 | 264 | ||
256 | it('Should set these videos as private and internal', async function () { | 265 | expect(privateVideo.privacy.id).to.equal(VideoPrivacy.PUBLIC) |
257 | this.timeout(10000) | 266 | expect(internalVideo.privacy.id).to.equal(VideoPrivacy.PUBLIC) |
267 | } | ||
268 | }) | ||
258 | 269 | ||
259 | await updateVideo(servers[0].url, servers[0].accessToken, internalVideoId, { privacy: VideoPrivacy.PRIVATE }) | 270 | it('Should set these videos as private and internal', async function () { |
260 | await updateVideo(servers[0].url, servers[0].accessToken, privateVideoId, { privacy: VideoPrivacy.INTERNAL }) | 271 | this.timeout(10000) |
261 | 272 | ||
262 | await waitJobs(servers) | 273 | await updateVideo(servers[0].url, servers[0].accessToken, internalVideoId, { privacy: VideoPrivacy.PRIVATE }) |
274 | await updateVideo(servers[0].url, servers[0].accessToken, privateVideoId, { privacy: VideoPrivacy.INTERNAL }) | ||
263 | 275 | ||
264 | for (const server of servers) { | 276 | await waitJobs(servers) |
265 | const res = await getVideosList(server.url) | ||
266 | 277 | ||
267 | expect(res.body.total).to.equal(0) | 278 | for (const server of servers) { |
268 | expect(res.body.data).to.have.lengthOf(0) | 279 | const res = await getVideosList(server.url) |
269 | } | 280 | |
281 | expect(res.body.total).to.equal(0) | ||
282 | expect(res.body.data).to.have.lengthOf(0) | ||
283 | } | ||
270 | 284 | ||
271 | { | 285 | { |
272 | const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 5) | 286 | const res = await getMyVideos(servers[0].url, servers[0].accessToken, 0, 5) |
273 | const videos = res.body.data | 287 | const videos = res.body.data |
274 | 288 | ||
275 | expect(res.body.total).to.equal(3) | 289 | expect(res.body.total).to.equal(3) |
276 | expect(videos).to.have.lengthOf(3) | 290 | expect(videos).to.have.lengthOf(3) |
277 | 291 | ||
278 | const privateVideo = videos.find(v => v.name === 'private video becomes public') | 292 | const privateVideo = videos.find(v => v.name === 'private video becomes public') |
279 | const internalVideo = videos.find(v => v.name === 'internal video becomes public') | 293 | const internalVideo = videos.find(v => v.name === 'internal video becomes public') |
280 | 294 | ||
281 | expect(privateVideo).to.not.be.undefined | 295 | expect(privateVideo).to.not.be.undefined |
282 | expect(internalVideo).to.not.be.undefined | 296 | expect(internalVideo).to.not.be.undefined |
283 | 297 | ||
284 | expect(privateVideo.privacy.id).to.equal(VideoPrivacy.INTERNAL) | 298 | expect(privateVideo.privacy.id).to.equal(VideoPrivacy.INTERNAL) |
285 | expect(internalVideo.privacy.id).to.equal(VideoPrivacy.PRIVATE) | 299 | expect(internalVideo.privacy.id).to.equal(VideoPrivacy.PRIVATE) |
286 | } | 300 | } |
301 | }) | ||
287 | }) | 302 | }) |
288 | 303 | ||
289 | after(async function () { | 304 | after(async function () { |