runServer,
ServerInfo,
setAccessTokensToServers,
+ updateCustomSubConfig,
userLogin
} from '../../utils'
import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params'
+import { getYoutubeVideoUrl } from '../../utils/videos/video-imports'
describe('Test video imports API validator', function () {
const path = '/api/v1/videos/imports'
before(function () {
baseCorrectParams = {
- targetUrl: 'https://youtu.be/msX3jv1XdvM',
+ targetUrl: getYoutubeVideoUrl(),
name: 'my super name',
category: 5,
licence: 1,
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
})
+ it('Should fail without a target url', async function () {
+ const fields = omit(baseCorrectParams, 'targetUrl')
+ await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields, statusCodeExpected: 400 })
+ })
+
+ it('Should fail with a bad target url', async function () {
+ const fields = immutableAssign(baseCorrectParams, { targetUrl: 'htt://hello' })
+
+ await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
+ })
+
it('Should fail with a long name', async function () {
const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) })
it('Should succeed with the correct parameters', async function () {
this.timeout(10000)
- const fields = baseCorrectParams
-
{
await makePostBodyRequest({
url: server.url,
path,
token: server.accessToken,
- fields,
+ fields: baseCorrectParams,
statusCodeExpected: 200
})
}
})
- it('Should forbid importing')
+ it('Should forbid to import videos', async function () {
+ await updateCustomSubConfig(server.url, server.accessToken, {
+ import: {
+ videos: {
+ http: {
+ enabled: false
+ }
+ }
+ }
+ })
+
+ await makePostBodyRequest({
+ url: server.url,
+ path,
+ token: server.accessToken,
+ fields: baseCorrectParams,
+ statusCodeExpected: 409
+ })
+ })
})
after(async function () {