aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/videos.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/check-params/videos.ts')
-rw-r--r--server/tests/api/check-params/videos.ts150
1 files changed, 127 insertions, 23 deletions
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts
index f25e3f595..aa30b721b 100644
--- a/server/tests/api/check-params/videos.ts
+++ b/server/tests/api/check-params/videos.ts
@@ -7,7 +7,7 @@ import { join } from 'path'
7import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' 7import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum'
8import { 8import {
9 createUser, flushTests, getMyUserInformation, getVideo, getVideosList, immutableAssign, killallServers, makeDeleteRequest, 9 createUser, flushTests, getMyUserInformation, getVideo, getVideosList, immutableAssign, killallServers, makeDeleteRequest,
10 makeGetRequest, makePostUploadRequest, makePutBodyRequest, removeVideo, runServer, ServerInfo, setAccessTokensToServers, userLogin 10 makeGetRequest, makeUploadRequest, makePutBodyRequest, removeVideo, runServer, ServerInfo, setAccessTokensToServers, userLogin
11} from '../../utils' 11} from '../../utils'
12import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' 12import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params'
13 13
@@ -111,91 +111,91 @@ describe('Test videos API validator', function () {
111 it('Should fail with nothing', async function () { 111 it('Should fail with nothing', async function () {
112 const fields = {} 112 const fields = {}
113 const attaches = {} 113 const attaches = {}
114 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 114 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
115 }) 115 })
116 116
117 it('Should fail without name', async function () { 117 it('Should fail without name', async function () {
118 const fields = omit(baseCorrectParams, 'name') 118 const fields = omit(baseCorrectParams, 'name')
119 const attaches = baseCorrectAttaches 119 const attaches = baseCorrectAttaches
120 120
121 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 121 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
122 }) 122 })
123 123
124 it('Should fail with a long name', async function () { 124 it('Should fail with a long name', async function () {
125 const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) }) 125 const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) })
126 const attaches = baseCorrectAttaches 126 const attaches = baseCorrectAttaches
127 127
128 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 128 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
129 }) 129 })
130 130
131 it('Should fail with a bad category', async function () { 131 it('Should fail with a bad category', async function () {
132 const fields = immutableAssign(baseCorrectParams, { category: 125 }) 132 const fields = immutableAssign(baseCorrectParams, { category: 125 })
133 const attaches = baseCorrectAttaches 133 const attaches = baseCorrectAttaches
134 134
135 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 135 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
136 }) 136 })
137 137
138 it('Should fail with a bad licence', async function () { 138 it('Should fail with a bad licence', async function () {
139 const fields = immutableAssign(baseCorrectParams, { licence: 125 }) 139 const fields = immutableAssign(baseCorrectParams, { licence: 125 })
140 const attaches = baseCorrectAttaches 140 const attaches = baseCorrectAttaches
141 141
142 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 142 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
143 }) 143 })
144 144
145 it('Should fail with a bad language', async function () { 145 it('Should fail with a bad language', async function () {
146 const fields = immutableAssign(baseCorrectParams, { language: 125 }) 146 const fields = immutableAssign(baseCorrectParams, { language: 125 })
147 const attaches = baseCorrectAttaches 147 const attaches = baseCorrectAttaches
148 148
149 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 149 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
150 }) 150 })
151 151
152 it('Should fail without nsfw attribute', async function () { 152 it('Should fail without nsfw attribute', async function () {
153 const fields = omit(baseCorrectParams, 'nsfw') 153 const fields = omit(baseCorrectParams, 'nsfw')
154 const attaches = baseCorrectAttaches 154 const attaches = baseCorrectAttaches
155 155
156 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 156 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
157 }) 157 })
158 158
159 it('Should fail with a bad nsfw attribute', async function () { 159 it('Should fail with a bad nsfw attribute', async function () {
160 const fields = immutableAssign(baseCorrectParams, { nsfw: 2 }) 160 const fields = immutableAssign(baseCorrectParams, { nsfw: 2 })
161 const attaches = baseCorrectAttaches 161 const attaches = baseCorrectAttaches
162 162
163 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 163 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
164 }) 164 })
165 165
166 it('Should fail without commentsEnabled attribute', async function () { 166 it('Should fail without commentsEnabled attribute', async function () {
167 const fields = omit(baseCorrectParams, 'commentsEnabled') 167 const fields = omit(baseCorrectParams, 'commentsEnabled')
168 const attaches = baseCorrectAttaches 168 const attaches = baseCorrectAttaches
169 169
170 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 170 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
171 }) 171 })
172 172
173 it('Should fail with a bad commentsEnabled attribute', async function () { 173 it('Should fail with a bad commentsEnabled attribute', async function () {
174 const fields = immutableAssign(baseCorrectParams, { commentsEnabled: 2 }) 174 const fields = immutableAssign(baseCorrectParams, { commentsEnabled: 2 })
175 const attaches = baseCorrectAttaches 175 const attaches = baseCorrectAttaches
176 176
177 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 177 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
178 }) 178 })
179 179
180 it('Should fail with a long description', async function () { 180 it('Should fail with a long description', async function () {
181 const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(1500) }) 181 const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(1500) })
182 const attaches = baseCorrectAttaches 182 const attaches = baseCorrectAttaches
183 183
184 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 184 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
185 }) 185 })
186 186
187 it('Should fail without a channel', async function () { 187 it('Should fail without a channel', async function () {
188 const fields = omit(baseCorrectParams, 'channelId') 188 const fields = omit(baseCorrectParams, 'channelId')
189 const attaches = baseCorrectAttaches 189 const attaches = baseCorrectAttaches
190 190
191 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 191 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
192 }) 192 })
193 193
194 it('Should fail with a bad channel', async function () { 194 it('Should fail with a bad channel', async function () {
195 const fields = immutableAssign(baseCorrectParams, { channelId: 545454 }) 195 const fields = immutableAssign(baseCorrectParams, { channelId: 545454 })
196 const attaches = baseCorrectAttaches 196 const attaches = baseCorrectAttaches
197 197
198 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 198 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
199 }) 199 })
200 200
201 it('Should fail with another user channel', async function () { 201 it('Should fail with another user channel', async function () {
@@ -212,34 +212,34 @@ describe('Test videos API validator', function () {
212 const fields = immutableAssign(baseCorrectParams, { channelId: customChannelId }) 212 const fields = immutableAssign(baseCorrectParams, { channelId: customChannelId })
213 const attaches = baseCorrectAttaches 213 const attaches = baseCorrectAttaches
214 214
215 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 215 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
216 }) 216 })
217 217
218 it('Should fail with too many tags', async function () { 218 it('Should fail with too many tags', async function () {
219 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }) 219 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] })
220 const attaches = baseCorrectAttaches 220 const attaches = baseCorrectAttaches
221 221
222 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 222 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
223 }) 223 })
224 224
225 it('Should fail with a tag length too low', async function () { 225 it('Should fail with a tag length too low', async function () {
226 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] }) 226 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] })
227 const attaches = baseCorrectAttaches 227 const attaches = baseCorrectAttaches
228 228
229 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 229 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
230 }) 230 })
231 231
232 it('Should fail with a tag length too big', async function () { 232 it('Should fail with a tag length too big', async function () {
233 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }) 233 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] })
234 const attaches = baseCorrectAttaches 234 const attaches = baseCorrectAttaches
235 235
236 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 236 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
237 }) 237 })
238 238
239 it('Should fail without an input file', async function () { 239 it('Should fail without an input file', async function () {
240 const fields = baseCorrectParams 240 const fields = baseCorrectParams
241 const attaches = {} 241 const attaches = {}
242 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 242 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
243 }) 243 })
244 244
245 it('Should fail without an incorrect input file', async function () { 245 it('Should fail without an incorrect input file', async function () {
@@ -247,7 +247,47 @@ describe('Test videos API validator', function () {
247 const attaches = { 247 const attaches = {
248 'videofile': join(__dirname, '..', 'fixtures', 'video_short_fake.webm') 248 'videofile': join(__dirname, '..', 'fixtures', 'video_short_fake.webm')
249 } 249 }
250 await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 250 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
251 })
252
253 it('Should fail with an incorrect thumbnail file', async function () {
254 const fields = baseCorrectParams
255 const attaches = {
256 'thumbnailfile': join(__dirname, '..', 'fixtures', 'avatar.png'),
257 'videofile': join(__dirname, '..', 'fixtures', 'video_short_fake.webm')
258 }
259
260 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
261 })
262
263 it('Should fail with a big thumbnail file', async function () {
264 const fields = baseCorrectParams
265 const attaches = {
266 'thumbnailfile': join(__dirname, '..', 'fixtures', 'avatar-big.png'),
267 'videofile': join(__dirname, '..', 'fixtures', 'video_short_fake.webm')
268 }
269
270 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
271 })
272
273 it('Should fail with an incorrect preview file', async function () {
274 const fields = baseCorrectParams
275 const attaches = {
276 'previewfile': join(__dirname, '..', 'fixtures', 'avatar.png'),
277 'videofile': join(__dirname, '..', 'fixtures', 'video_short_fake.webm')
278 }
279
280 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
281 })
282
283 it('Should fail with a big preview file', async function () {
284 const fields = baseCorrectParams
285 const attaches = {
286 'previewfile': join(__dirname, '..', 'fixtures', 'avatar-big.png'),
287 'videofile': join(__dirname, '..', 'fixtures', 'video_short_fake.webm')
288 }
289
290 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
251 }) 291 })
252 292
253 it('Should succeed with the correct parameters', async function () { 293 it('Should succeed with the correct parameters', async function () {
@@ -257,7 +297,7 @@ describe('Test videos API validator', function () {
257 297
258 { 298 {
259 const attaches = baseCorrectAttaches 299 const attaches = baseCorrectAttaches
260 await makePostUploadRequest({ 300 await makeUploadRequest({
261 url: server.url, 301 url: server.url,
262 path: path + '/upload', 302 path: path + '/upload',
263 token: server.accessToken, 303 token: server.accessToken,
@@ -272,7 +312,7 @@ describe('Test videos API validator', function () {
272 videofile: join(__dirname, '..', 'fixtures', 'video_short.mp4') 312 videofile: join(__dirname, '..', 'fixtures', 'video_short.mp4')
273 }) 313 })
274 314
275 await makePostUploadRequest({ 315 await makeUploadRequest({
276 url: server.url, 316 url: server.url,
277 path: path + '/upload', 317 path: path + '/upload',
278 token: server.accessToken, 318 token: server.accessToken,
@@ -287,7 +327,7 @@ describe('Test videos API validator', function () {
287 videofile: join(__dirname, '..', 'fixtures', 'video_short.ogv') 327 videofile: join(__dirname, '..', 'fixtures', 'video_short.ogv')
288 }) 328 })
289 329
290 await makePostUploadRequest({ 330 await makeUploadRequest({
291 url: server.url, 331 url: server.url,
292 path: path + '/upload', 332 path: path + '/upload',
293 token: server.accessToken, 333 token: server.accessToken,
@@ -400,6 +440,70 @@ describe('Test videos API validator', function () {
400 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 440 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
401 }) 441 })
402 442
443 it('Should fail with an incorrect thumbnail file', async function () {
444 const fields = baseCorrectParams
445 const attaches = {
446 'thumbnailfile': join(__dirname, '..', 'fixtures', 'avatar.png')
447 }
448
449 await makeUploadRequest({
450 url: server.url,
451 method: 'PUT',
452 path: path + videoId,
453 token: server.accessToken,
454 fields,
455 attaches
456 })
457 })
458
459 it('Should fail with a big thumbnail file', async function () {
460 const fields = baseCorrectParams
461 const attaches = {
462 'thumbnailfile': join(__dirname, '..', 'fixtures', 'avatar-big.png')
463 }
464
465 await makeUploadRequest({
466 url: server.url,
467 method: 'PUT',
468 path: path + videoId,
469 token: server.accessToken,
470 fields,
471 attaches
472 })
473 })
474
475 it('Should fail with an incorrect preview file', async function () {
476 const fields = baseCorrectParams
477 const attaches = {
478 'previewfile': join(__dirname, '..', 'fixtures', 'avatar.png')
479 }
480
481 await makeUploadRequest({
482 url: server.url,
483 method: 'PUT',
484 path: path + videoId,
485 token: server.accessToken,
486 fields,
487 attaches
488 })
489 })
490
491 it('Should fail with a big preview file', async function () {
492 const fields = baseCorrectParams
493 const attaches = {
494 'previewfile': join(__dirname, '..', 'fixtures', 'avatar-big.png')
495 }
496
497 await makeUploadRequest({
498 url: server.url,
499 method: 'PUT',
500 path: path + videoId,
501 token: server.accessToken,
502 fields,
503 attaches
504 })
505 })
506
403 it('Should fail with a video of another user') 507 it('Should fail with a video of another user')
404 508
405 it('Should fail with a video of another server') 509 it('Should fail with a video of another server')