From 187501f8b8e334f043ae1e9af3c9d4f45ea0e6c1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 7 Aug 2018 11:56:18 +0200 Subject: Add check param tests regarding video imports --- server/tests/api/check-params/video-imports.ts | 50 ++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) (limited to 'server/tests/api/check-params/video-imports.ts') 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 { userLogin } from '../../utils' import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' -import { getYoutubeVideoUrl } from '../../utils/videos/video-imports' +import { getMagnetURI, getYoutubeVideoUrl } from '../../utils/videos/video-imports' describe('Test video imports API validator', function () { const path = '/api/v1/videos/imports' @@ -229,6 +229,22 @@ describe('Test video imports API validator', function () { await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) }) + it('Should fail with an invalid torrent file', async function () { + const fields = omit(baseCorrectParams, 'targetUrl') + const attaches = { + 'torrentfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png') + } + + await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) + }) + + it('Should fail with an invalid magnet URI', async function () { + let fields = omit(baseCorrectParams, 'targetUrl') + fields = immutableAssign(fields, { magnetUri: 'blabla' }) + + await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) + }) + it('Should succeed with the correct parameters', async function () { this.timeout(10000) @@ -243,12 +259,15 @@ describe('Test video imports API validator', function () { } }) - it('Should forbid to import videos', async function () { + it('Should forbid to import http videos', async function () { await updateCustomSubConfig(server.url, server.accessToken, { import: { videos: { http: { enabled: false + }, + torrent: { + enabled: true } } } @@ -262,6 +281,33 @@ describe('Test video imports API validator', function () { statusCodeExpected: 409 }) }) + + it('Should forbid to import torrent videos', async function () { + await updateCustomSubConfig(server.url, server.accessToken, { + import: { + videos: { + http: { + enabled: true + }, + torrent: { + enabled: false + } + } + } + }) + + let fields = omit(baseCorrectParams, 'targetUrl') + fields = immutableAssign(fields, { magnetUri: getMagnetURI() }) + + await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields, statusCodeExpected: 409 }) + + fields = omit(fields, 'magnetUri') + const attaches = { + 'torrentfile': join(__dirname, '..', '..', 'fixtures', '60fps_small-240p.torrent') + } + + await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches, statusCodeExpected: 409 }) + }) }) after(async function () { -- cgit v1.2.3