setAccessTokensToServers,
updateCustomSubConfig,
userLogin
-} from '../../utils'
-import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params'
-import { getYoutubeVideoUrl } from '../../utils/videos/video-imports'
+} from '../../../../shared/utils'
+import {
+ checkBadCountPagination,
+ checkBadSortPagination,
+ checkBadStartPagination
+} from '../../../../shared/utils/requests/check-api-params'
+import { getMagnetURI, getYoutubeVideoUrl } from '../../../../shared/utils/videos/video-imports'
describe('Test video imports API validator', function () {
const path = '/api/v1/videos/imports'
let userAccessToken = ''
let accountName: string
let channelId: number
- let channelUUID: string
// ---------------------------------------------------------------
{
const res = await getMyUserInformation(server.url, server.accessToken)
channelId = res.body.videoChannels[ 0 ].id
- channelUUID = res.body.videoChannels[ 0 ].uuid
accountName = res.body.account.name + '@' + res.body.account.host
}
})
})
it('Should fail with a long support text', async function () {
- const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(150) })
+ const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) })
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
})
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)
+ this.timeout(30000)
{
await makePostBodyRequest({
}
})
- 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
}
}
}
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', 'video-720p.torrent')
+ }
+
+ await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches, statusCodeExpected: 409 })
+ })
})
after(async function () {