Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Centralize test URLs

Chocobozzz59bbcced3700
diff --git a/server/tests/api/check-params/upload-quota.ts b/server/tests/api/check-params/upload-quota.ts
index 2c73e6a19d..bd8dce9753 100644
--- a/server/tests/api/check-params/upload-quota.ts
+++ b/server/tests/api/check-params/upload-quota.ts
@@ -6,7 +6,7 @@ import { HttpStatusCode, randomInt } from '@shared/core-utils'
import {
cleanupTests,
createSingleServer,
- ImportsCommand,
+ FIXTURE_URLS,
PeerTubeServer,
setAccessTokensToServers,
setDefaultVideoChannel,
@@ -76,8 +76,8 @@ describe('Test upload quota', function () {
channelId: server.store.channel.id,
privacy: VideoPrivacy.PUBLIC
}
- await server.imports.importVideo({ attributes: { ...baseAttributes, targetUrl: ImportsCommand.getGoodVideoUrl() } })
- await server.imports.importVideo({ attributes: { ...baseAttributes, magnetUri: ImportsCommand.getMagnetURI() } })
+ await server.imports.importVideo({ attributes: { ...baseAttributes, targetUrl: FIXTURE_URLS.goodVideo } })
+ await server.imports.importVideo({ attributes: { ...baseAttributes, magnetUri: FIXTURE_URLS.magnet } })
await server.imports.importVideo({ attributes: { ...baseAttributes, torrentfile: 'video-720p.torrent' as any } })
await waitJobs([ server ])
diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts
index 627f0c7ad4..0209275ac8 100644
--- a/server/tests/api/check-params/video-imports.ts
+++ b/server/tests/api/check-params/video-imports.ts
@@ -10,7 +10,7 @@ import {
checkBadStartPagination,
cleanupTests,
createSingleServer,
- ImportsCommand,
+ FIXTURE_URLS,
makeGetRequest,
makePostBodyRequest,
makeUploadRequest,
@@ -70,7 +70,7 @@ describe('Test video imports API validator', function () {
before(function () {
baseCorrectParams = {
- targetUrl: ImportsCommand.getGoodVideoUrl(),
+ targetUrl: FIXTURE_URLS.goodVideo,
name: 'my super name',
category: 5,
licence: 1,
@@ -297,7 +297,7 @@ describe('Test video imports API validator', function () {
})
let fields = omit(baseCorrectParams, 'targetUrl')
- fields = { ...fields, magnetUri: ImportsCommand.getMagnetURI() }
+ fields = { ...fields, magnetUri: FIXTURE_URLS.magnet }
await makePostBodyRequest({
url: server.url,
diff --git a/server/tests/api/moderation/video-blacklist.ts b/server/tests/api/moderation/video-blacklist.ts
index 62cbf2e079..d5838191ad 100644
--- a/server/tests/api/moderation/video-blacklist.ts
+++ b/server/tests/api/moderation/video-blacklist.ts
@@ -6,9 +6,9 @@ import { orderBy } from 'lodash'
import {
BlacklistCommand,
cleanupTests,
- doubleFollow,
createMultipleServers,
- ImportsCommand,
+ doubleFollow,
+ FIXTURE_URLS,
killallServers,
PeerTubeServer,
setAccessTokensToServers,
@@ -387,7 +387,7 @@ describe('Test video blacklist', function () {
this.timeout(15000)
const attributes = {
- targetUrl: ImportsCommand.getGoodVideoUrl(),
+ targetUrl: FIXTURE_URLS.goodVideo,
name: 'URL import',
channelId: channelOfUserWithoutFlag
}
@@ -400,7 +400,7 @@ describe('Test video blacklist', function () {
it('Should auto blacklist a video on torrent import', async function () {
const attributes = {
- magnetUri: ImportsCommand.getMagnetURI(),
+ magnetUri: FIXTURE_URLS.magnet,
name: 'Torrent import',
channelId: channelOfUserWithoutFlag
}
diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts
index b7c22d1189..ca592d4669 100644
--- a/server/tests/api/notifications/user-notifications.ts
+++ b/server/tests/api/notifications/user-notifications.ts
@@ -10,10 +10,10 @@ import {
checkNewVideoFromSubscription,
checkVideoIsPublished,
cleanupTests,
- ImportsCommand,
+ FIXTURE_URLS,
MockSmtpServer,
- prepareNotificationsTest,
PeerTubeServer,
+ prepareNotificationsTest,
uploadRandomVideoOnServers,
wait,
waitJobs
@@ -205,7 +205,7 @@ describe('Test user notifications', function () {
name,
channelId,
privacy: VideoPrivacy.PUBLIC,
- targetUrl: ImportsCommand.getGoodVideoUrl()
+ targetUrl: FIXTURE_URLS.goodVideo
}
const { video } = await servers[0].imports.importVideo({ attributes })
@@ -275,7 +275,7 @@ describe('Test user notifications', function () {
name,
channelId,
privacy: VideoPrivacy.PUBLIC,
- targetUrl: ImportsCommand.getGoodVideoUrl(),
+ targetUrl: FIXTURE_URLS.goodVideo,
waitTranscoding: true
}
const { video } = await servers[1].imports.importVideo({ attributes })
@@ -343,12 +343,12 @@ describe('Test user notifications', function () {
name,
channelId,
privacy: VideoPrivacy.PRIVATE,
- targetUrl: ImportsCommand.getBadVideoUrl()
+ targetUrl: FIXTURE_URLS.badVideo
}
const { video } = await servers[0].imports.importVideo({ attributes })
await waitJobs(servers)
- await checkMyVideoImportIsFinished(baseParams, name, video.uuid, ImportsCommand.getBadVideoUrl(), false, 'presence')
+ await checkMyVideoImportIsFinished(baseParams, name, video.uuid, FIXTURE_URLS.badVideo, false, 'presence')
})
it('Should send a notification when the video import succeeded', async function () {
@@ -360,12 +360,12 @@ describe('Test user notifications', function () {
name,
channelId,
privacy: VideoPrivacy.PRIVATE,
- targetUrl: ImportsCommand.getGoodVideoUrl()
+ targetUrl: FIXTURE_URLS.goodVideo
}
const { video } = await servers[0].imports.importVideo({ attributes })
await waitJobs(servers)
- await checkMyVideoImportIsFinished(baseParams, name, video.uuid, ImportsCommand.getGoodVideoUrl(), true, 'presence')
+ await checkMyVideoImportIsFinished(baseParams, name, video.uuid, FIXTURE_URLS.goodVideo, true, 'presence')
})
})
diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts
index 4ef55c3af4..192f5232ef 100644
--- a/server/tests/api/videos/video-imports.ts
+++ b/server/tests/api/videos/video-imports.ts
@@ -5,9 +5,9 @@ import * as chai from 'chai'
import {
areHttpImportTestsDisabled,
cleanupTests,
- doubleFollow,
createMultipleServers,
- ImportsCommand,
+ doubleFollow,
+ FIXTURE_URLS,
PeerTubeServer,
setAccessTokensToServers,
testCaptionFile,
@@ -110,7 +110,7 @@ describe('Test video imports', function () {
}
{
- const attributes = { ...baseAttributes, targetUrl: ImportsCommand.getYoutubeVideoUrl() }
+ const attributes = { ...baseAttributes, targetUrl: FIXTURE_URLS.youtube }
const { video } = await servers[0].imports.importVideo({ attributes })
expect(video.name).to.equal('small video - youtube')
@@ -162,7 +162,7 @@ Ajouter un sous-titre est vraiment facile`)
{
const attributes = {
...baseAttributes,
- magnetUri: ImportsCommand.getMagnetURI(),
+ magnetUri: FIXTURE_URLS.magnet,
description: 'this is a super torrent description',
tags: [ 'tag_torrent1', 'tag_torrent2' ]
}
@@ -199,13 +199,13 @@ Ajouter un sous-titre est vraiment facile`)
expect(videoImports).to.have.lengthOf(3)
- expect(videoImports[2].targetUrl).to.equal(ImportsCommand.getYoutubeVideoUrl())
+ expect(videoImports[2].targetUrl).to.equal(FIXTURE_URLS.youtube)
expect(videoImports[2].magnetUri).to.be.null
expect(videoImports[2].torrentName).to.be.null
expect(videoImports[2].video.name).to.equal('small video - youtube')
expect(videoImports[1].targetUrl).to.be.null
- expect(videoImports[1].magnetUri).to.equal(ImportsCommand.getMagnetURI())
+ expect(videoImports[1].magnetUri).to.equal(FIXTURE_URLS.magnet)
expect(videoImports[1].torrentName).to.be.null
expect(videoImports[1].video.name).to.equal('super peertube2 video')
@@ -234,7 +234,7 @@ Ajouter un sous-titre est vraiment facile`)
this.timeout(60_000)
const attributes = {
- targetUrl: ImportsCommand.getYoutubeVideoUrl(),
+ targetUrl: FIXTURE_URLS.youtube,
channelId: channelIdServer2,
privacy: VideoPrivacy.PUBLIC,
category: 10,
@@ -270,7 +270,7 @@ Ajouter un sous-titre est vraiment facile`)
const attributes = {
name: 'transcoded video',
- magnetUri: ImportsCommand.getMagnetURI(),
+ magnetUri: FIXTURE_URLS.magnet,
channelId: channelIdServer2,
privacy: VideoPrivacy.PUBLIC
}
@@ -320,7 +320,7 @@ Ajouter un sous-titre est vraiment facile`)
const attributes = {
name: 'hdr video',
- targetUrl: ImportsCommand.getYoutubeHDRVideoUrl(),
+ targetUrl: FIXTURE_URLS.youtubeHDR,
channelId: channelIdServer1,
privacy: VideoPrivacy.PUBLIC
}
diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts
index f19b6ae227..f2a9849628 100644
--- a/server/tests/cli/peertube.ts
+++ b/server/tests/cli/peertube.ts
@@ -7,9 +7,9 @@ import {
buildAbsoluteFixturePath,
cleanupTests,
CLICommand,
- doubleFollow,
createSingleServer,
- ImportsCommand,
+ doubleFollow,
+ FIXTURE_URLS,
PeerTubeServer,
setAccessTokensToServers,
testHelloWorldRegisteredSettings,
@@ -117,7 +117,7 @@ describe('Test CLI wrapper', function () {
this.timeout(60000)
- const params = `--target-url ${ImportsCommand.getYoutubeVideoUrl()} --channel-name user_channel`
+ const params = `--target-url ${FIXTURE_URLS.youtube} --channel-name user_channel`
await cliCommand.execWithEnv(`${cmd} import ${params}`)
})
@@ -148,7 +148,7 @@ describe('Test CLI wrapper', function () {
this.timeout(60000)
- const params = `--target-url ${ImportsCommand.getYoutubeVideoUrl()} ` +
+ const params = `--target-url ${FIXTURE_URLS.youtube} ` +
`--channel-name user_channel --video-name toto --nsfw --support support`
await cliCommand.execWithEnv(`${cmd} import ${params}`)
diff --git a/server/tests/helpers/request.ts b/server/tests/helpers/request.ts
index 5e77f129ea..7f7873df34 100644
--- a/server/tests/helpers/request.ts
+++ b/server/tests/helpers/request.ts
@@ -4,7 +4,7 @@ import 'mocha'
import { expect } from 'chai'
import { pathExists, remove } from 'fs-extra'
import { join } from 'path'
-import { get4KFileUrl, root, wait } from '../../../shared/extra-utils'
+import { FIXTURE_URLS, root, wait } from '../../../shared/extra-utils'
import { doRequest, doRequestAndSaveToFile } from '../../helpers/requests'
describe('Request helpers', function () {
@@ -13,7 +13,7 @@ describe('Request helpers', function () {
it('Should throw an error when the bytes limit is exceeded for request', async function () {
try {
- await doRequest(get4KFileUrl(), { bodyKBLimit: 3 })
+ await doRequest(FIXTURE_URLS.video4K, { bodyKBLimit: 3 })
} catch {
return
}
@@ -23,7 +23,7 @@ describe('Request helpers', function () {
it('Should throw an error when the bytes limit is exceeded for request and save file', async function () {
try {
- await doRequestAndSaveToFile(get4KFileUrl(), destPath1, { bodyKBLimit: 3 })
+ await doRequestAndSaveToFile(FIXTURE_URLS.video4K, destPath1, { bodyKBLimit: 3 })
} catch {
await wait(500)
@@ -35,8 +35,8 @@ describe('Request helpers', function () {
})
it('Should succeed if the file is below the limit', async function () {
- await doRequest(get4KFileUrl(), { bodyKBLimit: 5 })
- await doRequestAndSaveToFile(get4KFileUrl(), destPath2, { bodyKBLimit: 5 })
+ await doRequest(FIXTURE_URLS.video4K, { bodyKBLimit: 5 })
+ await doRequestAndSaveToFile(FIXTURE_URLS.video4K, destPath2, { bodyKBLimit: 5 })
expect(await pathExists(destPath2)).to.be.true
})
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts
index 5d94303a94..df52bb3b57 100644
--- a/server/tests/plugins/filter-hooks.ts
+++ b/server/tests/plugins/filter-hooks.ts
@@ -5,12 +5,12 @@ import * as chai from 'chai'
import { HttpStatusCode } from '@shared/core-utils'
import {
cleanupTests,
- doubleFollow,
createMultipleServers,
- ImportsCommand,
+ doubleFollow,
+ FIXTURE_URLS,
makeRawRequest,
- PluginsCommand,
PeerTubeServer,
+ PluginsCommand,
setAccessTokensToServers,
setDefaultVideoChannel,
waitJobs
@@ -136,7 +136,7 @@ describe('Test plugin filter hooks', function () {
name: 'normal title',
privacy: VideoPrivacy.PUBLIC,
channelId: servers[0].store.channel.id,
- targetUrl: ImportsCommand.getGoodVideoUrl() + 'bad'
+ targetUrl: FIXTURE_URLS.goodVideo + 'bad'
}
await servers[0].imports.importVideo({ attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
@@ -161,7 +161,7 @@ describe('Test plugin filter hooks', function () {
name: 'title with bad word',
privacy: VideoPrivacy.PUBLIC,
channelId: servers[0].store.channel.id,
- targetUrl: ImportsCommand.getGoodVideoUrl()
+ targetUrl: FIXTURE_URLS.goodVideo
}
const body = await servers[0].imports.importVideo({ attributes })
videoImportId = body.id
@@ -273,7 +273,7 @@ describe('Test plugin filter hooks', function () {
const attributes = {
name: 'video please blacklist me',
- targetUrl: ImportsCommand.getGoodVideoUrl(),
+ targetUrl: FIXTURE_URLS.goodVideo,
channelId: servers[0].store.channel.id
}
const body = await servers[0].imports.importVideo({ attributes })
diff --git a/shared/extra-utils/miscs/tests.ts b/shared/extra-utils/miscs/tests.ts
index 8f7a2f92b4..3dfb2487ed 100644
--- a/shared/extra-utils/miscs/tests.ts
+++ b/shared/extra-utils/miscs/tests.ts
@@ -1,6 +1,36 @@
import { stat } from 'fs-extra'
import { basename, isAbsolute, join, resolve } from 'path'
+const FIXTURE_URLS = {
+ youtube: 'https://www.youtube.com/watch?v=msX3jv1XdvM',
+
+ /**
+ * The video is used to check format-selection correctness wrt. HDR,
+ * which brings its own set of oddities outside of a MediaSource.
+ * FIXME: refactor once HDR is supported at playback
+ *
+ * The video needs to have the following format_ids:
+ * (which you can check by using `youtube-dl <url> -F`):
+ * - 303 (1080p webm vp9)
+ * - 299 (1080p mp4 avc1)
+ * - 335 (1080p webm vp9.2 HDR)
+ *
+ * 15 jan. 2021: TEST VIDEO NOT CURRENTLY PROVIDING
+ * - 400 (1080p mp4 av01)
+ * - 315 (2160p webm vp9 HDR)
+ * - 337 (2160p webm vp9.2 HDR)
+ * - 401 (2160p mp4 av01 HDR)
+ */
+ youtubeHDR: 'https://www.youtube.com/watch?v=qR5vOXbZsI4',
+
+ // eslint-disable-next-line max-len
+ magnet: 'magnet:?xs=https%3A%2F%2Fpeertube2.cpy.re%2Fstatic%2Ftorrents%2Fb209ca00-c8bb-4b2b-b421-1ede169f3dbc-720.torrent&xt=urn:btih:0f498834733e8057ed5c6f2ee2b4efd8d84a76ee&dn=super+peertube2+video&tr=wss%3A%2F%2Fpeertube2.cpy.re%3A443%2Ftracker%2Fsocket&tr=https%3A%2F%2Fpeertube2.cpy.re%2Ftracker%2Fannounce&ws=https%3A%2F%2Fpeertube2.cpy.re%2Fstatic%2Fwebseed%2Fb209ca00-c8bb-4b2b-b421-1ede169f3dbc-720.mp4',
+
+ badVideo: 'https://download.cpy.re/peertube/bad_video.mp4',
+ goodVideo: 'https://download.cpy.re/peertube/good_video.mp4',
+ video4K: 'https://download.cpy.re/peertube/4k_file.txt'
+}
+
function parallelTests () {
return process.env.MOCHA_PARALLEL === 'true'
}
@@ -51,6 +81,8 @@ function buildRequestStub (): any {
}
export {
+ FIXTURE_URLS,
+
parallelTests,
isGithubCI,
areHttpImportTestsDisabled,
diff --git a/shared/extra-utils/requests/requests.ts b/shared/extra-utils/requests/requests.ts
index 3f1ac66504..60c9b938bd 100644
--- a/shared/extra-utils/requests/requests.ts
+++ b/shared/extra-utils/requests/requests.ts
@@ -7,10 +7,6 @@ import { URL } from 'url'
import { HttpStatusCode } from '@shared/core-utils'
import { buildAbsoluteFixturePath, root } from '../miscs/tests'
-function get4KFileUrl () {
- return 'https://download.cpy.re/peertube/4k_file.txt'
-}
-
function makeRawRequest (url: string, statusCodeExpected?: HttpStatusCode, range?: string) {
const { host, protocol, pathname } = new URL(url)
@@ -227,7 +223,6 @@ function unwrapText (test: request.Test): Promise<string> {
// ---------------------------------------------------------------------------
export {
- get4KFileUrl,
makeHTMLRequest,
makeGetRequest,
decodeQueryString,
diff --git a/shared/extra-utils/videos/imports-command.ts b/shared/extra-utils/videos/imports-command.ts
index 024aa363f3..de8b658299 100644
--- a/shared/extra-utils/videos/imports-command.ts
+++ b/shared/extra-utils/videos/imports-command.ts
@@ -7,44 +7,6 @@ import { AbstractCommand, OverrideCommandOptions } from '../shared'
export class ImportsCommand extends AbstractCommand {
- static getYoutubeVideoUrl () {
- return 'https://www.youtube.com/watch?v=msX3jv1XdvM'
- }
-
- static getYoutubeHDRVideoUrl () {
- /**
- * The video is used to check format-selection correctness wrt. HDR,
- * which brings its own set of oddities outside of a MediaSource.
- * FIXME: refactor once HDR is supported at playback
- *
- * The video needs to have the following format_ids:
- * (which you can check by using `youtube-dl <url> -F`):
- * - 303 (1080p webm vp9)
- * - 299 (1080p mp4 avc1)
- * - 335 (1080p webm vp9.2 HDR)
- *
- * 15 jan. 2021: TEST VIDEO NOT CURRENTLY PROVIDING
- * - 400 (1080p mp4 av01)
- * - 315 (2160p webm vp9 HDR)
- * - 337 (2160p webm vp9.2 HDR)
- * - 401 (2160p mp4 av01 HDR)
- */
- return 'https://www.youtube.com/watch?v=qR5vOXbZsI4'
- }
-
- static getMagnetURI () {
- // eslint-disable-next-line max-len
- return 'magnet:?xs=https%3A%2F%2Fpeertube2.cpy.re%2Fstatic%2Ftorrents%2Fb209ca00-c8bb-4b2b-b421-1ede169f3dbc-720.torrent&xt=urn:btih:0f498834733e8057ed5c6f2ee2b4efd8d84a76ee&dn=super+peertube2+video&tr=wss%3A%2F%2Fpeertube2.cpy.re%3A443%2Ftracker%2Fsocket&tr=https%3A%2F%2Fpeertube2.cpy.re%2Ftracker%2Fannounce&ws=https%3A%2F%2Fpeertube2.cpy.re%2Fstatic%2Fwebseed%2Fb209ca00-c8bb-4b2b-b421-1ede169f3dbc-720.mp4'
- }
-
- static getBadVideoUrl () {
- return 'https://download.cpy.re/peertube/bad_video.mp4'
- }
-
- static getGoodVideoUrl () {
- return 'https://download.cpy.re/peertube/good_video.mp4'
- }
-
importVideo (options: OverrideCommandOptions & {
attributes: VideoImportCreate & { torrentfile?: string }
}) {