diff options
Diffstat (limited to 'server/tests/plugins')
-rw-r--r-- | server/tests/plugins/filter-hooks.ts | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts index d88170201..6996ae788 100644 --- a/server/tests/plugins/filter-hooks.ts +++ b/server/tests/plugins/filter-hooks.ts | |||
@@ -20,12 +20,14 @@ import { | |||
20 | getVideoThreadComments, | 20 | getVideoThreadComments, |
21 | getVideoWithToken, | 21 | getVideoWithToken, |
22 | installPlugin, | 22 | installPlugin, |
23 | makeRawRequest, | ||
23 | registerUser, | 24 | registerUser, |
24 | setAccessTokensToServers, | 25 | setAccessTokensToServers, |
25 | setDefaultVideoChannel, | 26 | setDefaultVideoChannel, |
26 | updateCustomSubConfig, | 27 | updateCustomSubConfig, |
27 | updateVideo, | 28 | updateVideo, |
28 | uploadVideo, | 29 | uploadVideo, |
30 | uploadVideoAndGetId, | ||
29 | waitJobs | 31 | waitJobs |
30 | } from '../../../shared/extra-utils' | 32 | } from '../../../shared/extra-utils' |
31 | import { cleanupTests, flushAndRunMultipleServers, ServerInfo } from '../../../shared/extra-utils/server/servers' | 33 | import { cleanupTests, flushAndRunMultipleServers, ServerInfo } from '../../../shared/extra-utils/server/servers' |
@@ -355,6 +357,67 @@ describe('Test plugin filter hooks', function () { | |||
355 | }) | 357 | }) |
356 | }) | 358 | }) |
357 | 359 | ||
360 | describe('Download hooks', function () { | ||
361 | const downloadVideos: VideoDetails[] = [] | ||
362 | |||
363 | before(async function () { | ||
364 | this.timeout(60000) | ||
365 | |||
366 | await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { | ||
367 | transcoding: { | ||
368 | webtorrent: { | ||
369 | enabled: true | ||
370 | }, | ||
371 | hls: { | ||
372 | enabled: true | ||
373 | } | ||
374 | } | ||
375 | }) | ||
376 | |||
377 | const uuids: string[] = [] | ||
378 | |||
379 | for (const name of [ 'bad torrent', 'bad file', 'bad playlist file' ]) { | ||
380 | const uuid = (await uploadVideoAndGetId({ server: servers[0], videoName: name })).uuid | ||
381 | uuids.push(uuid) | ||
382 | } | ||
383 | |||
384 | await waitJobs(servers) | ||
385 | |||
386 | for (const uuid of uuids) { | ||
387 | const res = await getVideo(servers[0].url, uuid) | ||
388 | downloadVideos.push(res.body) | ||
389 | } | ||
390 | }) | ||
391 | |||
392 | it('Should run filter:api.download.torrent.allowed.result', async function () { | ||
393 | const res = await makeRawRequest(downloadVideos[0].files[0].torrentDownloadUrl, 403) | ||
394 | expect(res.body.error).to.equal('Liu Bei') | ||
395 | |||
396 | await makeRawRequest(downloadVideos[1].files[0].torrentDownloadUrl, 200) | ||
397 | await makeRawRequest(downloadVideos[2].files[0].torrentDownloadUrl, 200) | ||
398 | }) | ||
399 | |||
400 | it('Should run filter:api.download.video.allowed.result', async function () { | ||
401 | { | ||
402 | const res = await makeRawRequest(downloadVideos[1].files[0].fileDownloadUrl, 403) | ||
403 | expect(res.body.error).to.equal('Cao Cao') | ||
404 | |||
405 | await makeRawRequest(downloadVideos[0].files[0].fileDownloadUrl, 200) | ||
406 | await makeRawRequest(downloadVideos[2].files[0].fileDownloadUrl, 200) | ||
407 | } | ||
408 | |||
409 | { | ||
410 | const res = await makeRawRequest(downloadVideos[2].streamingPlaylists[0].files[0].fileDownloadUrl, 403) | ||
411 | expect(res.body.error).to.equal('Sun Jian') | ||
412 | |||
413 | await makeRawRequest(downloadVideos[2].files[0].fileDownloadUrl, 200) | ||
414 | |||
415 | await makeRawRequest(downloadVideos[0].streamingPlaylists[0].files[0].fileDownloadUrl, 200) | ||
416 | await makeRawRequest(downloadVideos[1].streamingPlaylists[0].files[0].fileDownloadUrl, 200) | ||
417 | } | ||
418 | }) | ||
419 | }) | ||
420 | |||
358 | after(async function () { | 421 | after(async function () { |
359 | await cleanupTests(servers) | 422 | await cleanupTests(servers) |
360 | }) | 423 | }) |