aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/video-imports.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-07 11:56:18 +0200
committerChocobozzz <me@florianbigard.com>2018-08-08 09:30:31 +0200
commit187501f8b8e334f043ae1e9af3c9d4f45ea0e6c1 (patch)
treeea895cb9dd743e400b64ab1b3b1bbee4d2521a2b /server/tests/api/check-params/video-imports.ts
parenta84b8fa5cf6e4cafb841af3db9bdfcc9531c09a4 (diff)
downloadPeerTube-187501f8b8e334f043ae1e9af3c9d4f45ea0e6c1.tar.gz
PeerTube-187501f8b8e334f043ae1e9af3c9d4f45ea0e6c1.tar.zst
PeerTube-187501f8b8e334f043ae1e9af3c9d4f45ea0e6c1.zip
Add check param tests regarding video imports
Diffstat (limited to 'server/tests/api/check-params/video-imports.ts')
-rw-r--r--server/tests/api/check-params/video-imports.ts50
1 files changed, 48 insertions, 2 deletions
diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts
index 0ead34a47..e62f0918e 100644
--- a/server/tests/api/check-params/video-imports.ts
+++ b/server/tests/api/check-params/video-imports.ts
@@ -20,7 +20,7 @@ import {
20 userLogin 20 userLogin
21} from '../../utils' 21} from '../../utils'
22import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' 22import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params'
23import { getYoutubeVideoUrl } from '../../utils/videos/video-imports' 23import { getMagnetURI, getYoutubeVideoUrl } from '../../utils/videos/video-imports'
24 24
25describe('Test video imports API validator', function () { 25describe('Test video imports API validator', function () {
26 const path = '/api/v1/videos/imports' 26 const path = '/api/v1/videos/imports'
@@ -229,6 +229,22 @@ describe('Test video imports API validator', function () {
229 await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) 229 await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
230 }) 230 })
231 231
232 it('Should fail with an invalid torrent file', async function () {
233 const fields = omit(baseCorrectParams, 'targetUrl')
234 const attaches = {
235 'torrentfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png')
236 }
237
238 await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches })
239 })
240
241 it('Should fail with an invalid magnet URI', async function () {
242 let fields = omit(baseCorrectParams, 'targetUrl')
243 fields = immutableAssign(fields, { magnetUri: 'blabla' })
244
245 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
246 })
247
232 it('Should succeed with the correct parameters', async function () { 248 it('Should succeed with the correct parameters', async function () {
233 this.timeout(10000) 249 this.timeout(10000)
234 250
@@ -243,12 +259,15 @@ describe('Test video imports API validator', function () {
243 } 259 }
244 }) 260 })
245 261
246 it('Should forbid to import videos', async function () { 262 it('Should forbid to import http videos', async function () {
247 await updateCustomSubConfig(server.url, server.accessToken, { 263 await updateCustomSubConfig(server.url, server.accessToken, {
248 import: { 264 import: {
249 videos: { 265 videos: {
250 http: { 266 http: {
251 enabled: false 267 enabled: false
268 },
269 torrent: {
270 enabled: true
252 } 271 }
253 } 272 }
254 } 273 }
@@ -262,6 +281,33 @@ describe('Test video imports API validator', function () {
262 statusCodeExpected: 409 281 statusCodeExpected: 409
263 }) 282 })
264 }) 283 })
284
285 it('Should forbid to import torrent videos', async function () {
286 await updateCustomSubConfig(server.url, server.accessToken, {
287 import: {
288 videos: {
289 http: {
290 enabled: true
291 },
292 torrent: {
293 enabled: false
294 }
295 }
296 }
297 })
298
299 let fields = omit(baseCorrectParams, 'targetUrl')
300 fields = immutableAssign(fields, { magnetUri: getMagnetURI() })
301
302 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields, statusCodeExpected: 409 })
303
304 fields = omit(fields, 'magnetUri')
305 const attaches = {
306 'torrentfile': join(__dirname, '..', '..', 'fixtures', '60fps_small-240p.torrent')
307 }
308
309 await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches, statusCodeExpected: 409 })
310 })
265 }) 311 })
266 312
267 after(async function () { 313 after(async function () {