diff options
Diffstat (limited to 'server/tests/api/check-params/video-imports.ts')
-rw-r--r-- | server/tests/api/check-params/video-imports.ts | 50 |
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' |
22 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' | 22 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' |
23 | import { getYoutubeVideoUrl } from '../../utils/videos/video-imports' | 23 | import { getMagnetURI, getYoutubeVideoUrl } from '../../utils/videos/video-imports' |
24 | 24 | ||
25 | describe('Test video imports API validator', function () { | 25 | describe('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 () { |