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/abuses.ts2
-rw-r--r--server/tests/api/check-params/live.ts40
-rw-r--r--server/tests/api/check-params/redundancy.ts38
-rw-r--r--server/tests/api/check-params/users.ts12
-rw-r--r--server/tests/api/check-params/video-blacklist.ts12
-rw-r--r--server/tests/api/check-params/video-captions.ts38
-rw-r--r--server/tests/api/check-params/video-comments.ts31
-rw-r--r--server/tests/api/check-params/video-playlists.ts64
-rw-r--r--server/tests/api/check-params/videos.ts52
9 files changed, 158 insertions, 131 deletions
diff --git a/server/tests/api/check-params/abuses.ts b/server/tests/api/check-params/abuses.ts
index 2aa09334c..2054776cc 100644
--- a/server/tests/api/check-params/abuses.ts
+++ b/server/tests/api/check-params/abuses.ts
@@ -258,7 +258,7 @@ describe('Test abuses API validators', function () {
258 }) 258 })
259 259
260 it('Should succeed with the correct parameters (basic)', async function () { 260 it('Should succeed with the correct parameters (basic)', async function () {
261 const fields: AbuseCreate = { video: { id: server.video.id }, reason: 'my super reason' } 261 const fields: AbuseCreate = { video: { id: server.video.shortUUID }, reason: 'my super reason' }
262 262
263 const res = await makePostBodyRequest({ 263 const res = await makePostBodyRequest({
264 url: server.url, 264 url: server.url,
diff --git a/server/tests/api/check-params/live.ts b/server/tests/api/check-params/live.ts
index 32233c9da..933d8abf2 100644
--- a/server/tests/api/check-params/live.ts
+++ b/server/tests/api/check-params/live.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { omit } from 'lodash' 4import { omit } from 'lodash'
5import { LiveVideo, VideoPrivacy } from '@shared/models' 5import { LiveVideo, VideoCreateResult, VideoPrivacy } from '@shared/models'
6import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 6import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
7import { 7import {
8 buildAbsoluteFixturePath, 8 buildAbsoluteFixturePath,
@@ -31,7 +31,7 @@ describe('Test video lives API validator', function () {
31 let server: ServerInfo 31 let server: ServerInfo
32 let userAccessToken = '' 32 let userAccessToken = ''
33 let channelId: number 33 let channelId: number
34 let videoId: number 34 let video: VideoCreateResult
35 let videoIdNotLive: number 35 let videoIdNotLive: number
36 36
37 // --------------------------------------------------------------- 37 // ---------------------------------------------------------------
@@ -230,7 +230,7 @@ describe('Test video lives API validator', function () {
230 statusCodeExpected: HttpStatusCode.OK_200 230 statusCodeExpected: HttpStatusCode.OK_200
231 }) 231 })
232 232
233 videoId = res.body.video.id 233 video = res.body.video
234 }) 234 })
235 235
236 it('Should forbid if live is disabled', async function () { 236 it('Should forbid if live is disabled', async function () {
@@ -326,15 +326,15 @@ describe('Test video lives API validator', function () {
326 describe('When getting live information', function () { 326 describe('When getting live information', function () {
327 327
328 it('Should fail without access token', async function () { 328 it('Should fail without access token', async function () {
329 await getLive(server.url, '', videoId, HttpStatusCode.UNAUTHORIZED_401) 329 await getLive(server.url, '', video.id, HttpStatusCode.UNAUTHORIZED_401)
330 }) 330 })
331 331
332 it('Should fail with a bad access token', async function () { 332 it('Should fail with a bad access token', async function () {
333 await getLive(server.url, 'toto', videoId, HttpStatusCode.UNAUTHORIZED_401) 333 await getLive(server.url, 'toto', video.id, HttpStatusCode.UNAUTHORIZED_401)
334 }) 334 })
335 335
336 it('Should fail with access token of another user', async function () { 336 it('Should fail with access token of another user', async function () {
337 await getLive(server.url, userAccessToken, videoId, HttpStatusCode.FORBIDDEN_403) 337 await getLive(server.url, userAccessToken, video.id, HttpStatusCode.FORBIDDEN_403)
338 }) 338 })
339 339
340 it('Should fail with a bad video id', async function () { 340 it('Should fail with a bad video id', async function () {
@@ -350,22 +350,23 @@ describe('Test video lives API validator', function () {
350 }) 350 })
351 351
352 it('Should succeed with the correct params', async function () { 352 it('Should succeed with the correct params', async function () {
353 await getLive(server.url, server.accessToken, videoId) 353 await getLive(server.url, server.accessToken, video.id)
354 await getLive(server.url, server.accessToken, video.shortUUID)
354 }) 355 })
355 }) 356 })
356 357
357 describe('When updating live information', async function () { 358 describe('When updating live information', async function () {
358 359
359 it('Should fail without access token', async function () { 360 it('Should fail without access token', async function () {
360 await updateLive(server.url, '', videoId, {}, HttpStatusCode.UNAUTHORIZED_401) 361 await updateLive(server.url, '', video.id, {}, HttpStatusCode.UNAUTHORIZED_401)
361 }) 362 })
362 363
363 it('Should fail with a bad access token', async function () { 364 it('Should fail with a bad access token', async function () {
364 await updateLive(server.url, 'toto', videoId, {}, HttpStatusCode.UNAUTHORIZED_401) 365 await updateLive(server.url, 'toto', video.id, {}, HttpStatusCode.UNAUTHORIZED_401)
365 }) 366 })
366 367
367 it('Should fail with access token of another user', async function () { 368 it('Should fail with access token of another user', async function () {
368 await updateLive(server.url, userAccessToken, videoId, {}, HttpStatusCode.FORBIDDEN_403) 369 await updateLive(server.url, userAccessToken, video.id, {}, HttpStatusCode.FORBIDDEN_403)
369 }) 370 })
370 371
371 it('Should fail with a bad video id', async function () { 372 it('Should fail with a bad video id', async function () {
@@ -383,11 +384,12 @@ describe('Test video lives API validator', function () {
383 it('Should fail with save replay and permanent live set to true', async function () { 384 it('Should fail with save replay and permanent live set to true', async function () {
384 const fields = { saveReplay: true, permanentLive: true } 385 const fields = { saveReplay: true, permanentLive: true }
385 386
386 await updateLive(server.url, server.accessToken, videoId, fields, HttpStatusCode.BAD_REQUEST_400) 387 await updateLive(server.url, server.accessToken, video.id, fields, HttpStatusCode.BAD_REQUEST_400)
387 }) 388 })
388 389
389 it('Should succeed with the correct params', async function () { 390 it('Should succeed with the correct params', async function () {
390 await updateLive(server.url, server.accessToken, videoId, { saveReplay: false }) 391 await updateLive(server.url, server.accessToken, video.id, { saveReplay: false })
392 await updateLive(server.url, server.accessToken, video.shortUUID, { saveReplay: false })
391 }) 393 })
392 394
393 it('Should fail to update replay status if replay is not allowed on the instance', async function () { 395 it('Should fail to update replay status if replay is not allowed on the instance', async function () {
@@ -398,19 +400,19 @@ describe('Test video lives API validator', function () {
398 } 400 }
399 }) 401 })
400 402
401 await updateLive(server.url, server.accessToken, videoId, { saveReplay: true }, HttpStatusCode.FORBIDDEN_403) 403 await updateLive(server.url, server.accessToken, video.id, { saveReplay: true }, HttpStatusCode.FORBIDDEN_403)
402 }) 404 })
403 405
404 it('Should fail to update a live if it has already started', async function () { 406 it('Should fail to update a live if it has already started', async function () {
405 this.timeout(40000) 407 this.timeout(40000)
406 408
407 const resLive = await getLive(server.url, server.accessToken, videoId) 409 const resLive = await getLive(server.url, server.accessToken, video.id)
408 const live: LiveVideo = resLive.body 410 const live: LiveVideo = resLive.body
409 411
410 const command = sendRTMPStream(live.rtmpUrl, live.streamKey) 412 const command = sendRTMPStream(live.rtmpUrl, live.streamKey)
411 413
412 await waitUntilLivePublished(server.url, server.accessToken, videoId) 414 await waitUntilLivePublished(server.url, server.accessToken, video.id)
413 await updateLive(server.url, server.accessToken, videoId, {}, HttpStatusCode.BAD_REQUEST_400) 415 await updateLive(server.url, server.accessToken, video.id, {}, HttpStatusCode.BAD_REQUEST_400)
414 416
415 await stopFfmpeg(command) 417 await stopFfmpeg(command)
416 }) 418 })
@@ -418,14 +420,14 @@ describe('Test video lives API validator', function () {
418 it('Should fail to stream twice in the save live', async function () { 420 it('Should fail to stream twice in the save live', async function () {
419 this.timeout(40000) 421 this.timeout(40000)
420 422
421 const resLive = await getLive(server.url, server.accessToken, videoId) 423 const resLive = await getLive(server.url, server.accessToken, video.id)
422 const live: LiveVideo = resLive.body 424 const live: LiveVideo = resLive.body
423 425
424 const command = sendRTMPStream(live.rtmpUrl, live.streamKey) 426 const command = sendRTMPStream(live.rtmpUrl, live.streamKey)
425 427
426 await waitUntilLivePublished(server.url, server.accessToken, videoId) 428 await waitUntilLivePublished(server.url, server.accessToken, video.id)
427 429
428 await runAndTestFfmpegStreamError(server.url, server.accessToken, videoId, true) 430 await runAndTestFfmpegStreamError(server.url, server.accessToken, video.id, true)
429 431
430 await stopFfmpeg(command) 432 await stopFfmpeg(command)
431 }) 433 })
diff --git a/server/tests/api/check-params/redundancy.ts b/server/tests/api/check-params/redundancy.ts
index 71be50a6f..dac6938de 100644
--- a/server/tests/api/check-params/redundancy.ts
+++ b/server/tests/api/check-params/redundancy.ts
@@ -1,7 +1,8 @@
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
3import 'mocha' 3import 'mocha'
4 4import { VideoCreateResult } from '@shared/models'
5import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
5import { 6import {
6 checkBadCountPagination, 7 checkBadCountPagination,
7 checkBadSortPagination, 8 checkBadSortPagination,
@@ -9,20 +10,24 @@ import {
9 cleanupTests, 10 cleanupTests,
10 createUser, 11 createUser,
11 doubleFollow, 12 doubleFollow,
12 flushAndRunMultipleServers, makeDeleteRequest, 13 flushAndRunMultipleServers,
13 makeGetRequest, makePostBodyRequest, 14 getVideo,
15 makeDeleteRequest,
16 makeGetRequest,
17 makePostBodyRequest,
14 makePutBodyRequest, 18 makePutBodyRequest,
15 ServerInfo, 19 ServerInfo,
16 setAccessTokensToServers, uploadVideoAndGetId, 20 setAccessTokensToServers,
17 userLogin, waitJobs, getVideoIdFromUUID 21 uploadVideoAndGetId,
22 userLogin,
23 waitJobs
18} from '../../../../shared/extra-utils' 24} from '../../../../shared/extra-utils'
19import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
20 25
21describe('Test server redundancy API validators', function () { 26describe('Test server redundancy API validators', function () {
22 let servers: ServerInfo[] 27 let servers: ServerInfo[]
23 let userAccessToken = null 28 let userAccessToken = null
24 let videoIdLocal: number 29 let videoIdLocal: number
25 let videoIdRemote: number 30 let videoRemote: VideoCreateResult
26 31
27 // --------------------------------------------------------------- 32 // ---------------------------------------------------------------
28 33
@@ -48,7 +53,8 @@ describe('Test server redundancy API validators', function () {
48 53
49 await waitJobs(servers) 54 await waitJobs(servers)
50 55
51 videoIdRemote = await getVideoIdFromUUID(servers[0].url, remoteUUID) 56 const resVideo = await getVideo(servers[0].url, remoteUUID)
57 videoRemote = resVideo.body
52 }) 58 })
53 59
54 describe('When listing redundancies', function () { 60 describe('When listing redundancies', function () {
@@ -131,7 +137,13 @@ describe('Test server redundancy API validators', function () {
131 }) 137 })
132 138
133 it('Should succeed with the correct params', async function () { 139 it('Should succeed with the correct params', async function () {
134 await makePostBodyRequest({ url, path, token, fields: { videoId: videoIdRemote }, statusCodeExpected: HttpStatusCode.NO_CONTENT_204 }) 140 await makePostBodyRequest({
141 url,
142 path,
143 token,
144 fields: { videoId: videoRemote.shortUUID },
145 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
146 })
135 }) 147 })
136 148
137 it('Should fail if the video is already duplicated', async function () { 149 it('Should fail if the video is already duplicated', async function () {
@@ -139,7 +151,13 @@ describe('Test server redundancy API validators', function () {
139 151
140 await waitJobs(servers) 152 await waitJobs(servers)
141 153
142 await makePostBodyRequest({ url, path, token, fields: { videoId: videoIdRemote }, statusCodeExpected: HttpStatusCode.CONFLICT_409 }) 154 await makePostBodyRequest({
155 url,
156 path,
157 token,
158 fields: { videoId: videoRemote.uuid },
159 statusCodeExpected: HttpStatusCode.CONFLICT_409
160 })
143 }) 161 })
144 }) 162 })
145 163
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts
index 36482ee17..70a872ce5 100644
--- a/server/tests/api/check-params/users.ts
+++ b/server/tests/api/check-params/users.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { omit } from 'lodash' 4import { omit } from 'lodash'
5import { User, UserRole } from '../../../../shared' 5import { User, UserRole, VideoCreateResult } from '../../../../shared'
6import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 6import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
7import { 7import {
8 addVideoChannel, 8 addVideoChannel,
@@ -45,7 +45,7 @@ describe('Test users API validators', function () {
45 let userId: number 45 let userId: number
46 let rootId: number 46 let rootId: number
47 let moderatorId: number 47 let moderatorId: number
48 let videoId: number 48 let video: VideoCreateResult
49 let server: ServerInfo 49 let server: ServerInfo
50 let serverWithRegistrationDisabled: ServerInfo 50 let serverWithRegistrationDisabled: ServerInfo
51 let userAccessToken = '' 51 let userAccessToken = ''
@@ -126,7 +126,7 @@ describe('Test users API validators', function () {
126 126
127 { 127 {
128 const res = await uploadVideo(server.url, server.accessToken, {}) 128 const res = await uploadVideo(server.url, server.accessToken, {})
129 videoId = res.body.video.id 129 video = res.body.video
130 } 130 }
131 131
132 { 132 {
@@ -829,7 +829,7 @@ describe('Test users API validators', function () {
829 829
830 describe('When getting my video rating', function () { 830 describe('When getting my video rating', function () {
831 it('Should fail with a non authenticated user', async function () { 831 it('Should fail with a non authenticated user', async function () {
832 await getMyUserVideoRating(server.url, 'fake_token', videoId, HttpStatusCode.UNAUTHORIZED_401) 832 await getMyUserVideoRating(server.url, 'fake_token', video.id, HttpStatusCode.UNAUTHORIZED_401)
833 }) 833 })
834 834
835 it('Should fail with an incorrect video uuid', async function () { 835 it('Should fail with an incorrect video uuid', async function () {
@@ -841,7 +841,9 @@ describe('Test users API validators', function () {
841 }) 841 })
842 842
843 it('Should succeed with the correct parameters', async function () { 843 it('Should succeed with the correct parameters', async function () {
844 await getMyUserVideoRating(server.url, server.accessToken, videoId) 844 await getMyUserVideoRating(server.url, server.accessToken, video.id)
845 await getMyUserVideoRating(server.url, server.accessToken, video.uuid)
846 await getMyUserVideoRating(server.url, server.accessToken, video.shortUUID)
845 }) 847 })
846 }) 848 })
847 849
diff --git a/server/tests/api/check-params/video-blacklist.ts b/server/tests/api/check-params/video-blacklist.ts
index 3d4837d58..ce7f5fa17 100644
--- a/server/tests/api/check-params/video-blacklist.ts
+++ b/server/tests/api/check-params/video-blacklist.ts
@@ -191,7 +191,7 @@ describe('Test video blacklist API validators', function () {
191 }) 191 })
192 192
193 it('Should succeed with the correct params', async function () { 193 it('Should succeed with the correct params', async function () {
194 const path = basePath + servers[0].video.uuid + '/blacklist' 194 const path = basePath + servers[0].video.shortUUID + '/blacklist'
195 const fields = { reason: 'hello' } 195 const fields = { reason: 'hello' }
196 196
197 await makePutBodyRequest({ 197 await makePutBodyRequest({
@@ -222,10 +222,14 @@ describe('Test video blacklist API validators', function () {
222 }) 222 })
223 223
224 it('Should succeed with an admin', async function () { 224 it('Should succeed with an admin', async function () {
225 const res = await getVideoWithToken(servers[0].url, servers[0].accessToken, servers[0].video.uuid, HttpStatusCode.OK_200) 225 const video = servers[0].video
226 const video: VideoDetails = res.body
227 226
228 expect(video.blacklisted).to.be.true 227 for (const id of [ video.id, video.uuid, video.shortUUID ]) {
228 const res = await getVideoWithToken(servers[0].url, servers[0].accessToken, id, HttpStatusCode.OK_200)
229 const video: VideoDetails = res.body
230
231 expect(video.blacklisted).to.be.true
232 }
229 }) 233 })
230 }) 234 })
231 235
diff --git a/server/tests/api/check-params/video-captions.ts b/server/tests/api/check-params/video-captions.ts
index 1ce2202d2..c0595c04d 100644
--- a/server/tests/api/check-params/video-captions.ts
+++ b/server/tests/api/check-params/video-captions.ts
@@ -1,7 +1,7 @@
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
3import 'mocha' 3import 'mocha'
4 4import { VideoCreateResult } from '@shared/models'
5import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 5import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
6import { 6import {
7 buildAbsoluteFixturePath, 7 buildAbsoluteFixturePath,
@@ -23,7 +23,7 @@ describe('Test video captions API validator', function () {
23 23
24 let server: ServerInfo 24 let server: ServerInfo
25 let userAccessToken: string 25 let userAccessToken: string
26 let videoUUID: string 26 let video: VideoCreateResult
27 27
28 // --------------------------------------------------------------- 28 // ---------------------------------------------------------------
29 29
@@ -36,7 +36,7 @@ describe('Test video captions API validator', function () {
36 36
37 { 37 {
38 const res = await uploadVideo(server.url, server.accessToken, {}) 38 const res = await uploadVideo(server.url, server.accessToken, {})
39 videoUUID = res.body.video.uuid 39 video = res.body.video
40 } 40 }
41 41
42 { 42 {
@@ -79,7 +79,7 @@ describe('Test video captions API validator', function () {
79 }) 79 })
80 80
81 it('Should fail with a missing language in path', async function () { 81 it('Should fail with a missing language in path', async function () {
82 const captionPath = path + videoUUID + '/captions' 82 const captionPath = path + video.uuid + '/captions'
83 await makeUploadRequest({ 83 await makeUploadRequest({
84 method: 'PUT', 84 method: 'PUT',
85 url: server.url, 85 url: server.url,
@@ -91,7 +91,7 @@ describe('Test video captions API validator', function () {
91 }) 91 })
92 92
93 it('Should fail with an unknown language', async function () { 93 it('Should fail with an unknown language', async function () {
94 const captionPath = path + videoUUID + '/captions/15' 94 const captionPath = path + video.uuid + '/captions/15'
95 await makeUploadRequest({ 95 await makeUploadRequest({
96 method: 'PUT', 96 method: 'PUT',
97 url: server.url, 97 url: server.url,
@@ -103,7 +103,7 @@ describe('Test video captions API validator', function () {
103 }) 103 })
104 104
105 it('Should fail without access token', async function () { 105 it('Should fail without access token', async function () {
106 const captionPath = path + videoUUID + '/captions/fr' 106 const captionPath = path + video.uuid + '/captions/fr'
107 await makeUploadRequest({ 107 await makeUploadRequest({
108 method: 'PUT', 108 method: 'PUT',
109 url: server.url, 109 url: server.url,
@@ -115,7 +115,7 @@ describe('Test video captions API validator', function () {
115 }) 115 })
116 116
117 it('Should fail with a bad access token', async function () { 117 it('Should fail with a bad access token', async function () {
118 const captionPath = path + videoUUID + '/captions/fr' 118 const captionPath = path + video.uuid + '/captions/fr'
119 await makeUploadRequest({ 119 await makeUploadRequest({
120 method: 'PUT', 120 method: 'PUT',
121 url: server.url, 121 url: server.url,
@@ -133,7 +133,7 @@ describe('Test video captions API validator', function () {
133 // 'captionfile': buildAbsoluteFixturePath('subtitle-bad.txt') 133 // 'captionfile': buildAbsoluteFixturePath('subtitle-bad.txt')
134 // } 134 // }
135 // 135 //
136 // const captionPath = path + videoUUID + '/captions/fr' 136 // const captionPath = path + video.uuid + '/captions/fr'
137 // await makeUploadRequest({ 137 // await makeUploadRequest({
138 // method: 'PUT', 138 // method: 'PUT',
139 // url: server.url, 139 // url: server.url,
@@ -151,7 +151,7 @@ describe('Test video captions API validator', function () {
151 // url: server.url, 151 // url: server.url,
152 // accessToken: server.accessToken, 152 // accessToken: server.accessToken,
153 // language: 'zh', 153 // language: 'zh',
154 // videoId: videoUUID, 154 // videoId: video.uuid,
155 // fixture: 'subtitle-bad.txt', 155 // fixture: 'subtitle-bad.txt',
156 // mimeType: 'application/octet-stream', 156 // mimeType: 'application/octet-stream',
157 // statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 157 // statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
@@ -163,7 +163,7 @@ describe('Test video captions API validator', function () {
163 url: server.url, 163 url: server.url,
164 accessToken: server.accessToken, 164 accessToken: server.accessToken,
165 language: 'zh', 165 language: 'zh',
166 videoId: videoUUID, 166 videoId: video.uuid,
167 fixture: 'subtitle-good.srt', 167 fixture: 'subtitle-good.srt',
168 mimeType: 'application/octet-stream' 168 mimeType: 'application/octet-stream'
169 }) 169 })
@@ -175,7 +175,7 @@ describe('Test video captions API validator', function () {
175 // 'captionfile': buildAbsoluteFixturePath('subtitle-bad.srt') 175 // 'captionfile': buildAbsoluteFixturePath('subtitle-bad.srt')
176 // } 176 // }
177 // 177 //
178 // const captionPath = path + videoUUID + '/captions/fr' 178 // const captionPath = path + video.uuid + '/captions/fr'
179 // await makeUploadRequest({ 179 // await makeUploadRequest({
180 // method: 'PUT', 180 // method: 'PUT',
181 // url: server.url, 181 // url: server.url,
@@ -188,7 +188,7 @@ describe('Test video captions API validator', function () {
188 // }) 188 // })
189 189
190 it('Should success with the correct parameters', async function () { 190 it('Should success with the correct parameters', async function () {
191 const captionPath = path + videoUUID + '/captions/fr' 191 const captionPath = path + video.uuid + '/captions/fr'
192 await makeUploadRequest({ 192 await makeUploadRequest({
193 method: 'PUT', 193 method: 'PUT',
194 url: server.url, 194 url: server.url,
@@ -215,7 +215,7 @@ describe('Test video captions API validator', function () {
215 }) 215 })
216 216
217 it('Should success with the correct parameters', async function () { 217 it('Should success with the correct parameters', async function () {
218 await makeGetRequest({ url: server.url, path: path + videoUUID + '/captions', statusCodeExpected: HttpStatusCode.OK_200 }) 218 await makeGetRequest({ url: server.url, path: path + video.shortUUID + '/captions', statusCodeExpected: HttpStatusCode.OK_200 })
219 }) 219 })
220 }) 220 })
221 221
@@ -246,27 +246,27 @@ describe('Test video captions API validator', function () {
246 }) 246 })
247 247
248 it('Should fail with a missing language', async function () { 248 it('Should fail with a missing language', async function () {
249 const captionPath = path + videoUUID + '/captions' 249 const captionPath = path + video.shortUUID + '/captions'
250 await makeDeleteRequest({ url: server.url, path: captionPath, token: server.accessToken }) 250 await makeDeleteRequest({ url: server.url, path: captionPath, token: server.accessToken })
251 }) 251 })
252 252
253 it('Should fail with an unknown language', async function () { 253 it('Should fail with an unknown language', async function () {
254 const captionPath = path + videoUUID + '/captions/15' 254 const captionPath = path + video.shortUUID + '/captions/15'
255 await makeDeleteRequest({ url: server.url, path: captionPath, token: server.accessToken }) 255 await makeDeleteRequest({ url: server.url, path: captionPath, token: server.accessToken })
256 }) 256 })
257 257
258 it('Should fail without access token', async function () { 258 it('Should fail without access token', async function () {
259 const captionPath = path + videoUUID + '/captions/fr' 259 const captionPath = path + video.shortUUID + '/captions/fr'
260 await makeDeleteRequest({ url: server.url, path: captionPath, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 260 await makeDeleteRequest({ url: server.url, path: captionPath, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
261 }) 261 })
262 262
263 it('Should fail with a bad access token', async function () { 263 it('Should fail with a bad access token', async function () {
264 const captionPath = path + videoUUID + '/captions/fr' 264 const captionPath = path + video.shortUUID + '/captions/fr'
265 await makeDeleteRequest({ url: server.url, path: captionPath, token: 'coucou', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 265 await makeDeleteRequest({ url: server.url, path: captionPath, token: 'coucou', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
266 }) 266 })
267 267
268 it('Should fail with another user', async function () { 268 it('Should fail with another user', async function () {
269 const captionPath = path + videoUUID + '/captions/fr' 269 const captionPath = path + video.shortUUID + '/captions/fr'
270 await makeDeleteRequest({ 270 await makeDeleteRequest({
271 url: server.url, 271 url: server.url,
272 path: captionPath, 272 path: captionPath,
@@ -276,7 +276,7 @@ describe('Test video captions API validator', function () {
276 }) 276 })
277 277
278 it('Should success with the correct parameters', async function () { 278 it('Should success with the correct parameters', async function () {
279 const captionPath = path + videoUUID + '/captions/fr' 279 const captionPath = path + video.shortUUID + '/captions/fr'
280 await makeDeleteRequest({ 280 await makeDeleteRequest({
281 url: server.url, 281 url: server.url,
282 path: captionPath, 282 path: captionPath,
diff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.ts
index 659a10c41..a38420851 100644
--- a/server/tests/api/check-params/video-comments.ts
+++ b/server/tests/api/check-params/video-comments.ts
@@ -1,7 +1,9 @@
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
3import * as chai from 'chai'
4import 'mocha' 3import 'mocha'
4import * as chai from 'chai'
5import { VideoCreateResult } from '@shared/models'
6import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
5import { 7import {
6 cleanupTests, 8 cleanupTests,
7 createUser, 9 createUser,
@@ -20,7 +22,6 @@ import {
20 checkBadStartPagination 22 checkBadStartPagination
21} from '../../../../shared/extra-utils/requests/check-api-params' 23} from '../../../../shared/extra-utils/requests/check-api-params'
22import { addVideoCommentThread } from '../../../../shared/extra-utils/videos/video-comments' 24import { addVideoCommentThread } from '../../../../shared/extra-utils/videos/video-comments'
23import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
24 25
25const expect = chai.expect 26const expect = chai.expect
26 27
@@ -28,7 +29,7 @@ describe('Test video comments API validator', function () {
28 let pathThread: string 29 let pathThread: string
29 let pathComment: string 30 let pathComment: string
30 let server: ServerInfo 31 let server: ServerInfo
31 let videoUUID: string 32 let video: VideoCreateResult
32 let userAccessToken: string 33 let userAccessToken: string
33 let userAccessToken2: string 34 let userAccessToken2: string
34 let commentId: number 35 let commentId: number
@@ -44,14 +45,14 @@ describe('Test video comments API validator', function () {
44 45
45 { 46 {
46 const res = await uploadVideo(server.url, server.accessToken, {}) 47 const res = await uploadVideo(server.url, server.accessToken, {})
47 videoUUID = res.body.video.uuid 48 video = res.body.video
48 pathThread = '/api/v1/videos/' + videoUUID + '/comment-threads' 49 pathThread = '/api/v1/videos/' + video.uuid + '/comment-threads'
49 } 50 }
50 51
51 { 52 {
52 const res = await addVideoCommentThread(server.url, server.accessToken, videoUUID, 'coucou') 53 const res = await addVideoCommentThread(server.url, server.accessToken, video.uuid, 'coucou')
53 commentId = res.body.comment.id 54 commentId = res.body.comment.id
54 pathComment = '/api/v1/videos/' + videoUUID + '/comments/' + commentId 55 pathComment = '/api/v1/videos/' + video.uuid + '/comments/' + commentId
55 } 56 }
56 57
57 { 58 {
@@ -101,7 +102,7 @@ describe('Test video comments API validator', function () {
101 it('Should fail with an incorrect thread id', async function () { 102 it('Should fail with an incorrect thread id', async function () {
102 await makeGetRequest({ 103 await makeGetRequest({
103 url: server.url, 104 url: server.url,
104 path: '/api/v1/videos/' + videoUUID + '/comment-threads/156', 105 path: '/api/v1/videos/' + video.shortUUID + '/comment-threads/156',
105 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 106 statusCodeExpected: HttpStatusCode.NOT_FOUND_404
106 }) 107 })
107 }) 108 })
@@ -109,7 +110,7 @@ describe('Test video comments API validator', function () {
109 it('Should success with the correct params', async function () { 110 it('Should success with the correct params', async function () {
110 await makeGetRequest({ 111 await makeGetRequest({
111 url: server.url, 112 url: server.url,
112 path: '/api/v1/videos/' + videoUUID + '/comment-threads/' + commentId, 113 path: '/api/v1/videos/' + video.shortUUID + '/comment-threads/' + commentId,
113 statusCodeExpected: HttpStatusCode.OK_200 114 statusCodeExpected: HttpStatusCode.OK_200
114 }) 115 })
115 }) 116 })
@@ -225,7 +226,7 @@ describe('Test video comments API validator', function () {
225 }) 226 })
226 227
227 it('Should fail with an incorrect comment', async function () { 228 it('Should fail with an incorrect comment', async function () {
228 const path = '/api/v1/videos/' + videoUUID + '/comments/124' 229 const path = '/api/v1/videos/' + video.uuid + '/comments/124'
229 const fields = { 230 const fields = {
230 text: 'super comment' 231 text: 'super comment'
231 } 232 }
@@ -272,7 +273,7 @@ describe('Test video comments API validator', function () {
272 }) 273 })
273 274
274 it('Should fail with an incorrect comment', async function () { 275 it('Should fail with an incorrect comment', async function () {
275 const path = '/api/v1/videos/' + videoUUID + '/comments/124' 276 const path = '/api/v1/videos/' + video.uuid + '/comments/124'
276 await makeDeleteRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) 277 await makeDeleteRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 })
277 }) 278 })
278 279
@@ -280,11 +281,11 @@ describe('Test video comments API validator', function () {
280 let commentToDelete: number 281 let commentToDelete: number
281 282
282 { 283 {
283 const res = await addVideoCommentThread(server.url, userAccessToken, videoUUID, 'hello') 284 const res = await addVideoCommentThread(server.url, userAccessToken, video.uuid, 'hello')
284 commentToDelete = res.body.comment.id 285 commentToDelete = res.body.comment.id
285 } 286 }
286 287
287 const path = '/api/v1/videos/' + videoUUID + '/comments/' + commentToDelete 288 const path = '/api/v1/videos/' + video.uuid + '/comments/' + commentToDelete
288 289
289 await makeDeleteRequest({ url: server.url, path, token: userAccessToken2, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) 290 await makeDeleteRequest({ url: server.url, path, token: userAccessToken2, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 })
290 await makeDeleteRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.NO_CONTENT_204 }) 291 await makeDeleteRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.NO_CONTENT_204 })
@@ -323,8 +324,8 @@ describe('Test video comments API validator', function () {
323 describe('When a video has comments disabled', function () { 324 describe('When a video has comments disabled', function () {
324 before(async function () { 325 before(async function () {
325 const res = await uploadVideo(server.url, server.accessToken, { commentsEnabled: false }) 326 const res = await uploadVideo(server.url, server.accessToken, { commentsEnabled: false })
326 videoUUID = res.body.video.uuid 327 video = res.body.video
327 pathThread = '/api/v1/videos/' + videoUUID + '/comment-threads' 328 pathThread = '/api/v1/videos/' + video.uuid + '/comment-threads'
328 }) 329 })
329 330
330 it('Should return an empty thread list', async function () { 331 it('Should return an empty thread list', async function () {
diff --git a/server/tests/api/check-params/video-playlists.ts b/server/tests/api/check-params/video-playlists.ts
index bbea88354..18253d11a 100644
--- a/server/tests/api/check-params/video-playlists.ts
+++ b/server/tests/api/check-params/video-playlists.ts
@@ -1,8 +1,13 @@
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
3import 'mocha' 3import 'mocha'
4import { VideoPlaylistCreateResult, VideoPlaylistPrivacy, VideoPlaylistType } from '@shared/models'
5import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
4import { 6import {
5 addVideoInPlaylist, 7 addVideoInPlaylist,
8 checkBadCountPagination,
9 checkBadSortPagination,
10 checkBadStartPagination,
6 cleanupTests, 11 cleanupTests,
7 createVideoPlaylist, 12 createVideoPlaylist,
8 deleteVideoPlaylist, 13 deleteVideoPlaylist,
@@ -21,20 +26,14 @@ import {
21 updateVideoPlaylistElement, 26 updateVideoPlaylistElement,
22 uploadVideoAndGetId 27 uploadVideoAndGetId
23} from '../../../../shared/extra-utils' 28} from '../../../../shared/extra-utils'
24import {
25 checkBadCountPagination,
26 checkBadSortPagination,
27 checkBadStartPagination
28} from '../../../../shared/extra-utils/requests/check-api-params'
29import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model'
30import { VideoPlaylistType } from '../../../../shared/models/videos/playlist/video-playlist-type.model'
31import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
32 29
33describe('Test video playlists API validator', function () { 30describe('Test video playlists API validator', function () {
34 let server: ServerInfo 31 let server: ServerInfo
35 let userAccessToken: string 32 let userAccessToken: string
36 let playlistUUID: string 33
34 let playlist: VideoPlaylistCreateResult
37 let privatePlaylistUUID: string 35 let privatePlaylistUUID: string
36
38 let watchLaterPlaylistId: number 37 let watchLaterPlaylistId: number
39 let videoId: number 38 let videoId: number
40 let playlistElementId: number 39 let playlistElementId: number
@@ -67,7 +66,7 @@ describe('Test video playlists API validator', function () {
67 videoChannelId: server.videoChannel.id 66 videoChannelId: server.videoChannel.id
68 } 67 }
69 }) 68 })
70 playlistUUID = res.body.videoPlaylist.uuid 69 playlist = res.body.videoPlaylist
71 } 70 }
72 71
73 { 72 {
@@ -150,15 +149,15 @@ describe('Test video playlists API validator', function () {
150 const path = '/api/v1/video-playlists/' 149 const path = '/api/v1/video-playlists/'
151 150
152 it('Should fail with a bad start pagination', async function () { 151 it('Should fail with a bad start pagination', async function () {
153 await checkBadStartPagination(server.url, path + playlistUUID + '/videos', server.accessToken) 152 await checkBadStartPagination(server.url, path + playlist.shortUUID + '/videos', server.accessToken)
154 }) 153 })
155 154
156 it('Should fail with a bad count pagination', async function () { 155 it('Should fail with a bad count pagination', async function () {
157 await checkBadCountPagination(server.url, path + playlistUUID + '/videos', server.accessToken) 156 await checkBadCountPagination(server.url, path + playlist.shortUUID + '/videos', server.accessToken)
158 }) 157 })
159 158
160 it('Should success with the correct parameters', async function () { 159 it('Should success with the correct parameters', async function () {
161 await makeGetRequest({ url: server.url, path: path + playlistUUID + '/videos', statusCodeExpected: HttpStatusCode.OK_200 }) 160 await makeGetRequest({ url: server.url, path: path + playlist.shortUUID + '/videos', statusCodeExpected: HttpStatusCode.OK_200 })
162 }) 161 })
163 }) 162 })
164 163
@@ -177,6 +176,7 @@ describe('Test video playlists API validator', function () {
177 token: server.accessToken, 176 token: server.accessToken,
178 playlistAttrs: { 177 playlistAttrs: {
179 displayName: 'super playlist', 178 displayName: 'super playlist',
179 videoChannelId: server.videoChannel.id,
180 privacy: VideoPlaylistPrivacy.UNLISTED 180 privacy: VideoPlaylistPrivacy.UNLISTED
181 } 181 }
182 }) 182 })
@@ -187,7 +187,7 @@ describe('Test video playlists API validator', function () {
187 }) 187 })
188 188
189 it('Should succeed with the correct params', async function () { 189 it('Should succeed with the correct params', async function () {
190 await getVideoPlaylist(server.url, playlistUUID, HttpStatusCode.OK_200) 190 await getVideoPlaylist(server.url, playlist.uuid, HttpStatusCode.OK_200)
191 }) 191 })
192 }) 192 })
193 193
@@ -213,7 +213,7 @@ describe('Test video playlists API validator', function () {
213 const params = getBase({}, { token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 213 const params = getBase({}, { token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
214 214
215 await createVideoPlaylist(params) 215 await createVideoPlaylist(params)
216 await updateVideoPlaylist(getUpdate(params, playlistUUID)) 216 await updateVideoPlaylist(getUpdate(params, playlist.shortUUID))
217 }) 217 })
218 218
219 it('Should fail without displayName', async function () { 219 it('Should fail without displayName', async function () {
@@ -226,42 +226,42 @@ describe('Test video playlists API validator', function () {
226 const params = getBase({ displayName: 's'.repeat(300) }) 226 const params = getBase({ displayName: 's'.repeat(300) })
227 227
228 await createVideoPlaylist(params) 228 await createVideoPlaylist(params)
229 await updateVideoPlaylist(getUpdate(params, playlistUUID)) 229 await updateVideoPlaylist(getUpdate(params, playlist.shortUUID))
230 }) 230 })
231 231
232 it('Should fail with an incorrect description', async function () { 232 it('Should fail with an incorrect description', async function () {
233 const params = getBase({ description: 't' }) 233 const params = getBase({ description: 't' })
234 234
235 await createVideoPlaylist(params) 235 await createVideoPlaylist(params)
236 await updateVideoPlaylist(getUpdate(params, playlistUUID)) 236 await updateVideoPlaylist(getUpdate(params, playlist.shortUUID))
237 }) 237 })
238 238
239 it('Should fail with an incorrect privacy', async function () { 239 it('Should fail with an incorrect privacy', async function () {
240 const params = getBase({ privacy: 45 }) 240 const params = getBase({ privacy: 45 })
241 241
242 await createVideoPlaylist(params) 242 await createVideoPlaylist(params)
243 await updateVideoPlaylist(getUpdate(params, playlistUUID)) 243 await updateVideoPlaylist(getUpdate(params, playlist.shortUUID))
244 }) 244 })
245 245
246 it('Should fail with an unknown video channel id', async function () { 246 it('Should fail with an unknown video channel id', async function () {
247 const params = getBase({ videoChannelId: 42 }, { expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 247 const params = getBase({ videoChannelId: 42 }, { expectedStatus: HttpStatusCode.NOT_FOUND_404 })
248 248
249 await createVideoPlaylist(params) 249 await createVideoPlaylist(params)
250 await updateVideoPlaylist(getUpdate(params, playlistUUID)) 250 await updateVideoPlaylist(getUpdate(params, playlist.shortUUID))
251 }) 251 })
252 252
253 it('Should fail with an incorrect thumbnail file', async function () { 253 it('Should fail with an incorrect thumbnail file', async function () {
254 const params = getBase({ thumbnailfile: 'video_short.mp4' }) 254 const params = getBase({ thumbnailfile: 'video_short.mp4' })
255 255
256 await createVideoPlaylist(params) 256 await createVideoPlaylist(params)
257 await updateVideoPlaylist(getUpdate(params, playlistUUID)) 257 await updateVideoPlaylist(getUpdate(params, playlist.shortUUID))
258 }) 258 })
259 259
260 it('Should fail with a thumbnail file too big', async function () { 260 it('Should fail with a thumbnail file too big', async function () {
261 const params = getBase({ thumbnailfile: 'preview-big.png' }) 261 const params = getBase({ thumbnailfile: 'preview-big.png' })
262 262
263 await createVideoPlaylist(params) 263 await createVideoPlaylist(params)
264 await updateVideoPlaylist(getUpdate(params, playlistUUID)) 264 await updateVideoPlaylist(getUpdate(params, playlist.shortUUID))
265 }) 265 })
266 266
267 it('Should fail to set "public" a playlist not assigned to a channel', async function () { 267 it('Should fail to set "public" a playlist not assigned to a channel', async function () {
@@ -272,8 +272,8 @@ describe('Test video playlists API validator', function () {
272 await createVideoPlaylist(params) 272 await createVideoPlaylist(params)
273 await createVideoPlaylist(params2) 273 await createVideoPlaylist(params2)
274 await updateVideoPlaylist(getUpdate(params, privatePlaylistUUID)) 274 await updateVideoPlaylist(getUpdate(params, privatePlaylistUUID))
275 await updateVideoPlaylist(getUpdate(params2, playlistUUID)) 275 await updateVideoPlaylist(getUpdate(params2, playlist.shortUUID))
276 await updateVideoPlaylist(getUpdate(params3, playlistUUID)) 276 await updateVideoPlaylist(getUpdate(params3, playlist.shortUUID))
277 }) 277 })
278 278
279 it('Should fail with an unknown playlist to update', async function () { 279 it('Should fail with an unknown playlist to update', async function () {
@@ -286,7 +286,7 @@ describe('Test video playlists API validator', function () {
286 it('Should fail to update a playlist of another user', async function () { 286 it('Should fail to update a playlist of another user', async function () {
287 await updateVideoPlaylist(getUpdate( 287 await updateVideoPlaylist(getUpdate(
288 getBase({}, { token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }), 288 getBase({}, { token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }),
289 playlistUUID 289 playlist.shortUUID
290 )) 290 ))
291 }) 291 })
292 292
@@ -305,7 +305,7 @@ describe('Test video playlists API validator', function () {
305 305
306 { 306 {
307 const params = getBase({}, { expectedStatus: HttpStatusCode.NO_CONTENT_204 }) 307 const params = getBase({}, { expectedStatus: HttpStatusCode.NO_CONTENT_204 })
308 await updateVideoPlaylist(getUpdate(params, playlistUUID)) 308 await updateVideoPlaylist(getUpdate(params, playlist.shortUUID))
309 } 309 }
310 }) 310 })
311 }) 311 })
@@ -316,7 +316,7 @@ describe('Test video playlists API validator', function () {
316 expectedStatus: HttpStatusCode.BAD_REQUEST_400, 316 expectedStatus: HttpStatusCode.BAD_REQUEST_400,
317 url: server.url, 317 url: server.url,
318 token: server.accessToken, 318 token: server.accessToken,
319 playlistId: playlistUUID, 319 playlistId: playlist.id,
320 elementAttrs: Object.assign({ 320 elementAttrs: Object.assign({
321 videoId, 321 videoId,
322 startTimestamp: 2, 322 startTimestamp: 2,
@@ -381,7 +381,7 @@ describe('Test video playlists API validator', function () {
381 stopTimestamp: 2 381 stopTimestamp: 2
382 }, elementAttrs), 382 }, elementAttrs),
383 playlistElementId, 383 playlistElementId,
384 playlistId: playlistUUID, 384 playlistId: playlist.id,
385 expectedStatus: HttpStatusCode.BAD_REQUEST_400 385 expectedStatus: HttpStatusCode.BAD_REQUEST_400
386 }, wrapper) 386 }, wrapper)
387 } 387 }
@@ -451,7 +451,7 @@ describe('Test video playlists API validator', function () {
451 return Object.assign({ 451 return Object.assign({
452 url: server.url, 452 url: server.url,
453 token: server.accessToken, 453 token: server.accessToken,
454 playlistId: playlistUUID, 454 playlistId: playlist.shortUUID,
455 elementAttrs: Object.assign({ 455 elementAttrs: Object.assign({
456 startPosition: 1, 456 startPosition: 1,
457 insertAfterPosition: 2, 457 insertAfterPosition: 2,
@@ -469,7 +469,7 @@ describe('Test video playlists API validator', function () {
469 await addVideoInPlaylist({ 469 await addVideoInPlaylist({
470 url: server.url, 470 url: server.url,
471 token: server.accessToken, 471 token: server.accessToken,
472 playlistId: playlistUUID, 472 playlistId: playlist.shortUUID,
473 elementAttrs: { videoId: id } 473 elementAttrs: { videoId: id }
474 }) 474 })
475 } 475 }
@@ -606,7 +606,7 @@ describe('Test video playlists API validator', function () {
606 url: server.url, 606 url: server.url,
607 token: server.accessToken, 607 token: server.accessToken,
608 playlistElementId, 608 playlistElementId,
609 playlistId: playlistUUID, 609 playlistId: playlist.uuid,
610 expectedStatus: HttpStatusCode.BAD_REQUEST_400 610 expectedStatus: HttpStatusCode.BAD_REQUEST_400
611 }, wrapper) 611 }, wrapper)
612 } 612 }
@@ -662,7 +662,7 @@ describe('Test video playlists API validator', function () {
662 }) 662 })
663 663
664 it('Should fail with a playlist of another user', async function () { 664 it('Should fail with a playlist of another user', async function () {
665 await deleteVideoPlaylist(server.url, userAccessToken, playlistUUID, HttpStatusCode.FORBIDDEN_403) 665 await deleteVideoPlaylist(server.url, userAccessToken, playlist.uuid, HttpStatusCode.FORBIDDEN_403)
666 }) 666 })
667 667
668 it('Should fail with the watch later playlist', async function () { 668 it('Should fail with the watch later playlist', async function () {
@@ -670,7 +670,7 @@ describe('Test video playlists API validator', function () {
670 }) 670 })
671 671
672 it('Should succeed with the correct params', async function () { 672 it('Should succeed with the correct params', async function () {
673 await deleteVideoPlaylist(server.url, server.accessToken, playlistUUID) 673 await deleteVideoPlaylist(server.url, server.accessToken, playlist.uuid)
674 }) 674 })
675 }) 675 })
676 676
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts
index a6eecb13a..4d7a9a23b 100644
--- a/server/tests/api/check-params/videos.ts
+++ b/server/tests/api/check-params/videos.ts
@@ -5,7 +5,7 @@ import * as chai from 'chai'
5import { omit } from 'lodash' 5import { omit } from 'lodash'
6import { join } from 'path' 6import { join } from 'path'
7import { randomInt } from '@shared/core-utils' 7import { randomInt } from '@shared/core-utils'
8import { PeerTubeProblemDocument } from '@shared/models' 8import { PeerTubeProblemDocument, VideoCreateResult } from '@shared/models'
9import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 9import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
10import { 10import {
11 checkUploadVideoParam, 11 checkUploadVideoParam,
@@ -42,7 +42,7 @@ describe('Test videos API validator', function () {
42 let accountName: string 42 let accountName: string
43 let channelId: number 43 let channelId: number
44 let channelName: string 44 let channelName: string
45 let videoId 45 let video: VideoCreateResult
46 46
47 // --------------------------------------------------------------- 47 // ---------------------------------------------------------------
48 48
@@ -490,7 +490,7 @@ describe('Test videos API validator', function () {
490 490
491 before(async function () { 491 before(async function () {
492 const res = await getVideosList(server.url) 492 const res = await getVideosList(server.url)
493 videoId = res.body.data[0].uuid 493 video = res.body.data[0]
494 }) 494 })
495 495
496 it('Should fail with nothing', async function () { 496 it('Should fail with nothing', async function () {
@@ -518,79 +518,79 @@ describe('Test videos API validator', function () {
518 it('Should fail with a long name', async function () { 518 it('Should fail with a long name', async function () {
519 const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) }) 519 const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) })
520 520
521 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 521 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
522 }) 522 })
523 523
524 it('Should fail with a bad category', async function () { 524 it('Should fail with a bad category', async function () {
525 const fields = immutableAssign(baseCorrectParams, { category: 125 }) 525 const fields = immutableAssign(baseCorrectParams, { category: 125 })
526 526
527 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 527 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
528 }) 528 })
529 529
530 it('Should fail with a bad licence', async function () { 530 it('Should fail with a bad licence', async function () {
531 const fields = immutableAssign(baseCorrectParams, { licence: 125 }) 531 const fields = immutableAssign(baseCorrectParams, { licence: 125 })
532 532
533 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 533 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
534 }) 534 })
535 535
536 it('Should fail with a bad language', async function () { 536 it('Should fail with a bad language', async function () {
537 const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) }) 537 const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) })
538 538
539 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 539 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
540 }) 540 })
541 541
542 it('Should fail with a long description', async function () { 542 it('Should fail with a long description', async function () {
543 const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) }) 543 const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) })
544 544
545 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 545 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
546 }) 546 })
547 547
548 it('Should fail with a long support text', async function () { 548 it('Should fail with a long support text', async function () {
549 const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) }) 549 const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) })
550 550
551 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 551 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
552 }) 552 })
553 553
554 it('Should fail with a bad channel', async function () { 554 it('Should fail with a bad channel', async function () {
555 const fields = immutableAssign(baseCorrectParams, { channelId: 545454 }) 555 const fields = immutableAssign(baseCorrectParams, { channelId: 545454 })
556 556
557 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 557 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
558 }) 558 })
559 559
560 it('Should fail with too many tags', async function () { 560 it('Should fail with too many tags', async function () {
561 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }) 561 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] })
562 562
563 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 563 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
564 }) 564 })
565 565
566 it('Should fail with a tag length too low', async function () { 566 it('Should fail with a tag length too low', async function () {
567 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] }) 567 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] })
568 568
569 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 569 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
570 }) 570 })
571 571
572 it('Should fail with a tag length too big', async function () { 572 it('Should fail with a tag length too big', async function () {
573 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }) 573 const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] })
574 574
575 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 575 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
576 }) 576 })
577 577
578 it('Should fail with a bad schedule update (miss updateAt)', async function () { 578 it('Should fail with a bad schedule update (miss updateAt)', async function () {
579 const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } }) 579 const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } })
580 580
581 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 581 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
582 }) 582 })
583 583
584 it('Should fail with a bad schedule update (wrong updateAt)', async function () { 584 it('Should fail with a bad schedule update (wrong updateAt)', async function () {
585 const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { updateAt: 'toto', privacy: VideoPrivacy.PUBLIC } }) 585 const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { updateAt: 'toto', privacy: VideoPrivacy.PUBLIC } })
586 586
587 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 587 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
588 }) 588 })
589 589
590 it('Should fail with a bad originally published at param', async function () { 590 it('Should fail with a bad originally published at param', async function () {
591 const fields = immutableAssign(baseCorrectParams, { originallyPublishedAt: 'toto' }) 591 const fields = immutableAssign(baseCorrectParams, { originallyPublishedAt: 'toto' })
592 592
593 await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 593 await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
594 }) 594 })
595 595
596 it('Should fail with an incorrect thumbnail file', async function () { 596 it('Should fail with an incorrect thumbnail file', async function () {
@@ -602,7 +602,7 @@ describe('Test videos API validator', function () {
602 await makeUploadRequest({ 602 await makeUploadRequest({
603 url: server.url, 603 url: server.url,
604 method: 'PUT', 604 method: 'PUT',
605 path: path + videoId, 605 path: path + video.shortUUID,
606 token: server.accessToken, 606 token: server.accessToken,
607 fields, 607 fields,
608 attaches 608 attaches
@@ -618,7 +618,7 @@ describe('Test videos API validator', function () {
618 await makeUploadRequest({ 618 await makeUploadRequest({
619 url: server.url, 619 url: server.url,
620 method: 'PUT', 620 method: 'PUT',
621 path: path + videoId, 621 path: path + video.shortUUID,
622 token: server.accessToken, 622 token: server.accessToken,
623 fields, 623 fields,
624 attaches 624 attaches
@@ -634,7 +634,7 @@ describe('Test videos API validator', function () {
634 await makeUploadRequest({ 634 await makeUploadRequest({
635 url: server.url, 635 url: server.url,
636 method: 'PUT', 636 method: 'PUT',
637 path: path + videoId, 637 path: path + video.shortUUID,
638 token: server.accessToken, 638 token: server.accessToken,
639 fields, 639 fields,
640 attaches 640 attaches
@@ -650,7 +650,7 @@ describe('Test videos API validator', function () {
650 await makeUploadRequest({ 650 await makeUploadRequest({
651 url: server.url, 651 url: server.url,
652 method: 'PUT', 652 method: 'PUT',
653 path: path + videoId, 653 path: path + video.shortUUID,
654 token: server.accessToken, 654 token: server.accessToken,
655 fields, 655 fields,
656 attaches 656 attaches
@@ -662,7 +662,7 @@ describe('Test videos API validator', function () {
662 662
663 await makePutBodyRequest({ 663 await makePutBodyRequest({
664 url: server.url, 664 url: server.url,
665 path: path + videoId, 665 path: path + video.shortUUID,
666 token: userAccessToken, 666 token: userAccessToken,
667 fields, 667 fields,
668 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 668 statusCodeExpected: HttpStatusCode.FORBIDDEN_403
@@ -674,7 +674,7 @@ describe('Test videos API validator', function () {
674 it('Shoud report the appropriate error', async function () { 674 it('Shoud report the appropriate error', async function () {
675 const fields = immutableAssign(baseCorrectParams, { licence: 125 }) 675 const fields = immutableAssign(baseCorrectParams, { licence: 125 })
676 676
677 const res = await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) 677 const res = await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields })
678 const error = res.body as PeerTubeProblemDocument 678 const error = res.body as PeerTubeProblemDocument
679 679
680 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/putVideo') 680 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/putVideo')
@@ -694,7 +694,7 @@ describe('Test videos API validator', function () {
694 694
695 await makePutBodyRequest({ 695 await makePutBodyRequest({
696 url: server.url, 696 url: server.url,
697 path: path + videoId, 697 path: path + video.shortUUID,
698 token: server.accessToken, 698 token: server.accessToken,
699 fields, 699 fields,
700 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 700 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
@@ -739,7 +739,7 @@ describe('Test videos API validator', function () {
739 }) 739 })
740 740
741 it('Should succeed with the correct parameters', async function () { 741 it('Should succeed with the correct parameters', async function () {
742 await getVideo(server.url, videoId) 742 await getVideo(server.url, video.shortUUID)
743 }) 743 })
744 }) 744 })
745 745
@@ -810,7 +810,7 @@ describe('Test videos API validator', function () {
810 }) 810 })
811 811
812 it('Should fail with a video of another user without the appropriate right', async function () { 812 it('Should fail with a video of another user without the appropriate right', async function () {
813 await removeVideo(server.url, userAccessToken, videoId, HttpStatusCode.FORBIDDEN_403) 813 await removeVideo(server.url, userAccessToken, video.uuid, HttpStatusCode.FORBIDDEN_403)
814 }) 814 })
815 815
816 it('Should fail with a video of another server') 816 it('Should fail with a video of another server')
@@ -832,7 +832,7 @@ describe('Test videos API validator', function () {
832 }) 832 })
833 833
834 it('Should succeed with the correct parameters', async function () { 834 it('Should succeed with the correct parameters', async function () {
835 await removeVideo(server.url, server.accessToken, videoId) 835 await removeVideo(server.url, server.accessToken, video.uuid)
836 }) 836 })
837 }) 837 })
838 838