From 3545e72c686ff1725bbdfd8d16d693e2f4aa75a3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 12 Oct 2022 16:09:02 +0200 Subject: Put private videos under a specific subdirectory --- server/tests/plugins/filter-hooks.ts | 36 ++++++++++++++++++++++------------ server/tests/plugins/plugin-helpers.ts | 6 +++--- 2 files changed, 27 insertions(+), 15 deletions(-) (limited to 'server/tests/plugins') diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts index ae4b3cf5f..083fd43ca 100644 --- a/server/tests/plugins/filter-hooks.ts +++ b/server/tests/plugins/filter-hooks.ts @@ -6,6 +6,7 @@ import { cleanupTests, createMultipleServers, doubleFollow, + makeGetRequest, makeRawRequest, PeerTubeServer, PluginsCommand, @@ -461,30 +462,41 @@ describe('Test plugin filter hooks', function () { }) it('Should run filter:api.download.torrent.allowed.result', async function () { - const res = await makeRawRequest(downloadVideos[0].files[0].torrentDownloadUrl, 403) + const res = await makeRawRequest({ url: downloadVideos[0].files[0].torrentDownloadUrl, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) expect(res.body.error).to.equal('Liu Bei') - await makeRawRequest(downloadVideos[1].files[0].torrentDownloadUrl, 200) - await makeRawRequest(downloadVideos[2].files[0].torrentDownloadUrl, 200) + await makeRawRequest({ url: downloadVideos[1].files[0].torrentDownloadUrl, expectedStatus: HttpStatusCode.OK_200 }) + await makeRawRequest({ url: downloadVideos[2].files[0].torrentDownloadUrl, expectedStatus: HttpStatusCode.OK_200 }) }) it('Should run filter:api.download.video.allowed.result', async function () { { - const res = await makeRawRequest(downloadVideos[1].files[0].fileDownloadUrl, 403) + const res = await makeRawRequest({ url: downloadVideos[1].files[0].fileDownloadUrl, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) expect(res.body.error).to.equal('Cao Cao') - await makeRawRequest(downloadVideos[0].files[0].fileDownloadUrl, 200) - await makeRawRequest(downloadVideos[2].files[0].fileDownloadUrl, 200) + await makeRawRequest({ url: downloadVideos[0].files[0].fileDownloadUrl, expectedStatus: HttpStatusCode.OK_200 }) + await makeRawRequest({ url: downloadVideos[2].files[0].fileDownloadUrl, expectedStatus: HttpStatusCode.OK_200 }) } { - const res = await makeRawRequest(downloadVideos[2].streamingPlaylists[0].files[0].fileDownloadUrl, 403) + const res = await makeRawRequest({ + url: downloadVideos[2].streamingPlaylists[0].files[0].fileDownloadUrl, + expectedStatus: HttpStatusCode.FORBIDDEN_403 + }) + expect(res.body.error).to.equal('Sun Jian') - await makeRawRequest(downloadVideos[2].files[0].fileDownloadUrl, 200) + await makeRawRequest({ url: downloadVideos[2].files[0].fileDownloadUrl, expectedStatus: HttpStatusCode.OK_200 }) + + await makeRawRequest({ + url: downloadVideos[0].streamingPlaylists[0].files[0].fileDownloadUrl, + expectedStatus: HttpStatusCode.OK_200 + }) - await makeRawRequest(downloadVideos[0].streamingPlaylists[0].files[0].fileDownloadUrl, 200) - await makeRawRequest(downloadVideos[1].streamingPlaylists[0].files[0].fileDownloadUrl, 200) + await makeRawRequest({ + url: downloadVideos[1].streamingPlaylists[0].files[0].fileDownloadUrl, + expectedStatus: HttpStatusCode.OK_200 + }) } }) }) @@ -515,12 +527,12 @@ describe('Test plugin filter hooks', function () { }) it('Should run filter:html.embed.video.allowed.result', async function () { - const res = await makeRawRequest(servers[0].url + embedVideos[0].embedPath, 200) + const res = await makeGetRequest({ url: servers[0].url, path: embedVideos[0].embedPath, expectedStatus: HttpStatusCode.OK_200 }) expect(res.text).to.equal('Lu Bu') }) it('Should run filter:html.embed.video-playlist.allowed.result', async function () { - const res = await makeRawRequest(servers[0].url + embedPlaylists[0].embedPath, 200) + const res = await makeGetRequest({ url: servers[0].url, path: embedPlaylists[0].embedPath, expectedStatus: HttpStatusCode.OK_200 }) expect(res.text).to.equal('Diao Chan') }) }) diff --git a/server/tests/plugins/plugin-helpers.ts b/server/tests/plugins/plugin-helpers.ts index 31c18350a..f2bada4ee 100644 --- a/server/tests/plugins/plugin-helpers.ts +++ b/server/tests/plugins/plugin-helpers.ts @@ -307,7 +307,7 @@ describe('Test plugin helpers', function () { expect(file.fps).to.equal(25) expect(await pathExists(file.path)).to.be.true - await makeRawRequest(file.url, HttpStatusCode.OK_200) + await makeRawRequest({ url: file.url, expectedStatus: HttpStatusCode.OK_200 }) } } @@ -321,12 +321,12 @@ describe('Test plugin helpers', function () { const miniature = body.thumbnails.find(t => t.type === ThumbnailType.MINIATURE) expect(miniature).to.exist expect(await pathExists(miniature.path)).to.be.true - await makeRawRequest(miniature.url, HttpStatusCode.OK_200) + await makeRawRequest({ url: miniature.url, expectedStatus: HttpStatusCode.OK_200 }) const preview = body.thumbnails.find(t => t.type === ThumbnailType.PREVIEW) expect(preview).to.exist expect(await pathExists(preview.path)).to.be.true - await makeRawRequest(preview.url, HttpStatusCode.OK_200) + await makeRawRequest({ url: preview.url, expectedStatus: HttpStatusCode.OK_200 }) } }) -- cgit v1.2.3