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