aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/video-imports.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/check-params/video-imports.ts')
-rw-r--r--server/tests/api/check-params/video-imports.ts66
1 files changed, 65 insertions, 1 deletions
diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts
index da05793a0..156a612ee 100644
--- a/server/tests/api/check-params/video-imports.ts
+++ b/server/tests/api/check-params/video-imports.ts
@@ -12,7 +12,9 @@ import {
12 makePostBodyRequest, 12 makePostBodyRequest,
13 makeUploadRequest, 13 makeUploadRequest,
14 PeerTubeServer, 14 PeerTubeServer,
15 setAccessTokensToServers 15 setAccessTokensToServers,
16 setDefaultVideoChannel,
17 waitJobs
16} from '@shared/server-commands' 18} from '@shared/server-commands'
17 19
18describe('Test video imports API validator', function () { 20describe('Test video imports API validator', function () {
@@ -29,6 +31,7 @@ describe('Test video imports API validator', function () {
29 server = await createSingleServer(1) 31 server = await createSingleServer(1)
30 32
31 await setAccessTokensToServers([ server ]) 33 await setAccessTokensToServers([ server ])
34 await setDefaultVideoChannel([ server ])
32 35
33 const username = 'user1' 36 const username = 'user1'
34 const password = 'my super password' 37 const password = 'my super password'
@@ -347,6 +350,67 @@ describe('Test video imports API validator', function () {
347 }) 350 })
348 }) 351 })
349 352
353 describe('Deleting/cancelling a video import', function () {
354 let importId: number
355
356 async function importVideo () {
357 const attributes = { channelId: server.store.channel.id, targetUrl: FIXTURE_URLS.goodVideo }
358 const res = await server.imports.importVideo({ attributes })
359
360 return res.id
361 }
362
363 before(async function () {
364 importId = await importVideo()
365 })
366
367 it('Should fail with an invalid import id', async function () {
368 await server.imports.cancel({ importId: 'artyom' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
369 await server.imports.delete({ importId: 'artyom' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
370 })
371
372 it('Should fail with an unknown import id', async function () {
373 await server.imports.cancel({ importId: 42, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
374 await server.imports.delete({ importId: 42, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
375 })
376
377 it('Should fail without token', async function () {
378 await server.imports.cancel({ importId, token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
379 await server.imports.delete({ importId, token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
380 })
381
382 it('Should fail with another user token', async function () {
383 await server.imports.cancel({ importId, token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
384 await server.imports.delete({ importId, token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
385 })
386
387 it('Should fail to cancel non pending import', async function () {
388 this.timeout(60000)
389
390 await waitJobs([ server ])
391
392 await server.imports.cancel({ importId, expectedStatus: HttpStatusCode.CONFLICT_409 })
393 })
394
395 it('Should succeed to delete an import', async function () {
396 await server.imports.delete({ importId })
397 })
398
399 it('Should fail to delete a pending import', async function () {
400 await server.jobs.pauseJobQueue()
401
402 importId = await importVideo()
403
404 await server.imports.delete({ importId, expectedStatus: HttpStatusCode.CONFLICT_409 })
405 })
406
407 it('Should succeed to cancel an import', async function () {
408 importId = await importVideo()
409
410 await server.imports.cancel({ importId })
411 })
412 })
413
350 after(async function () { 414 after(async function () {
351 await cleanupTests([ server ]) 415 await cleanupTests([ server ])
352 }) 416 })