]>
Commit | Line | Data |
---|---|---|
a1587156 | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
9b474844 | 2 | |
9b474844 | 3 | import 'mocha' |
2158ac90 | 4 | import * as chai from 'chai' |
c55e3d72 | 5 | import { HttpStatusCode, VideoDetails, VideoImportState, VideoPlaylist, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' |
89cd1275 | 6 | import { |
af971e06 | 7 | cleanupTests, |
254d3579 | 8 | createMultipleServers, |
59bbcced | 9 | doubleFollow, |
4bc45da3 | 10 | makeRawRequest, |
254d3579 | 11 | PeerTubeServer, |
59bbcced | 12 | PluginsCommand, |
a1587156 | 13 | setAccessTokensToServers, |
6691c522 | 14 | setDefaultVideoChannel, |
6c5065a0 | 15 | waitJobs |
bf54587a | 16 | } from '@shared/server-commands' |
c55e3d72 | 17 | import { FIXTURE_URLS } from '../shared' |
9b474844 C |
18 | |
19 | const expect = chai.expect | |
20 | ||
21 | describe('Test plugin filter hooks', function () { | |
254d3579 | 22 | let servers: PeerTubeServer[] |
89cd1275 C |
23 | let videoUUID: string |
24 | let threadId: number | |
c5ca7e1e | 25 | let videoPlaylistUUID: string |
9b474844 C |
26 | |
27 | before(async function () { | |
4076e2ef | 28 | this.timeout(60000) |
9b474844 | 29 | |
254d3579 | 30 | servers = await createMultipleServers(2) |
89cd1275 | 31 | await setAccessTokensToServers(servers) |
6691c522 C |
32 | await setDefaultVideoChannel(servers) |
33 | await doubleFollow(servers[0], servers[1]) | |
89cd1275 | 34 | |
89d241a7 C |
35 | await servers[0].plugins.install({ path: PluginsCommand.getPluginTestPath() }) |
36 | await servers[0].plugins.install({ path: PluginsCommand.getPluginTestPath('-filter-translations') }) | |
c5ca7e1e | 37 | { |
38 | ({ uuid: videoPlaylistUUID } = await servers[0].playlists.create({ | |
39 | attributes: { | |
40 | displayName: 'my super playlist', | |
41 | privacy: VideoPlaylistPrivacy.PUBLIC, | |
42 | description: 'my super description', | |
43 | videoChannelId: servers[0].store.channel.id | |
44 | } | |
45 | })) | |
46 | } | |
89cd1275 C |
47 | |
48 | for (let i = 0; i < 10; i++) { | |
c5ca7e1e | 49 | const video = await servers[0].videos.upload({ attributes: { name: 'default video ' + i } }) |
50 | await servers[0].playlists.addElement({ playlistId: videoPlaylistUUID, attributes: { videoId: video.id } }) | |
89cd1275 C |
51 | } |
52 | ||
89d241a7 | 53 | const { data } = await servers[0].videos.list() |
d23dd9fb | 54 | videoUUID = data[0].uuid |
3cabf353 | 55 | |
89d241a7 | 56 | await servers[0].config.updateCustomSubConfig({ |
65e6e260 C |
57 | newConfig: { |
58 | live: { enabled: true }, | |
59 | signup: { enabled: true }, | |
60 | import: { | |
61 | videos: { | |
62 | http: { enabled: true }, | |
63 | torrent: { enabled: true } | |
64 | } | |
3cabf353 C |
65 | } |
66 | } | |
67 | }) | |
9b474844 C |
68 | }) |
69 | ||
6691c522 | 70 | it('Should run filter:api.videos.list.params', async function () { |
89d241a7 | 71 | const { data } = await servers[0].videos.list({ start: 0, count: 2 }) |
89cd1275 C |
72 | |
73 | // 2 plugins do +1 to the count parameter | |
d23dd9fb | 74 | expect(data).to.have.lengthOf(4) |
89cd1275 C |
75 | }) |
76 | ||
77 | it('Should run filter:api.videos.list.result', async function () { | |
89d241a7 | 78 | const { total } = await servers[0].videos.list({ start: 0, count: 0 }) |
89cd1275 C |
79 | |
80 | // Plugin do +1 to the total result | |
d23dd9fb | 81 | expect(total).to.equal(11) |
89cd1275 C |
82 | }) |
83 | ||
c5ca7e1e | 84 | it('Should run filter:api.video-playlist.videos.list.params', async function () { |
85 | const { data } = await servers[0].playlists.listVideos({ | |
86 | count: 2, | |
87 | playlistId: videoPlaylistUUID | |
88 | }) | |
89 | ||
90 | // 1 plugin do +1 to the count parameter | |
91 | expect(data).to.have.lengthOf(3) | |
92 | }) | |
93 | ||
94 | it('Should run filter:api.video-playlist.videos.list.result', async function () { | |
95 | const { total } = await servers[0].playlists.listVideos({ | |
96 | count: 0, | |
97 | playlistId: videoPlaylistUUID | |
98 | }) | |
99 | ||
100 | // Plugin do +1 to the total result | |
101 | expect(total).to.equal(11) | |
102 | }) | |
103 | ||
38267c0c | 104 | it('Should run filter:api.accounts.videos.list.params', async function () { |
c0e8b12e | 105 | const { data } = await servers[0].videos.listByAccount({ handle: 'root', start: 0, count: 2 }) |
38267c0c C |
106 | |
107 | // 1 plugin do +1 to the count parameter | |
d23dd9fb | 108 | expect(data).to.have.lengthOf(3) |
38267c0c C |
109 | }) |
110 | ||
111 | it('Should run filter:api.accounts.videos.list.result', async function () { | |
c0e8b12e | 112 | const { total } = await servers[0].videos.listByAccount({ handle: 'root', start: 0, count: 2 }) |
38267c0c C |
113 | |
114 | // Plugin do +2 to the total result | |
d23dd9fb | 115 | expect(total).to.equal(12) |
38267c0c C |
116 | }) |
117 | ||
118 | it('Should run filter:api.video-channels.videos.list.params', async function () { | |
c0e8b12e | 119 | const { data } = await servers[0].videos.listByChannel({ handle: 'root_channel', start: 0, count: 2 }) |
38267c0c C |
120 | |
121 | // 1 plugin do +3 to the count parameter | |
d23dd9fb | 122 | expect(data).to.have.lengthOf(5) |
38267c0c C |
123 | }) |
124 | ||
125 | it('Should run filter:api.video-channels.videos.list.result', async function () { | |
c0e8b12e | 126 | const { total } = await servers[0].videos.listByChannel({ handle: 'root_channel', start: 0, count: 2 }) |
38267c0c C |
127 | |
128 | // Plugin do +3 to the total result | |
d23dd9fb | 129 | expect(total).to.equal(13) |
38267c0c C |
130 | }) |
131 | ||
a4d2ca07 | 132 | it('Should run filter:api.user.me.videos.list.params', async function () { |
89d241a7 | 133 | const { data } = await servers[0].videos.listMyVideos({ start: 0, count: 2 }) |
a4d2ca07 C |
134 | |
135 | // 1 plugin do +4 to the count parameter | |
d23dd9fb | 136 | expect(data).to.have.lengthOf(6) |
a4d2ca07 C |
137 | }) |
138 | ||
139 | it('Should run filter:api.user.me.videos.list.result', async function () { | |
89d241a7 | 140 | const { total } = await servers[0].videos.listMyVideos({ start: 0, count: 2 }) |
a4d2ca07 C |
141 | |
142 | // Plugin do +4 to the total result | |
d23dd9fb | 143 | expect(total).to.equal(14) |
a4d2ca07 C |
144 | }) |
145 | ||
89cd1275 | 146 | it('Should run filter:api.video.get.result', async function () { |
89d241a7 | 147 | const video = await servers[0].videos.get({ id: videoUUID }) |
d23dd9fb | 148 | expect(video.name).to.contain('<3') |
9b474844 C |
149 | }) |
150 | ||
6691c522 | 151 | it('Should run filter:api.video.upload.accept.result', async function () { |
89d241a7 | 152 | await servers[0].videos.upload({ attributes: { name: 'video with bad word' }, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
6691c522 C |
153 | }) |
154 | ||
3cabf353 C |
155 | it('Should run filter:api.live-video.create.accept.result', async function () { |
156 | const attributes = { | |
157 | name: 'video with bad word', | |
158 | privacy: VideoPrivacy.PUBLIC, | |
89d241a7 | 159 | channelId: servers[0].store.channel.id |
3cabf353 C |
160 | } |
161 | ||
89d241a7 | 162 | await servers[0].live.create({ fields: attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
3cabf353 C |
163 | }) |
164 | ||
2158ac90 | 165 | it('Should run filter:api.video.pre-import-url.accept.result', async function () { |
6910f20f | 166 | const attributes = { |
2158ac90 RK |
167 | name: 'normal title', |
168 | privacy: VideoPrivacy.PUBLIC, | |
89d241a7 | 169 | channelId: servers[0].store.channel.id, |
59bbcced | 170 | targetUrl: FIXTURE_URLS.goodVideo + 'bad' |
2158ac90 | 171 | } |
89d241a7 | 172 | await servers[0].imports.importVideo({ attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
2158ac90 RK |
173 | }) |
174 | ||
175 | it('Should run filter:api.video.pre-import-torrent.accept.result', async function () { | |
6910f20f | 176 | const attributes = { |
2158ac90 RK |
177 | name: 'bad torrent', |
178 | privacy: VideoPrivacy.PUBLIC, | |
89d241a7 | 179 | channelId: servers[0].store.channel.id, |
2158ac90 RK |
180 | torrentfile: 'video-720p.torrent' as any |
181 | } | |
89d241a7 | 182 | await servers[0].imports.importVideo({ attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
2158ac90 RK |
183 | }) |
184 | ||
185 | it('Should run filter:api.video.post-import-url.accept.result', async function () { | |
186 | this.timeout(60000) | |
187 | ||
188 | let videoImportId: number | |
189 | ||
190 | { | |
6910f20f | 191 | const attributes = { |
2158ac90 RK |
192 | name: 'title with bad word', |
193 | privacy: VideoPrivacy.PUBLIC, | |
89d241a7 | 194 | channelId: servers[0].store.channel.id, |
59bbcced | 195 | targetUrl: FIXTURE_URLS.goodVideo |
2158ac90 | 196 | } |
89d241a7 | 197 | const body = await servers[0].imports.importVideo({ attributes }) |
6910f20f | 198 | videoImportId = body.id |
2158ac90 RK |
199 | } |
200 | ||
201 | await waitJobs(servers) | |
202 | ||
203 | { | |
89d241a7 | 204 | const body = await servers[0].imports.getMyVideoImports() |
6910f20f | 205 | const videoImports = body.data |
2158ac90 RK |
206 | |
207 | const videoImport = videoImports.find(i => i.id === videoImportId) | |
208 | ||
209 | expect(videoImport.state.id).to.equal(VideoImportState.REJECTED) | |
210 | expect(videoImport.state.label).to.equal('Rejected') | |
211 | } | |
212 | }) | |
213 | ||
214 | it('Should run filter:api.video.post-import-torrent.accept.result', async function () { | |
215 | this.timeout(60000) | |
216 | ||
217 | let videoImportId: number | |
218 | ||
219 | { | |
6910f20f | 220 | const attributes = { |
2158ac90 RK |
221 | name: 'title with bad word', |
222 | privacy: VideoPrivacy.PUBLIC, | |
89d241a7 | 223 | channelId: servers[0].store.channel.id, |
2158ac90 RK |
224 | torrentfile: 'video-720p.torrent' as any |
225 | } | |
89d241a7 | 226 | const body = await servers[0].imports.importVideo({ attributes }) |
6910f20f | 227 | videoImportId = body.id |
2158ac90 RK |
228 | } |
229 | ||
230 | await waitJobs(servers) | |
231 | ||
232 | { | |
89d241a7 | 233 | const { data: videoImports } = await servers[0].imports.getMyVideoImports() |
2158ac90 RK |
234 | |
235 | const videoImport = videoImports.find(i => i.id === videoImportId) | |
236 | ||
237 | expect(videoImport.state.id).to.equal(VideoImportState.REJECTED) | |
238 | expect(videoImport.state.label).to.equal('Rejected') | |
239 | } | |
240 | }) | |
241 | ||
6691c522 | 242 | it('Should run filter:api.video-thread.create.accept.result', async function () { |
89d241a7 | 243 | await servers[0].comments.createThread({ |
12edc149 C |
244 | videoId: videoUUID, |
245 | text: 'comment with bad word', | |
246 | expectedStatus: HttpStatusCode.FORBIDDEN_403 | |
247 | }) | |
6691c522 C |
248 | }) |
249 | ||
250 | it('Should run filter:api.video-comment-reply.create.accept.result', async function () { | |
89d241a7 | 251 | const created = await servers[0].comments.createThread({ videoId: videoUUID, text: 'thread' }) |
12edc149 C |
252 | threadId = created.id |
253 | ||
89d241a7 | 254 | await servers[0].comments.addReply({ |
12edc149 C |
255 | videoId: videoUUID, |
256 | toCommentId: threadId, | |
257 | text: 'comment with bad word', | |
258 | expectedStatus: HttpStatusCode.FORBIDDEN_403 | |
259 | }) | |
89d241a7 | 260 | await servers[0].comments.addReply({ |
12edc149 C |
261 | videoId: videoUUID, |
262 | toCommentId: threadId, | |
263 | text: 'comment with good word', | |
264 | expectedStatus: HttpStatusCode.OK_200 | |
265 | }) | |
6691c522 C |
266 | }) |
267 | ||
268 | it('Should run filter:api.video-threads.list.params', async function () { | |
89d241a7 | 269 | const { data } = await servers[0].comments.listThreads({ videoId: videoUUID, start: 0, count: 0 }) |
6691c522 C |
270 | |
271 | // our plugin do +1 to the count parameter | |
12edc149 | 272 | expect(data).to.have.lengthOf(1) |
6691c522 C |
273 | }) |
274 | ||
275 | it('Should run filter:api.video-threads.list.result', async function () { | |
89d241a7 | 276 | const { total } = await servers[0].comments.listThreads({ videoId: videoUUID, start: 0, count: 0 }) |
6691c522 C |
277 | |
278 | // Plugin do +1 to the total result | |
12edc149 | 279 | expect(total).to.equal(2) |
6691c522 C |
280 | }) |
281 | ||
282 | it('Should run filter:api.video-thread-comments.list.params') | |
283 | ||
284 | it('Should run filter:api.video-thread-comments.list.result', async function () { | |
89d241a7 | 285 | const thread = await servers[0].comments.getThread({ videoId: videoUUID, threadId }) |
6691c522 | 286 | |
6691c522 C |
287 | expect(thread.comment.text.endsWith(' <3')).to.be.true |
288 | }) | |
289 | ||
d1aed103 C |
290 | it('Should run filter:api.overviews.videos.list.{params,result}', async function () { |
291 | await servers[0].overviews.getVideos({ page: 1 }) | |
292 | ||
293 | // 3 because we get 3 samples per page | |
294 | await servers[0].servers.waitUntilLog('Run hook filter:api.overviews.videos.list.params', 3) | |
295 | await servers[0].servers.waitUntilLog('Run hook filter:api.overviews.videos.list.result', 3) | |
296 | }) | |
297 | ||
6691c522 C |
298 | describe('Should run filter:video.auto-blacklist.result', function () { |
299 | ||
6910f20f | 300 | async function checkIsBlacklisted (id: number | string, value: boolean) { |
89d241a7 | 301 | const video = await servers[0].videos.getWithToken({ id }) |
6691c522 C |
302 | expect(video.blacklisted).to.equal(value) |
303 | } | |
304 | ||
305 | it('Should blacklist on upload', async function () { | |
89d241a7 | 306 | const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video please blacklist me' } }) |
d23dd9fb | 307 | await checkIsBlacklisted(uuid, true) |
6691c522 C |
308 | }) |
309 | ||
310 | it('Should blacklist on import', async function () { | |
89566f77 C |
311 | this.timeout(15000) |
312 | ||
6691c522 C |
313 | const attributes = { |
314 | name: 'video please blacklist me', | |
59bbcced | 315 | targetUrl: FIXTURE_URLS.goodVideo, |
89d241a7 | 316 | channelId: servers[0].store.channel.id |
6691c522 | 317 | } |
89d241a7 | 318 | const body = await servers[0].imports.importVideo({ attributes }) |
6910f20f | 319 | await checkIsBlacklisted(body.video.uuid, true) |
6691c522 C |
320 | }) |
321 | ||
322 | it('Should blacklist on update', async function () { | |
89d241a7 | 323 | const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video' } }) |
d23dd9fb | 324 | await checkIsBlacklisted(uuid, false) |
6691c522 | 325 | |
89d241a7 | 326 | await servers[0].videos.update({ id: uuid, attributes: { name: 'please blacklist me' } }) |
d23dd9fb | 327 | await checkIsBlacklisted(uuid, true) |
6691c522 C |
328 | }) |
329 | ||
330 | it('Should blacklist on remote upload', async function () { | |
3d470a53 | 331 | this.timeout(120000) |
6691c522 | 332 | |
89d241a7 | 333 | const { uuid } = await servers[1].videos.upload({ attributes: { name: 'remote please blacklist me' } }) |
6691c522 C |
334 | await waitJobs(servers) |
335 | ||
d23dd9fb | 336 | await checkIsBlacklisted(uuid, true) |
6691c522 C |
337 | }) |
338 | ||
339 | it('Should blacklist on remote update', async function () { | |
3d470a53 | 340 | this.timeout(120000) |
6691c522 | 341 | |
89d241a7 | 342 | const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video' } }) |
6691c522 C |
343 | await waitJobs(servers) |
344 | ||
d23dd9fb | 345 | await checkIsBlacklisted(uuid, false) |
6691c522 | 346 | |
89d241a7 | 347 | await servers[1].videos.update({ id: uuid, attributes: { name: 'please blacklist me' } }) |
6691c522 C |
348 | await waitJobs(servers) |
349 | ||
d23dd9fb | 350 | await checkIsBlacklisted(uuid, true) |
6691c522 C |
351 | }) |
352 | }) | |
353 | ||
4ce7eb71 C |
354 | describe('Should run filter:api.user.signup.allowed.result', function () { |
355 | ||
356 | it('Should run on config endpoint', async function () { | |
89d241a7 | 357 | const body = await servers[0].config.getConfig() |
65e6e260 | 358 | expect(body.signup.allowed).to.be.true |
4ce7eb71 C |
359 | }) |
360 | ||
361 | it('Should allow a signup', async function () { | |
89d241a7 | 362 | await servers[0].users.register({ username: 'john', password: 'password' }) |
4ce7eb71 C |
363 | }) |
364 | ||
365 | it('Should not allow a signup', async function () { | |
89d241a7 | 366 | const res = await servers[0].users.register({ |
7926c5f9 C |
367 | username: 'jma', |
368 | password: 'password', | |
369 | expectedStatus: HttpStatusCode.FORBIDDEN_403 | |
370 | }) | |
4ce7eb71 C |
371 | |
372 | expect(res.body.error).to.equal('No jma') | |
373 | }) | |
374 | }) | |
375 | ||
4bc45da3 C |
376 | describe('Download hooks', function () { |
377 | const downloadVideos: VideoDetails[] = [] | |
378 | ||
379 | before(async function () { | |
c4244cfd | 380 | this.timeout(120000) |
4bc45da3 | 381 | |
89d241a7 | 382 | await servers[0].config.updateCustomSubConfig({ |
65e6e260 C |
383 | newConfig: { |
384 | transcoding: { | |
385 | webtorrent: { | |
386 | enabled: true | |
387 | }, | |
388 | hls: { | |
389 | enabled: true | |
390 | } | |
4bc45da3 C |
391 | } |
392 | } | |
393 | }) | |
394 | ||
395 | const uuids: string[] = [] | |
396 | ||
397 | for (const name of [ 'bad torrent', 'bad file', 'bad playlist file' ]) { | |
ba2684ce | 398 | const uuid = (await servers[0].videos.quickUpload({ name })).uuid |
4bc45da3 C |
399 | uuids.push(uuid) |
400 | } | |
401 | ||
402 | await waitJobs(servers) | |
403 | ||
404 | for (const uuid of uuids) { | |
89d241a7 | 405 | downloadVideos.push(await servers[0].videos.get({ id: uuid })) |
4bc45da3 C |
406 | } |
407 | }) | |
408 | ||
409 | it('Should run filter:api.download.torrent.allowed.result', async function () { | |
410 | const res = await makeRawRequest(downloadVideos[0].files[0].torrentDownloadUrl, 403) | |
411 | expect(res.body.error).to.equal('Liu Bei') | |
412 | ||
413 | await makeRawRequest(downloadVideos[1].files[0].torrentDownloadUrl, 200) | |
414 | await makeRawRequest(downloadVideos[2].files[0].torrentDownloadUrl, 200) | |
415 | }) | |
416 | ||
417 | it('Should run filter:api.download.video.allowed.result', async function () { | |
418 | { | |
419 | const res = await makeRawRequest(downloadVideos[1].files[0].fileDownloadUrl, 403) | |
420 | expect(res.body.error).to.equal('Cao Cao') | |
421 | ||
422 | await makeRawRequest(downloadVideos[0].files[0].fileDownloadUrl, 200) | |
423 | await makeRawRequest(downloadVideos[2].files[0].fileDownloadUrl, 200) | |
424 | } | |
425 | ||
426 | { | |
427 | const res = await makeRawRequest(downloadVideos[2].streamingPlaylists[0].files[0].fileDownloadUrl, 403) | |
428 | expect(res.body.error).to.equal('Sun Jian') | |
429 | ||
430 | await makeRawRequest(downloadVideos[2].files[0].fileDownloadUrl, 200) | |
431 | ||
432 | await makeRawRequest(downloadVideos[0].streamingPlaylists[0].files[0].fileDownloadUrl, 200) | |
433 | await makeRawRequest(downloadVideos[1].streamingPlaylists[0].files[0].fileDownloadUrl, 200) | |
434 | } | |
435 | }) | |
436 | }) | |
437 | ||
eebd9838 C |
438 | describe('Embed filters', function () { |
439 | const embedVideos: VideoDetails[] = [] | |
440 | const embedPlaylists: VideoPlaylist[] = [] | |
441 | ||
442 | before(async function () { | |
443 | this.timeout(60000) | |
444 | ||
c729caf6 | 445 | await servers[0].config.disableTranscoding() |
eebd9838 C |
446 | |
447 | for (const name of [ 'bad embed', 'good embed' ]) { | |
448 | { | |
ba2684ce | 449 | const uuid = (await servers[0].videos.quickUpload({ name })).uuid |
89d241a7 | 450 | embedVideos.push(await servers[0].videos.get({ id: uuid })) |
eebd9838 C |
451 | } |
452 | ||
453 | { | |
89d241a7 C |
454 | const attributes = { displayName: name, videoChannelId: servers[0].store.channel.id, privacy: VideoPlaylistPrivacy.PUBLIC } |
455 | const { id } = await servers[0].playlists.create({ attributes }) | |
eebd9838 | 456 | |
89d241a7 | 457 | const playlist = await servers[0].playlists.get({ playlistId: id }) |
e6346d59 | 458 | embedPlaylists.push(playlist) |
eebd9838 C |
459 | } |
460 | } | |
461 | }) | |
462 | ||
463 | it('Should run filter:html.embed.video.allowed.result', async function () { | |
464 | const res = await makeRawRequest(servers[0].url + embedVideos[0].embedPath, 200) | |
465 | expect(res.text).to.equal('Lu Bu') | |
466 | }) | |
467 | ||
468 | it('Should run filter:html.embed.video-playlist.allowed.result', async function () { | |
469 | const res = await makeRawRequest(servers[0].url + embedPlaylists[0].embedPath, 200) | |
470 | expect(res.text).to.equal('Diao Chan') | |
471 | }) | |
472 | }) | |
473 | ||
74a4d531 C |
474 | describe('Search filters', function () { |
475 | ||
476 | before(async function () { | |
89d241a7 | 477 | await servers[0].config.updateCustomSubConfig({ |
65e6e260 C |
478 | newConfig: { |
479 | search: { | |
480 | searchIndex: { | |
481 | enabled: true, | |
482 | isDefaultSearch: false, | |
483 | disableLocalSearch: false | |
484 | } | |
74a4d531 C |
485 | } |
486 | } | |
487 | }) | |
488 | }) | |
489 | ||
490 | it('Should run filter:api.search.videos.local.list.{params,result}', async function () { | |
89d241a7 | 491 | await servers[0].search.advancedVideoSearch({ |
af971e06 C |
492 | search: { |
493 | search: 'Sun Quan' | |
494 | } | |
74a4d531 C |
495 | }) |
496 | ||
89d241a7 C |
497 | await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.local.list.params', 1) |
498 | await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.local.list.result', 1) | |
74a4d531 C |
499 | }) |
500 | ||
501 | it('Should run filter:api.search.videos.index.list.{params,result}', async function () { | |
89d241a7 | 502 | await servers[0].search.advancedVideoSearch({ |
af971e06 C |
503 | search: { |
504 | search: 'Sun Quan', | |
505 | searchTarget: 'search-index' | |
506 | } | |
74a4d531 C |
507 | }) |
508 | ||
89d241a7 C |
509 | await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.local.list.params', 1) |
510 | await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.local.list.result', 1) | |
511 | await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.index.list.params', 1) | |
512 | await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.index.list.result', 1) | |
74a4d531 C |
513 | }) |
514 | ||
515 | it('Should run filter:api.search.video-channels.local.list.{params,result}', async function () { | |
89d241a7 | 516 | await servers[0].search.advancedChannelSearch({ |
af971e06 C |
517 | search: { |
518 | search: 'Sun Ce' | |
519 | } | |
74a4d531 C |
520 | }) |
521 | ||
89d241a7 C |
522 | await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.local.list.params', 1) |
523 | await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.local.list.result', 1) | |
74a4d531 C |
524 | }) |
525 | ||
526 | it('Should run filter:api.search.video-channels.index.list.{params,result}', async function () { | |
89d241a7 | 527 | await servers[0].search.advancedChannelSearch({ |
af971e06 C |
528 | search: { |
529 | search: 'Sun Ce', | |
530 | searchTarget: 'search-index' | |
531 | } | |
74a4d531 C |
532 | }) |
533 | ||
89d241a7 C |
534 | await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.local.list.params', 1) |
535 | await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.local.list.result', 1) | |
536 | await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.index.list.params', 1) | |
537 | await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.index.list.result', 1) | |
74a4d531 | 538 | }) |
37a44fc9 C |
539 | |
540 | it('Should run filter:api.search.video-playlists.local.list.{params,result}', async function () { | |
89d241a7 | 541 | await servers[0].search.advancedPlaylistSearch({ |
af971e06 C |
542 | search: { |
543 | search: 'Sun Jian' | |
544 | } | |
37a44fc9 C |
545 | }) |
546 | ||
89d241a7 C |
547 | await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.params', 1) |
548 | await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.result', 1) | |
37a44fc9 C |
549 | }) |
550 | ||
551 | it('Should run filter:api.search.video-playlists.index.list.{params,result}', async function () { | |
89d241a7 | 552 | await servers[0].search.advancedPlaylistSearch({ |
af971e06 C |
553 | search: { |
554 | search: 'Sun Jian', | |
555 | searchTarget: 'search-index' | |
556 | } | |
37a44fc9 C |
557 | }) |
558 | ||
89d241a7 C |
559 | await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.params', 1) |
560 | await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.result', 1) | |
561 | await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.index.list.params', 1) | |
562 | await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.index.list.result', 1) | |
37a44fc9 | 563 | }) |
74a4d531 C |
564 | }) |
565 | ||
d17d7430 C |
566 | describe('Upload/import/live attributes filters', function () { |
567 | ||
568 | before(async function () { | |
569 | await servers[0].config.enableLive({ transcoding: false, allowReplay: false }) | |
570 | await servers[0].config.enableImports() | |
571 | await servers[0].config.disableTranscoding() | |
572 | }) | |
573 | ||
574 | it('Should run filter:api.video.upload.video-attribute.result', async function () { | |
575 | for (const mode of [ 'legacy' as 'legacy', 'resumable' as 'resumable' ]) { | |
576 | const { id } = await servers[0].videos.upload({ attributes: { name: 'video', description: 'upload' }, mode }) | |
577 | ||
578 | const video = await servers[0].videos.get({ id }) | |
579 | expect(video.description).to.equal('upload - filter:api.video.upload.video-attribute.result') | |
580 | } | |
581 | }) | |
582 | ||
583 | it('Should run filter:api.video.import-url.video-attribute.result', async function () { | |
584 | const attributes = { | |
585 | name: 'video', | |
586 | description: 'import url', | |
587 | channelId: servers[0].store.channel.id, | |
588 | targetUrl: FIXTURE_URLS.goodVideo, | |
589 | privacy: VideoPrivacy.PUBLIC | |
590 | } | |
591 | const { video: { id } } = await servers[0].imports.importVideo({ attributes }) | |
592 | ||
593 | const video = await servers[0].videos.get({ id }) | |
594 | expect(video.description).to.equal('import url - filter:api.video.import-url.video-attribute.result') | |
595 | }) | |
596 | ||
597 | it('Should run filter:api.video.import-torrent.video-attribute.result', async function () { | |
598 | const attributes = { | |
599 | name: 'video', | |
600 | description: 'import torrent', | |
601 | channelId: servers[0].store.channel.id, | |
602 | magnetUri: FIXTURE_URLS.magnet, | |
603 | privacy: VideoPrivacy.PUBLIC | |
604 | } | |
605 | const { video: { id } } = await servers[0].imports.importVideo({ attributes }) | |
606 | ||
607 | const video = await servers[0].videos.get({ id }) | |
608 | expect(video.description).to.equal('import torrent - filter:api.video.import-torrent.video-attribute.result') | |
609 | }) | |
610 | ||
611 | it('Should run filter:api.video.live.video-attribute.result', async function () { | |
612 | const fields = { | |
613 | name: 'live', | |
614 | description: 'live', | |
615 | channelId: servers[0].store.channel.id, | |
616 | privacy: VideoPrivacy.PUBLIC | |
617 | } | |
618 | const { id } = await servers[0].live.create({ fields }) | |
619 | ||
620 | const video = await servers[0].videos.get({ id }) | |
621 | expect(video.description).to.equal('live - filter:api.video.live.video-attribute.result') | |
622 | }) | |
623 | }) | |
624 | ||
65058050 C |
625 | describe('Stats filters', function () { |
626 | ||
627 | it('Should run filter:api.server.stats.get.result', async function () { | |
628 | const data = await servers[0].stats.get() | |
629 | ||
630 | expect((data as any).customStats).to.equal(14) | |
631 | }) | |
632 | ||
633 | }) | |
634 | ||
9b474844 | 635 | after(async function () { |
89cd1275 | 636 | await cleanupTests(servers) |
9b474844 C |
637 | }) |
638 | }) |