aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/check-params')
-rw-r--r--server/tests/api/check-params/video-imports.ts39
1 files changed, 34 insertions, 5 deletions
diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts
index 7f58efb74..0ead34a47 100644
--- a/server/tests/api/check-params/video-imports.ts
+++ b/server/tests/api/check-params/video-imports.ts
@@ -16,9 +16,11 @@ import {
16 runServer, 16 runServer,
17 ServerInfo, 17 ServerInfo,
18 setAccessTokensToServers, 18 setAccessTokensToServers,
19 updateCustomSubConfig,
19 userLogin 20 userLogin
20} from '../../utils' 21} from '../../utils'
21import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' 22import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params'
23import { getYoutubeVideoUrl } from '../../utils/videos/video-imports'
22 24
23describe('Test video imports API validator', function () { 25describe('Test video imports API validator', function () {
24 const path = '/api/v1/videos/imports' 26 const path = '/api/v1/videos/imports'
@@ -77,7 +79,7 @@ describe('Test video imports API validator', function () {
77 79
78 before(function () { 80 before(function () {
79 baseCorrectParams = { 81 baseCorrectParams = {
80 targetUrl: 'https://youtu.be/msX3jv1XdvM', 82 targetUrl: getYoutubeVideoUrl(),
81 name: 'my super name', 83 name: 'my super name',
82 category: 5, 84 category: 5,
83 licence: 1, 85 licence: 1,
@@ -98,6 +100,17 @@ describe('Test video imports API validator', function () {
98 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 100 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
99 }) 101 })
100 102
103 it('Should fail without a target url', async function () {
104 const fields = omit(baseCorrectParams, 'targetUrl')
105 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields, statusCodeExpected: 400 })
106 })
107
108 it('Should fail with a bad target url', async function () {
109 const fields = immutableAssign(baseCorrectParams, { targetUrl: 'htt://hello' })
110
111 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
112 })
113
101 it('Should fail with a long name', async function () { 114 it('Should fail with a long name', async function () {
102 const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) }) 115 const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) })
103 116
@@ -219,20 +232,36 @@ describe('Test video imports API validator', function () {
219 it('Should succeed with the correct parameters', async function () { 232 it('Should succeed with the correct parameters', async function () {
220 this.timeout(10000) 233 this.timeout(10000)
221 234
222 const fields = baseCorrectParams
223
224 { 235 {
225 await makePostBodyRequest({ 236 await makePostBodyRequest({
226 url: server.url, 237 url: server.url,
227 path, 238 path,
228 token: server.accessToken, 239 token: server.accessToken,
229 fields, 240 fields: baseCorrectParams,
230 statusCodeExpected: 200 241 statusCodeExpected: 200
231 }) 242 })
232 } 243 }
233 }) 244 })
234 245
235 it('Should forbid importing') 246 it('Should forbid to import videos', async function () {
247 await updateCustomSubConfig(server.url, server.accessToken, {
248 import: {
249 videos: {
250 http: {
251 enabled: false
252 }
253 }
254 }
255 })
256
257 await makePostBodyRequest({
258 url: server.url,
259 path,
260 token: server.accessToken,
261 fields: baseCorrectParams,
262 statusCodeExpected: 409
263 })
264 })
236 }) 265 })
237 266
238 after(async function () { 267 after(async function () {