aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-07-30 09:43:12 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-07-31 11:32:04 +0200
commitb488ba1e26b803ac6c637e8b11bdd444ca4c803f (patch)
tree0a9ce01fcfb26ecddd8a0dccf997514818b8a72f /server
parentb9fe9a7ffdf80d81c5580ccccfeb989051fd9d8a (diff)
downloadPeerTube-b488ba1e26b803ac6c637e8b11bdd444ca4c803f.tar.gz
PeerTube-b488ba1e26b803ac6c637e8b11bdd444ca4c803f.tar.zst
PeerTube-b488ba1e26b803ac6c637e8b11bdd444ca4c803f.zip
Don't rely on youtube for tests
Use another import URL when possible, and disable import tests when we want to do a youtube import test
Diffstat (limited to 'server')
-rw-r--r--server/tests/api/check-params/users.ts13
-rw-r--r--server/tests/api/check-params/video-imports.ts24
-rw-r--r--server/tests/api/notifications/user-notifications.ts10
-rw-r--r--server/tests/api/videos/video-blacklist.ts10
-rw-r--r--server/tests/api/videos/video-imports.ts14
-rw-r--r--server/tests/plugins/filter-hooks.ts8
6 files changed, 39 insertions, 40 deletions
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts
index 2fea2cbd5..3e53c445d 100644
--- a/server/tests/api/check-params/users.ts
+++ b/server/tests/api/check-params/users.ts
@@ -1,10 +1,10 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import { omit } from 'lodash'
4import 'mocha' 3import 'mocha'
4import { expect } from 'chai'
5import { omit } from 'lodash'
5import { join } from 'path' 6import { join } from 'path'
6import { User, UserRole, VideoImport, VideoImportState } from '../../../../shared' 7import { User, UserRole, VideoImport, VideoImportState } from '../../../../shared'
7
8import { 8import {
9 addVideoChannel, 9 addVideoChannel,
10 blockUser, 10 blockUser,
@@ -31,17 +31,16 @@ import {
31 uploadVideo, 31 uploadVideo,
32 userLogin 32 userLogin
33} from '../../../../shared/extra-utils' 33} from '../../../../shared/extra-utils'
34import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email'
34import { 35import {
35 checkBadCountPagination, 36 checkBadCountPagination,
36 checkBadSortPagination, 37 checkBadSortPagination,
37 checkBadStartPagination 38 checkBadStartPagination
38} from '../../../../shared/extra-utils/requests/check-api-params' 39} from '../../../../shared/extra-utils/requests/check-api-params'
39import { getMagnetURI, getMyVideoImports, getYoutubeVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports'
40import { VideoPrivacy } from '../../../../shared/models/videos'
41import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 40import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
42import { expect } from 'chai' 41import { getMagnetURI, getMyVideoImports, getGoodVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports'
43import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model' 42import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model'
44import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email' 43import { VideoPrivacy } from '../../../../shared/models/videos'
45 44
46describe('Test users API validators', function () { 45describe('Test users API validators', function () {
47 const path = '/api/v1/users/' 46 const path = '/api/v1/users/'
@@ -1047,7 +1046,7 @@ describe('Test users API validators', function () {
1047 channelId: 1, 1046 channelId: 1,
1048 privacy: VideoPrivacy.PUBLIC 1047 privacy: VideoPrivacy.PUBLIC
1049 } 1048 }
1050 await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { targetUrl: getYoutubeVideoUrl() })) 1049 await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { targetUrl: getGoodVideoUrl() }))
1051 await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { magnetUri: getMagnetURI() })) 1050 await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { magnetUri: getMagnetURI() }))
1052 await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { torrentfile: 'video-720p.torrent' as any })) 1051 await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { torrentfile: 'video-720p.torrent' as any }))
1053 1052
diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts
index 3759e47c4..f954ba089 100644
--- a/server/tests/api/check-params/video-imports.ts
+++ b/server/tests/api/check-params/video-imports.ts
@@ -1,9 +1,8 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import { omit } from 'lodash'
4import 'mocha' 3import 'mocha'
4import { omit } from 'lodash'
5import { join } from 'path' 5import { join } from 'path'
6import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum'
7import { 6import {
8 cleanupTests, 7 cleanupTests,
9 createUser, 8 createUser,
@@ -23,7 +22,8 @@ import {
23 checkBadSortPagination, 22 checkBadSortPagination,
24 checkBadStartPagination 23 checkBadStartPagination
25} from '../../../../shared/extra-utils/requests/check-api-params' 24} from '../../../../shared/extra-utils/requests/check-api-params'
26import { getMagnetURI, getYoutubeVideoUrl } from '../../../../shared/extra-utils/videos/video-imports' 25import { getMagnetURI, getGoodVideoUrl } from '../../../../shared/extra-utils/videos/video-imports'
26import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum'
27 27
28describe('Test video imports API validator', function () { 28describe('Test video imports API validator', function () {
29 const path = '/api/v1/videos/imports' 29 const path = '/api/v1/videos/imports'
@@ -76,7 +76,7 @@ describe('Test video imports API validator', function () {
76 76
77 before(function () { 77 before(function () {
78 baseCorrectParams = { 78 baseCorrectParams = {
79 targetUrl: getYoutubeVideoUrl(), 79 targetUrl: getGoodVideoUrl(),
80 name: 'my super name', 80 name: 'my super name',
81 category: 5, 81 category: 5,
82 licence: 1, 82 licence: 1,
@@ -246,15 +246,13 @@ describe('Test video imports API validator', function () {
246 it('Should succeed with the correct parameters', async function () { 246 it('Should succeed with the correct parameters', async function () {
247 this.timeout(30000) 247 this.timeout(30000)
248 248
249 { 249 await makePostBodyRequest({
250 await makePostBodyRequest({ 250 url: server.url,
251 url: server.url, 251 path,
252 path, 252 token: server.accessToken,
253 token: server.accessToken, 253 fields: baseCorrectParams,
254 fields: baseCorrectParams, 254 statusCodeExpected: 200
255 statusCodeExpected: 200 255 })
256 })
257 }
258 }) 256 })
259 257
260 it('Should forbid to import http videos', async function () { 258 it('Should forbid to import http videos', async function () {
diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts
index e5f6aa864..af4ff42b0 100644
--- a/server/tests/api/notifications/user-notifications.ts
+++ b/server/tests/api/notifications/user-notifications.ts
@@ -24,7 +24,7 @@ import {
24 prepareNotificationsTest 24 prepareNotificationsTest
25} from '../../../../shared/extra-utils/users/user-notifications' 25} from '../../../../shared/extra-utils/users/user-notifications'
26import { addUserSubscription, removeUserSubscription } from '../../../../shared/extra-utils/users/user-subscriptions' 26import { addUserSubscription, removeUserSubscription } from '../../../../shared/extra-utils/users/user-subscriptions'
27import { getBadVideoUrl, getYoutubeVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports' 27import { getBadVideoUrl, getGoodVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports'
28import { UserNotification, UserNotificationType } from '../../../../shared/models/users' 28import { UserNotification, UserNotificationType } from '../../../../shared/models/users'
29import { VideoPrivacy } from '../../../../shared/models/videos' 29import { VideoPrivacy } from '../../../../shared/models/videos'
30 30
@@ -213,7 +213,7 @@ describe('Test user notifications', function () {
213 name, 213 name,
214 channelId, 214 channelId,
215 privacy: VideoPrivacy.PUBLIC, 215 privacy: VideoPrivacy.PUBLIC,
216 targetUrl: getYoutubeVideoUrl() 216 targetUrl: getGoodVideoUrl()
217 } 217 }
218 const res = await importVideo(servers[0].url, servers[0].accessToken, attributes) 218 const res = await importVideo(servers[0].url, servers[0].accessToken, attributes)
219 const uuid = res.body.video.uuid 219 const uuid = res.body.video.uuid
@@ -284,7 +284,7 @@ describe('Test user notifications', function () {
284 name, 284 name,
285 channelId, 285 channelId,
286 privacy: VideoPrivacy.PUBLIC, 286 privacy: VideoPrivacy.PUBLIC,
287 targetUrl: getYoutubeVideoUrl(), 287 targetUrl: getGoodVideoUrl(),
288 waitTranscoding: true 288 waitTranscoding: true
289 } 289 }
290 const res = await importVideo(servers[1].url, servers[1].accessToken, attributes) 290 const res = await importVideo(servers[1].url, servers[1].accessToken, attributes)
@@ -371,13 +371,13 @@ describe('Test user notifications', function () {
371 name, 371 name,
372 channelId, 372 channelId,
373 privacy: VideoPrivacy.PRIVATE, 373 privacy: VideoPrivacy.PRIVATE,
374 targetUrl: getYoutubeVideoUrl() 374 targetUrl: getGoodVideoUrl()
375 } 375 }
376 const res = await importVideo(servers[0].url, servers[0].accessToken, attributes) 376 const res = await importVideo(servers[0].url, servers[0].accessToken, attributes)
377 const uuid = res.body.video.uuid 377 const uuid = res.body.video.uuid
378 378
379 await waitJobs(servers) 379 await waitJobs(servers)
380 await checkMyVideoImportIsFinished(baseParams, name, uuid, getYoutubeVideoUrl(), true, 'presence') 380 await checkMyVideoImportIsFinished(baseParams, name, uuid, getGoodVideoUrl(), true, 'presence')
381 }) 381 })
382 }) 382 })
383 383
diff --git a/server/tests/api/videos/video-blacklist.ts b/server/tests/api/videos/video-blacklist.ts
index a8500627b..52cac20d9 100644
--- a/server/tests/api/videos/video-blacklist.ts
+++ b/server/tests/api/videos/video-blacklist.ts
@@ -1,8 +1,8 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha'
3import * as chai from 'chai' 4import * as chai from 'chai'
4import { orderBy } from 'lodash' 5import { orderBy } from 'lodash'
5import 'mocha'
6import { 6import {
7 addVideoToBlacklist, 7 addVideoToBlacklist,
8 cleanupTests, 8 cleanupTests,
@@ -25,10 +25,10 @@ import {
25} from '../../../../shared/extra-utils/index' 25} from '../../../../shared/extra-utils/index'
26import { doubleFollow } from '../../../../shared/extra-utils/server/follows' 26import { doubleFollow } from '../../../../shared/extra-utils/server/follows'
27import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 27import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
28import { VideoBlacklist, VideoBlacklistType } from '../../../../shared/models/videos' 28import { getGoodVideoUrl, getMagnetURI, importVideo } from '../../../../shared/extra-utils/videos/video-imports'
29import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model'
30import { User, UserRole } from '../../../../shared/models/users' 29import { User, UserRole } from '../../../../shared/models/users'
31import { getMagnetURI, getYoutubeVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports' 30import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model'
31import { VideoBlacklist, VideoBlacklistType } from '../../../../shared/models/videos'
32 32
33const expect = chai.expect 33const expect = chai.expect
34 34
@@ -424,7 +424,7 @@ describe('Test video blacklist', function () {
424 this.timeout(15000) 424 this.timeout(15000)
425 425
426 const attributes = { 426 const attributes = {
427 targetUrl: getYoutubeVideoUrl(), 427 targetUrl: getGoodVideoUrl(),
428 name: 'URL import', 428 name: 'URL import',
429 channelId: channelOfUserWithoutFlag 429 channelId: channelOfUserWithoutFlag
430 } 430 }
diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts
index 05ee36b27..efda4fc7b 100644
--- a/server/tests/api/videos/video-imports.ts
+++ b/server/tests/api/videos/video-imports.ts
@@ -1,8 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import * as chai from 'chai'
4import 'mocha' 3import 'mocha'
5import { VideoDetails, VideoImport, VideoPrivacy, VideoCaption } from '../../../../shared/models/videos' 4import * as chai from 'chai'
6import { 5import {
7 cleanupTests, 6 cleanupTests,
8 doubleFollow, 7 doubleFollow,
@@ -11,15 +10,16 @@ import {
11 getMyVideos, 10 getMyVideos,
12 getVideo, 11 getVideo,
13 getVideosList, 12 getVideosList,
14 listVideoCaptions,
15 testCaptionFile,
16 immutableAssign, 13 immutableAssign,
14 listVideoCaptions,
17 ServerInfo, 15 ServerInfo,
18 setAccessTokensToServers 16 setAccessTokensToServers,
17 testCaptionFile
19} from '../../../../shared/extra-utils' 18} from '../../../../shared/extra-utils'
19import { areHttpImportTestsDisabled, testImage } from '../../../../shared/extra-utils/miscs/miscs'
20import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 20import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
21import { getMagnetURI, getMyVideoImports, getYoutubeVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports' 21import { getMagnetURI, getMyVideoImports, getYoutubeVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports'
22import { testImage } from '../../../../shared/extra-utils/miscs/miscs' 22import { VideoCaption, VideoDetails, VideoImport, VideoPrivacy } from '../../../../shared/models/videos'
23 23
24const expect = chai.expect 24const expect = chai.expect
25 25
@@ -28,6 +28,8 @@ describe('Test video imports', function () {
28 let channelIdServer1: number 28 let channelIdServer1: number
29 let channelIdServer2: number 29 let channelIdServer2: number
30 30
31 if (areHttpImportTestsDisabled()) return
32
31 async function checkVideosServer1 (url: string, idHttp: string, idMagnet: string, idTorrent: string) { 33 async function checkVideosServer1 (url: string, idHttp: string, idMagnet: string, idTorrent: string) {
32 const resHttp = await getVideo(url, idHttp) 34 const resHttp = await getVideo(url, idHttp)
33 const videoHttp: VideoDetails = resHttp.body 35 const videoHttp: VideoDetails = resHttp.body
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts
index 41242318e..4d354b68e 100644
--- a/server/tests/plugins/filter-hooks.ts
+++ b/server/tests/plugins/filter-hooks.ts
@@ -24,7 +24,7 @@ import {
24 waitJobs 24 waitJobs
25} from '../../../shared/extra-utils' 25} from '../../../shared/extra-utils'
26import { cleanupTests, flushAndRunMultipleServers, ServerInfo } from '../../../shared/extra-utils/server/servers' 26import { cleanupTests, flushAndRunMultipleServers, ServerInfo } from '../../../shared/extra-utils/server/servers'
27import { getMyVideoImports, getYoutubeVideoUrl, importVideo } from '../../../shared/extra-utils/videos/video-imports' 27import { getGoodVideoUrl, getMyVideoImports, importVideo } from '../../../shared/extra-utils/videos/video-imports'
28import { VideoDetails, VideoImport, VideoImportState, VideoPrivacy } from '../../../shared/models/videos' 28import { VideoDetails, VideoImport, VideoImportState, VideoPrivacy } from '../../../shared/models/videos'
29import { VideoCommentThreadTree } from '../../../shared/models/videos/video-comment.model' 29import { VideoCommentThreadTree } from '../../../shared/models/videos/video-comment.model'
30 30
@@ -92,7 +92,7 @@ describe('Test plugin filter hooks', function () {
92 name: 'normal title', 92 name: 'normal title',
93 privacy: VideoPrivacy.PUBLIC, 93 privacy: VideoPrivacy.PUBLIC,
94 channelId: servers[0].videoChannel.id, 94 channelId: servers[0].videoChannel.id,
95 targetUrl: getYoutubeVideoUrl() + 'bad' 95 targetUrl: getGoodVideoUrl() + 'bad'
96 } 96 }
97 await importVideo(servers[0].url, servers[0].accessToken, baseAttributes, 403) 97 await importVideo(servers[0].url, servers[0].accessToken, baseAttributes, 403)
98 }) 98 })
@@ -117,7 +117,7 @@ describe('Test plugin filter hooks', function () {
117 name: 'title with bad word', 117 name: 'title with bad word',
118 privacy: VideoPrivacy.PUBLIC, 118 privacy: VideoPrivacy.PUBLIC,
119 channelId: servers[0].videoChannel.id, 119 channelId: servers[0].videoChannel.id,
120 targetUrl: getYoutubeVideoUrl() 120 targetUrl: getGoodVideoUrl()
121 } 121 }
122 const res = await importVideo(servers[0].url, servers[0].accessToken, baseAttributes) 122 const res = await importVideo(servers[0].url, servers[0].accessToken, baseAttributes)
123 videoImportId = res.body.id 123 videoImportId = res.body.id
@@ -220,7 +220,7 @@ describe('Test plugin filter hooks', function () {
220 220
221 const attributes = { 221 const attributes = {
222 name: 'video please blacklist me', 222 name: 'video please blacklist me',
223 targetUrl: getYoutubeVideoUrl(), 223 targetUrl: getGoodVideoUrl(),
224 channelId: servers[0].videoChannel.id 224 channelId: servers[0].videoChannel.id
225 } 225 }
226 const res = await importVideo(servers[0].url, servers[0].accessToken, attributes) 226 const res = await importVideo(servers[0].url, servers[0].accessToken, attributes)