diff options
author | Chocobozzz <me@florianbigard.com> | 2021-05-27 16:12:41 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-05-27 16:12:41 +0200 |
commit | 8f608a4cb22ab232cfab20665050764b38bac9c7 (patch) | |
tree | 6a6785aae79bf5939ad7b7a50a1bd8031268d2b4 /server/tests/api/check-params/videos.ts | |
parent | 030ccfce59a8cb8f2fee6ea8dd363ba635c5c5c2 (diff) | |
parent | c215e627b575d2c4085ccb222f4ca8d0237b7552 (diff) | |
download | PeerTube-8f608a4cb22ab232cfab20665050764b38bac9c7.tar.gz PeerTube-8f608a4cb22ab232cfab20665050764b38bac9c7.tar.zst PeerTube-8f608a4cb22ab232cfab20665050764b38bac9c7.zip |
Merge branch 'develop' into shorter-URLs-channels-accounts
Diffstat (limited to 'server/tests/api/check-params/videos.ts')
-rw-r--r-- | server/tests/api/check-params/videos.ts | 393 |
1 files changed, 191 insertions, 202 deletions
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts index 188d1835c..c970c4a15 100644 --- a/server/tests/api/check-params/videos.ts +++ b/server/tests/api/check-params/videos.ts | |||
@@ -1,11 +1,12 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | ||
3 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
4 | import { omit } from 'lodash' | 5 | import { omit } from 'lodash' |
5 | import 'mocha' | ||
6 | import { join } from 'path' | 6 | import { join } from 'path' |
7 | import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' | 7 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' |
8 | import { | 8 | import { |
9 | checkUploadVideoParam, | ||
9 | cleanupTests, | 10 | cleanupTests, |
10 | createUser, | 11 | createUser, |
11 | flushAndRunServer, | 12 | flushAndRunServer, |
@@ -18,17 +19,18 @@ import { | |||
18 | makePutBodyRequest, | 19 | makePutBodyRequest, |
19 | makeUploadRequest, | 20 | makeUploadRequest, |
20 | removeVideo, | 21 | removeVideo, |
22 | root, | ||
21 | ServerInfo, | 23 | ServerInfo, |
22 | setAccessTokensToServers, | 24 | setAccessTokensToServers, |
23 | userLogin, | 25 | userLogin |
24 | root | ||
25 | } from '../../../../shared/extra-utils' | 26 | } from '../../../../shared/extra-utils' |
26 | import { | 27 | import { |
27 | checkBadCountPagination, | 28 | checkBadCountPagination, |
28 | checkBadSortPagination, | 29 | checkBadSortPagination, |
29 | checkBadStartPagination | 30 | checkBadStartPagination |
30 | } from '../../../../shared/extra-utils/requests/check-api-params' | 31 | } from '../../../../shared/extra-utils/requests/check-api-params' |
31 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 32 | import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' |
33 | import { randomInt } from '@shared/core-utils' | ||
32 | 34 | ||
33 | const expect = chai.expect | 35 | const expect = chai.expect |
34 | 36 | ||
@@ -183,7 +185,7 @@ describe('Test videos API validator', function () { | |||
183 | describe('When adding a video', function () { | 185 | describe('When adding a video', function () { |
184 | let baseCorrectParams | 186 | let baseCorrectParams |
185 | const baseCorrectAttaches = { | 187 | const baseCorrectAttaches = { |
186 | videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.webm') | 188 | fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.webm') |
187 | } | 189 | } |
188 | 190 | ||
189 | before(function () { | 191 | before(function () { |
@@ -206,256 +208,243 @@ describe('Test videos API validator', function () { | |||
206 | } | 208 | } |
207 | }) | 209 | }) |
208 | 210 | ||
209 | it('Should fail with nothing', async function () { | 211 | function runSuite (mode: 'legacy' | 'resumable') { |
210 | const fields = {} | ||
211 | const attaches = {} | ||
212 | await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | ||
213 | }) | ||
214 | 212 | ||
215 | it('Should fail without name', async function () { | 213 | it('Should fail with nothing', async function () { |
216 | const fields = omit(baseCorrectParams, 'name') | 214 | const fields = {} |
217 | const attaches = baseCorrectAttaches | 215 | const attaches = {} |
216 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | ||
217 | }) | ||
218 | 218 | ||
219 | await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 219 | it('Should fail without name', async function () { |
220 | }) | 220 | const fields = omit(baseCorrectParams, 'name') |
221 | const attaches = baseCorrectAttaches | ||
221 | 222 | ||
222 | it('Should fail with a long name', async function () { | 223 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
223 | const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) }) | 224 | }) |
224 | const attaches = baseCorrectAttaches | ||
225 | 225 | ||
226 | await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 226 | it('Should fail with a long name', async function () { |
227 | }) | 227 | const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) }) |
228 | const attaches = baseCorrectAttaches | ||
228 | 229 | ||
229 | it('Should fail with a bad category', async function () { | 230 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
230 | const fields = immutableAssign(baseCorrectParams, { category: 125 }) | 231 | }) |
231 | const attaches = baseCorrectAttaches | ||
232 | 232 | ||
233 | await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 233 | it('Should fail with a bad category', async function () { |
234 | }) | 234 | const fields = immutableAssign(baseCorrectParams, { category: 125 }) |
235 | const attaches = baseCorrectAttaches | ||
235 | 236 | ||
236 | it('Should fail with a bad licence', async function () { | 237 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
237 | const fields = immutableAssign(baseCorrectParams, { licence: 125 }) | 238 | }) |
238 | const attaches = baseCorrectAttaches | ||
239 | 239 | ||
240 | await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 240 | it('Should fail with a bad licence', async function () { |
241 | }) | 241 | const fields = immutableAssign(baseCorrectParams, { licence: 125 }) |
242 | const attaches = baseCorrectAttaches | ||
242 | 243 | ||
243 | it('Should fail with a bad language', async function () { | 244 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
244 | const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) }) | 245 | }) |
245 | const attaches = baseCorrectAttaches | ||
246 | 246 | ||
247 | await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 247 | it('Should fail with a bad language', async function () { |
248 | }) | 248 | const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) }) |
249 | const attaches = baseCorrectAttaches | ||
249 | 250 | ||
250 | it('Should fail with a long description', async function () { | 251 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
251 | const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) }) | 252 | }) |
252 | const attaches = baseCorrectAttaches | ||
253 | 253 | ||
254 | await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 254 | it('Should fail with a long description', async function () { |
255 | }) | 255 | const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) }) |
256 | const attaches = baseCorrectAttaches | ||
256 | 257 | ||
257 | it('Should fail with a long support text', async function () { | 258 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
258 | const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) }) | 259 | }) |
259 | const attaches = baseCorrectAttaches | ||
260 | 260 | ||
261 | await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 261 | it('Should fail with a long support text', async function () { |
262 | }) | 262 | const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) }) |
263 | const attaches = baseCorrectAttaches | ||
263 | 264 | ||
264 | it('Should fail without a channel', async function () { | 265 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
265 | const fields = omit(baseCorrectParams, 'channelId') | 266 | }) |
266 | const attaches = baseCorrectAttaches | ||
267 | 267 | ||
268 | await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 268 | it('Should fail without a channel', async function () { |
269 | }) | 269 | const fields = omit(baseCorrectParams, 'channelId') |
270 | const attaches = baseCorrectAttaches | ||
270 | 271 | ||
271 | it('Should fail with a bad channel', async function () { | 272 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
272 | const fields = immutableAssign(baseCorrectParams, { channelId: 545454 }) | 273 | }) |
273 | const attaches = baseCorrectAttaches | ||
274 | 274 | ||
275 | await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 275 | it('Should fail with a bad channel', async function () { |
276 | }) | 276 | const fields = immutableAssign(baseCorrectParams, { channelId: 545454 }) |
277 | const attaches = baseCorrectAttaches | ||
277 | 278 | ||
278 | it('Should fail with another user channel', async function () { | 279 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
279 | const user = { | 280 | }) |
280 | username: 'fake', | ||
281 | password: 'fake_password' | ||
282 | } | ||
283 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) | ||
284 | 281 | ||
285 | const accessTokenUser = await userLogin(server, user) | 282 | it('Should fail with another user channel', async function () { |
286 | const res = await getMyUserInformation(server.url, accessTokenUser) | 283 | const user = { |
287 | const customChannelId = res.body.videoChannels[0].id | 284 | username: 'fake' + randomInt(0, 1500), |
285 | password: 'fake_password' | ||
286 | } | ||
287 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) | ||
288 | 288 | ||
289 | const fields = immutableAssign(baseCorrectParams, { channelId: customChannelId }) | 289 | const accessTokenUser = await userLogin(server, user) |
290 | const attaches = baseCorrectAttaches | 290 | const res = await getMyUserInformation(server.url, accessTokenUser) |
291 | const customChannelId = res.body.videoChannels[0].id | ||
291 | 292 | ||
292 | await makeUploadRequest({ url: server.url, path: path + '/upload', token: userAccessToken, fields, attaches }) | 293 | const fields = immutableAssign(baseCorrectParams, { channelId: customChannelId }) |
293 | }) | 294 | const attaches = baseCorrectAttaches |
294 | 295 | ||
295 | it('Should fail with too many tags', async function () { | 296 | await checkUploadVideoParam(server.url, userAccessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
296 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }) | 297 | }) |
297 | const attaches = baseCorrectAttaches | ||
298 | 298 | ||
299 | await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 299 | it('Should fail with too many tags', async function () { |
300 | }) | 300 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }) |
301 | const attaches = baseCorrectAttaches | ||
301 | 302 | ||
302 | it('Should fail with a tag length too low', async function () { | 303 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
303 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] }) | 304 | }) |
304 | const attaches = baseCorrectAttaches | ||
305 | 305 | ||
306 | await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 306 | it('Should fail with a tag length too low', async function () { |
307 | }) | 307 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] }) |
308 | const attaches = baseCorrectAttaches | ||
308 | 309 | ||
309 | it('Should fail with a tag length too big', async function () { | 310 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
310 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }) | 311 | }) |
311 | const attaches = baseCorrectAttaches | ||
312 | 312 | ||
313 | await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 313 | it('Should fail with a tag length too big', async function () { |
314 | }) | 314 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }) |
315 | const attaches = baseCorrectAttaches | ||
315 | 316 | ||
316 | it('Should fail with a bad schedule update (miss updateAt)', async function () { | 317 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
317 | const fields = immutableAssign(baseCorrectParams, { 'scheduleUpdate[privacy]': VideoPrivacy.PUBLIC }) | 318 | }) |
318 | const attaches = baseCorrectAttaches | ||
319 | 319 | ||
320 | await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 320 | it('Should fail with a bad schedule update (miss updateAt)', async function () { |
321 | }) | 321 | const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } }) |
322 | const attaches = baseCorrectAttaches | ||
322 | 323 | ||
323 | it('Should fail with a bad schedule update (wrong updateAt)', async function () { | 324 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
324 | const fields = immutableAssign(baseCorrectParams, { | ||
325 | 'scheduleUpdate[privacy]': VideoPrivacy.PUBLIC, | ||
326 | 'scheduleUpdate[updateAt]': 'toto' | ||
327 | }) | 325 | }) |
328 | const attaches = baseCorrectAttaches | ||
329 | 326 | ||
330 | await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 327 | it('Should fail with a bad schedule update (wrong updateAt)', async function () { |
331 | }) | 328 | const fields = immutableAssign(baseCorrectParams, { |
329 | scheduleUpdate: { | ||
330 | privacy: VideoPrivacy.PUBLIC, | ||
331 | updateAt: 'toto' | ||
332 | } | ||
333 | }) | ||
334 | const attaches = baseCorrectAttaches | ||
332 | 335 | ||
333 | it('Should fail with a bad originally published at attribute', async function () { | 336 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
334 | const fields = immutableAssign(baseCorrectParams, { originallyPublishedAt: 'toto' }) | 337 | }) |
335 | const attaches = baseCorrectAttaches | ||
336 | 338 | ||
337 | await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 339 | it('Should fail with a bad originally published at attribute', async function () { |
338 | }) | 340 | const fields = immutableAssign(baseCorrectParams, { originallyPublishedAt: 'toto' }) |
341 | const attaches = baseCorrectAttaches | ||
339 | 342 | ||
340 | it('Should fail without an input file', async function () { | 343 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
341 | const fields = baseCorrectParams | 344 | }) |
342 | const attaches = {} | ||
343 | await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | ||
344 | }) | ||
345 | 345 | ||
346 | it('Should fail with an incorrect input file', async function () { | 346 | it('Should fail without an input file', async function () { |
347 | const fields = baseCorrectParams | 347 | const fields = baseCorrectParams |
348 | let attaches = { | 348 | const attaches = {} |
349 | videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short_fake.webm') | 349 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
350 | } | ||
351 | await makeUploadRequest({ | ||
352 | url: server.url, | ||
353 | path: path + '/upload', | ||
354 | token: server.accessToken, | ||
355 | fields, | ||
356 | attaches, | ||
357 | statusCodeExpected: HttpStatusCode.UNPROCESSABLE_ENTITY_422 | ||
358 | }) | 350 | }) |
359 | 351 | ||
360 | attaches = { | 352 | it('Should fail with an incorrect input file', async function () { |
361 | videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mkv') | 353 | const fields = baseCorrectParams |
362 | } | 354 | let attaches = { fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short_fake.webm') } |
363 | await makeUploadRequest({ | 355 | |
364 | url: server.url, | 356 | await checkUploadVideoParam( |
365 | path: path + '/upload', | 357 | server.url, |
366 | token: server.accessToken, | 358 | server.accessToken, |
367 | fields, | 359 | { ...fields, ...attaches }, |
368 | attaches, | 360 | HttpStatusCode.UNPROCESSABLE_ENTITY_422, |
369 | statusCodeExpected: HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415 | 361 | mode |
362 | ) | ||
363 | |||
364 | attaches = { fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mkv') } | ||
365 | await checkUploadVideoParam( | ||
366 | server.url, | ||
367 | server.accessToken, | ||
368 | { ...fields, ...attaches }, | ||
369 | HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415, | ||
370 | mode | ||
371 | ) | ||
370 | }) | 372 | }) |
371 | }) | ||
372 | 373 | ||
373 | it('Should fail with an incorrect thumbnail file', async function () { | 374 | it('Should fail with an incorrect thumbnail file', async function () { |
374 | const fields = baseCorrectParams | 375 | const fields = baseCorrectParams |
375 | const attaches = { | 376 | const attaches = { |
376 | thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4'), | 377 | thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4'), |
377 | videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') | 378 | fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') |
378 | } | 379 | } |
379 | 380 | ||
380 | await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 381 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
381 | }) | 382 | }) |
382 | 383 | ||
383 | it('Should fail with a big thumbnail file', async function () { | 384 | it('Should fail with a big thumbnail file', async function () { |
384 | const fields = baseCorrectParams | 385 | const fields = baseCorrectParams |
385 | const attaches = { | 386 | const attaches = { |
386 | thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png'), | 387 | thumbnailfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png'), |
387 | videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') | 388 | fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') |
388 | } | 389 | } |
389 | 390 | ||
390 | await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 391 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
391 | }) | 392 | }) |
392 | 393 | ||
393 | it('Should fail with an incorrect preview file', async function () { | 394 | it('Should fail with an incorrect preview file', async function () { |
394 | const fields = baseCorrectParams | 395 | const fields = baseCorrectParams |
395 | const attaches = { | 396 | const attaches = { |
396 | previewfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4'), | 397 | previewfile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4'), |
397 | videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') | 398 | fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') |
398 | } | 399 | } |
399 | 400 | ||
400 | await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 401 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
401 | }) | 402 | }) |
402 | 403 | ||
403 | it('Should fail with a big preview file', async function () { | 404 | it('Should fail with a big preview file', async function () { |
404 | const fields = baseCorrectParams | 405 | const fields = baseCorrectParams |
405 | const attaches = { | 406 | const attaches = { |
406 | previewfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png'), | 407 | previewfile: join(root(), 'server', 'tests', 'fixtures', 'preview-big.png'), |
407 | videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') | 408 | fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') |
408 | } | 409 | } |
409 | 410 | ||
410 | await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 411 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
411 | }) | 412 | }) |
412 | 413 | ||
413 | it('Should succeed with the correct parameters', async function () { | 414 | it('Should succeed with the correct parameters', async function () { |
414 | this.timeout(10000) | 415 | this.timeout(10000) |
415 | 416 | ||
416 | const fields = baseCorrectParams | 417 | const fields = baseCorrectParams |
417 | 418 | ||
418 | { | 419 | { |
419 | const attaches = baseCorrectAttaches | 420 | const attaches = baseCorrectAttaches |
420 | await makeUploadRequest({ | 421 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode) |
421 | url: server.url, | 422 | } |
422 | path: path + '/upload', | ||
423 | token: server.accessToken, | ||
424 | fields, | ||
425 | attaches, | ||
426 | statusCodeExpected: HttpStatusCode.OK_200 | ||
427 | }) | ||
428 | } | ||
429 | 423 | ||
430 | { | 424 | { |
431 | const attaches = immutableAssign(baseCorrectAttaches, { | 425 | const attaches = immutableAssign(baseCorrectAttaches, { |
432 | videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') | 426 | videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') |
433 | }) | 427 | }) |
434 | 428 | ||
435 | await makeUploadRequest({ | 429 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode) |
436 | url: server.url, | 430 | } |
437 | path: path + '/upload', | ||
438 | token: server.accessToken, | ||
439 | fields, | ||
440 | attaches, | ||
441 | statusCodeExpected: HttpStatusCode.OK_200 | ||
442 | }) | ||
443 | } | ||
444 | 431 | ||
445 | { | 432 | { |
446 | const attaches = immutableAssign(baseCorrectAttaches, { | 433 | const attaches = immutableAssign(baseCorrectAttaches, { |
447 | videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.ogv') | 434 | videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.ogv') |
448 | }) | 435 | }) |
449 | 436 | ||
450 | await makeUploadRequest({ | 437 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode) |
451 | url: server.url, | 438 | } |
452 | path: path + '/upload', | 439 | }) |
453 | token: server.accessToken, | 440 | } |
454 | fields, | 441 | |
455 | attaches, | 442 | describe('Resumable upload', function () { |
456 | statusCodeExpected: HttpStatusCode.OK_200 | 443 | runSuite('resumable') |
457 | }) | 444 | }) |
458 | } | 445 | |
446 | describe('Legacy upload', function () { | ||
447 | runSuite('legacy') | ||
459 | }) | 448 | }) |
460 | }) | 449 | }) |
461 | 450 | ||
@@ -678,7 +667,7 @@ describe('Test videos API validator', function () { | |||
678 | }) | 667 | }) |
679 | 668 | ||
680 | expect(res.body.data).to.be.an('array') | 669 | expect(res.body.data).to.be.an('array') |
681 | expect(res.body.data.length).to.equal(3) | 670 | expect(res.body.data.length).to.equal(6) |
682 | }) | 671 | }) |
683 | 672 | ||
684 | it('Should fail without a correct uuid', async function () { | 673 | it('Should fail without a correct uuid', async function () { |