diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-21 15:51:30 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-21 15:51:30 +0200 |
commit | a24bd1ed41b43790bab6ba789580bb4e85f07d85 (patch) | |
tree | a54b0f6c921ba83a6e909cd0ced325b2d4b8863c /server/tests/api/check-params/videos.ts | |
parent | 5f26f13b3c16ac5ae0a3b0a7142d84a9528cf565 (diff) | |
parent | c63830f15403ac4e750829f27d8bbbdc9a59282c (diff) | |
download | PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.gz PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.zst PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.zip |
Merge branch 'next' into develop
Diffstat (limited to 'server/tests/api/check-params/videos.ts')
-rw-r--r-- | server/tests/api/check-params/videos.ts | 243 |
1 files changed, 119 insertions, 124 deletions
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts index 4d7a9a23b..e11ca0c82 100644 --- a/server/tests/api/check-params/videos.ts +++ b/server/tests/api/check-params/videos.ts | |||
@@ -5,39 +5,28 @@ import * as chai from 'chai' | |||
5 | import { omit } from 'lodash' | 5 | import { omit } from 'lodash' |
6 | import { join } from 'path' | 6 | import { join } from 'path' |
7 | import { randomInt } from '@shared/core-utils' | 7 | import { randomInt } from '@shared/core-utils' |
8 | import { PeerTubeProblemDocument, VideoCreateResult } from '@shared/models' | ||
9 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
10 | import { | 8 | import { |
9 | checkBadCountPagination, | ||
10 | checkBadSortPagination, | ||
11 | checkBadStartPagination, | ||
11 | checkUploadVideoParam, | 12 | checkUploadVideoParam, |
12 | cleanupTests, | 13 | cleanupTests, |
13 | createUser, | 14 | createSingleServer, |
14 | flushAndRunServer, | ||
15 | getMyUserInformation, | ||
16 | getVideo, | ||
17 | getVideosList, | ||
18 | immutableAssign, | ||
19 | makeDeleteRequest, | 15 | makeDeleteRequest, |
20 | makeGetRequest, | 16 | makeGetRequest, |
21 | makePutBodyRequest, | 17 | makePutBodyRequest, |
22 | makeUploadRequest, | 18 | makeUploadRequest, |
23 | removeVideo, | 19 | PeerTubeServer, |
24 | root, | 20 | root, |
25 | ServerInfo, | 21 | setAccessTokensToServers |
26 | setAccessTokensToServers, | 22 | } from '@shared/extra-utils' |
27 | userLogin | 23 | import { HttpStatusCode, PeerTubeProblemDocument, VideoCreateResult, VideoPrivacy } from '@shared/models' |
28 | } from '../../../../shared/extra-utils' | ||
29 | import { | ||
30 | checkBadCountPagination, | ||
31 | checkBadSortPagination, | ||
32 | checkBadStartPagination | ||
33 | } from '../../../../shared/extra-utils/requests/check-api-params' | ||
34 | import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' | ||
35 | 24 | ||
36 | const expect = chai.expect | 25 | const expect = chai.expect |
37 | 26 | ||
38 | describe('Test videos API validator', function () { | 27 | describe('Test videos API validator', function () { |
39 | const path = '/api/v1/videos/' | 28 | const path = '/api/v1/videos/' |
40 | let server: ServerInfo | 29 | let server: PeerTubeServer |
41 | let userAccessToken = '' | 30 | let userAccessToken = '' |
42 | let accountName: string | 31 | let accountName: string |
43 | let channelId: number | 32 | let channelId: number |
@@ -49,20 +38,20 @@ describe('Test videos API validator', function () { | |||
49 | before(async function () { | 38 | before(async function () { |
50 | this.timeout(30000) | 39 | this.timeout(30000) |
51 | 40 | ||
52 | server = await flushAndRunServer(1) | 41 | server = await createSingleServer(1) |
53 | 42 | ||
54 | await setAccessTokensToServers([ server ]) | 43 | await setAccessTokensToServers([ server ]) |
55 | 44 | ||
56 | const username = 'user1' | 45 | const username = 'user1' |
57 | const password = 'my super password' | 46 | const password = 'my super password' |
58 | await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password }) | 47 | await server.users.create({ username: username, password: password }) |
59 | userAccessToken = await userLogin(server, { username, password }) | 48 | userAccessToken = await server.login.getAccessToken({ username, password }) |
60 | 49 | ||
61 | { | 50 | { |
62 | const res = await getMyUserInformation(server.url, server.accessToken) | 51 | const body = await server.users.getMyInfo() |
63 | channelId = res.body.videoChannels[0].id | 52 | channelId = body.videoChannels[0].id |
64 | channelName = res.body.videoChannels[0].name | 53 | channelName = body.videoChannels[0].name |
65 | accountName = res.body.account.name + '@' + res.body.account.host | 54 | accountName = body.account.name + '@' + body.account.host |
66 | } | 55 | } |
67 | }) | 56 | }) |
68 | 57 | ||
@@ -80,11 +69,11 @@ describe('Test videos API validator', function () { | |||
80 | }) | 69 | }) |
81 | 70 | ||
82 | it('Should fail with a bad skipVideos query', async function () { | 71 | it('Should fail with a bad skipVideos query', async function () { |
83 | await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200, query: { skipCount: 'toto' } }) | 72 | await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200, query: { skipCount: 'toto' } }) |
84 | }) | 73 | }) |
85 | 74 | ||
86 | it('Should success with the correct parameters', async function () { | 75 | it('Should success with the correct parameters', async function () { |
87 | await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200, query: { skipCount: false } }) | 76 | await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200, query: { skipCount: false } }) |
88 | }) | 77 | }) |
89 | }) | 78 | }) |
90 | 79 | ||
@@ -94,7 +83,7 @@ describe('Test videos API validator', function () { | |||
94 | await makeGetRequest({ | 83 | await makeGetRequest({ |
95 | url: server.url, | 84 | url: server.url, |
96 | path: join(path, 'search'), | 85 | path: join(path, 'search'), |
97 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 86 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
98 | }) | 87 | }) |
99 | }) | 88 | }) |
100 | 89 | ||
@@ -111,7 +100,7 @@ describe('Test videos API validator', function () { | |||
111 | }) | 100 | }) |
112 | 101 | ||
113 | it('Should success with the correct parameters', async function () { | 102 | it('Should success with the correct parameters', async function () { |
114 | await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200 }) | 103 | await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200 }) |
115 | }) | 104 | }) |
116 | }) | 105 | }) |
117 | 106 | ||
@@ -131,7 +120,7 @@ describe('Test videos API validator', function () { | |||
131 | }) | 120 | }) |
132 | 121 | ||
133 | it('Should success with the correct parameters', async function () { | 122 | it('Should success with the correct parameters', async function () { |
134 | await makeGetRequest({ url: server.url, token: server.accessToken, path, statusCodeExpected: HttpStatusCode.OK_200 }) | 123 | await makeGetRequest({ url: server.url, token: server.accessToken, path, expectedStatus: HttpStatusCode.OK_200 }) |
135 | }) | 124 | }) |
136 | }) | 125 | }) |
137 | 126 | ||
@@ -155,7 +144,7 @@ describe('Test videos API validator', function () { | |||
155 | }) | 144 | }) |
156 | 145 | ||
157 | it('Should success with the correct parameters', async function () { | 146 | it('Should success with the correct parameters', async function () { |
158 | await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200 }) | 147 | await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200 }) |
159 | }) | 148 | }) |
160 | }) | 149 | }) |
161 | 150 | ||
@@ -179,7 +168,7 @@ describe('Test videos API validator', function () { | |||
179 | }) | 168 | }) |
180 | 169 | ||
181 | it('Should success with the correct parameters', async function () { | 170 | it('Should success with the correct parameters', async function () { |
182 | await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200 }) | 171 | await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200 }) |
183 | }) | 172 | }) |
184 | }) | 173 | }) |
185 | 174 | ||
@@ -214,70 +203,70 @@ describe('Test videos API validator', function () { | |||
214 | it('Should fail with nothing', async function () { | 203 | it('Should fail with nothing', async function () { |
215 | const fields = {} | 204 | const fields = {} |
216 | const attaches = {} | 205 | const attaches = {} |
217 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 206 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
218 | }) | 207 | }) |
219 | 208 | ||
220 | it('Should fail without name', async function () { | 209 | it('Should fail without name', async function () { |
221 | const fields = omit(baseCorrectParams, 'name') | 210 | const fields = omit(baseCorrectParams, 'name') |
222 | const attaches = baseCorrectAttaches | 211 | const attaches = baseCorrectAttaches |
223 | 212 | ||
224 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 213 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
225 | }) | 214 | }) |
226 | 215 | ||
227 | it('Should fail with a long name', async function () { | 216 | it('Should fail with a long name', async function () { |
228 | const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) }) | 217 | const fields = { ...baseCorrectParams, name: 'super'.repeat(65) } |
229 | const attaches = baseCorrectAttaches | 218 | const attaches = baseCorrectAttaches |
230 | 219 | ||
231 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 220 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
232 | }) | 221 | }) |
233 | 222 | ||
234 | it('Should fail with a bad category', async function () { | 223 | it('Should fail with a bad category', async function () { |
235 | const fields = immutableAssign(baseCorrectParams, { category: 125 }) | 224 | const fields = { ...baseCorrectParams, category: 125 } |
236 | const attaches = baseCorrectAttaches | 225 | const attaches = baseCorrectAttaches |
237 | 226 | ||
238 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 227 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
239 | }) | 228 | }) |
240 | 229 | ||
241 | it('Should fail with a bad licence', async function () { | 230 | it('Should fail with a bad licence', async function () { |
242 | const fields = immutableAssign(baseCorrectParams, { licence: 125 }) | 231 | const fields = { ...baseCorrectParams, licence: 125 } |
243 | const attaches = baseCorrectAttaches | 232 | const attaches = baseCorrectAttaches |
244 | 233 | ||
245 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 234 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
246 | }) | 235 | }) |
247 | 236 | ||
248 | it('Should fail with a bad language', async function () { | 237 | it('Should fail with a bad language', async function () { |
249 | const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) }) | 238 | const fields = { ...baseCorrectParams, language: 'a'.repeat(15) } |
250 | const attaches = baseCorrectAttaches | 239 | const attaches = baseCorrectAttaches |
251 | 240 | ||
252 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 241 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
253 | }) | 242 | }) |
254 | 243 | ||
255 | it('Should fail with a long description', async function () { | 244 | it('Should fail with a long description', async function () { |
256 | const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) }) | 245 | const fields = { ...baseCorrectParams, description: 'super'.repeat(2500) } |
257 | const attaches = baseCorrectAttaches | 246 | const attaches = baseCorrectAttaches |
258 | 247 | ||
259 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 248 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
260 | }) | 249 | }) |
261 | 250 | ||
262 | it('Should fail with a long support text', async function () { | 251 | it('Should fail with a long support text', async function () { |
263 | const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) }) | 252 | const fields = { ...baseCorrectParams, support: 'super'.repeat(201) } |
264 | const attaches = baseCorrectAttaches | 253 | const attaches = baseCorrectAttaches |
265 | 254 | ||
266 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 255 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
267 | }) | 256 | }) |
268 | 257 | ||
269 | it('Should fail without a channel', async function () { | 258 | it('Should fail without a channel', async function () { |
270 | const fields = omit(baseCorrectParams, 'channelId') | 259 | const fields = omit(baseCorrectParams, 'channelId') |
271 | const attaches = baseCorrectAttaches | 260 | const attaches = baseCorrectAttaches |
272 | 261 | ||
273 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 262 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
274 | }) | 263 | }) |
275 | 264 | ||
276 | it('Should fail with a bad channel', async function () { | 265 | it('Should fail with a bad channel', async function () { |
277 | const fields = immutableAssign(baseCorrectParams, { channelId: 545454 }) | 266 | const fields = { ...baseCorrectParams, channelId: 545454 } |
278 | const attaches = baseCorrectAttaches | 267 | const attaches = baseCorrectAttaches |
279 | 268 | ||
280 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 269 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
281 | }) | 270 | }) |
282 | 271 | ||
283 | it('Should fail with another user channel', async function () { | 272 | it('Should fail with another user channel', async function () { |
@@ -285,69 +274,71 @@ describe('Test videos API validator', function () { | |||
285 | username: 'fake' + randomInt(0, 1500), | 274 | username: 'fake' + randomInt(0, 1500), |
286 | password: 'fake_password' | 275 | password: 'fake_password' |
287 | } | 276 | } |
288 | await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) | 277 | await server.users.create({ username: user.username, password: user.password }) |
289 | 278 | ||
290 | const accessTokenUser = await userLogin(server, user) | 279 | const accessTokenUser = await server.login.getAccessToken(user) |
291 | const res = await getMyUserInformation(server.url, accessTokenUser) | 280 | const { videoChannels } = await server.users.getMyInfo({ token: accessTokenUser }) |
292 | const customChannelId = res.body.videoChannels[0].id | 281 | const customChannelId = videoChannels[0].id |
293 | 282 | ||
294 | const fields = immutableAssign(baseCorrectParams, { channelId: customChannelId }) | 283 | const fields = { ...baseCorrectParams, channelId: customChannelId } |
295 | const attaches = baseCorrectAttaches | 284 | const attaches = baseCorrectAttaches |
296 | 285 | ||
297 | await checkUploadVideoParam(server.url, userAccessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 286 | await checkUploadVideoParam(server, userAccessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
298 | }) | 287 | }) |
299 | 288 | ||
300 | it('Should fail with too many tags', async function () { | 289 | it('Should fail with too many tags', async function () { |
301 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }) | 290 | const fields = { ...baseCorrectParams, tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] } |
302 | const attaches = baseCorrectAttaches | 291 | const attaches = baseCorrectAttaches |
303 | 292 | ||
304 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 293 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
305 | }) | 294 | }) |
306 | 295 | ||
307 | it('Should fail with a tag length too low', async function () { | 296 | it('Should fail with a tag length too low', async function () { |
308 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] }) | 297 | const fields = { ...baseCorrectParams, tags: [ 'tag1', 't' ] } |
309 | const attaches = baseCorrectAttaches | 298 | const attaches = baseCorrectAttaches |
310 | 299 | ||
311 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 300 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
312 | }) | 301 | }) |
313 | 302 | ||
314 | it('Should fail with a tag length too big', async function () { | 303 | it('Should fail with a tag length too big', async function () { |
315 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }) | 304 | const fields = { ...baseCorrectParams, tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] } |
316 | const attaches = baseCorrectAttaches | 305 | const attaches = baseCorrectAttaches |
317 | 306 | ||
318 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 307 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
319 | }) | 308 | }) |
320 | 309 | ||
321 | it('Should fail with a bad schedule update (miss updateAt)', async function () { | 310 | it('Should fail with a bad schedule update (miss updateAt)', async function () { |
322 | const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } }) | 311 | const fields = { ...baseCorrectParams, scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } } |
323 | const attaches = baseCorrectAttaches | 312 | const attaches = baseCorrectAttaches |
324 | 313 | ||
325 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 314 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
326 | }) | 315 | }) |
327 | 316 | ||
328 | it('Should fail with a bad schedule update (wrong updateAt)', async function () { | 317 | it('Should fail with a bad schedule update (wrong updateAt)', async function () { |
329 | const fields = immutableAssign(baseCorrectParams, { | 318 | const fields = { |
319 | ...baseCorrectParams, | ||
320 | |||
330 | scheduleUpdate: { | 321 | scheduleUpdate: { |
331 | privacy: VideoPrivacy.PUBLIC, | 322 | privacy: VideoPrivacy.PUBLIC, |
332 | updateAt: 'toto' | 323 | updateAt: 'toto' |
333 | } | 324 | } |
334 | }) | 325 | } |
335 | const attaches = baseCorrectAttaches | 326 | const attaches = baseCorrectAttaches |
336 | 327 | ||
337 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 328 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
338 | }) | 329 | }) |
339 | 330 | ||
340 | it('Should fail with a bad originally published at attribute', async function () { | 331 | it('Should fail with a bad originally published at attribute', async function () { |
341 | const fields = immutableAssign(baseCorrectParams, { originallyPublishedAt: 'toto' }) | 332 | const fields = { ...baseCorrectParams, originallyPublishedAt: 'toto' } |
342 | const attaches = baseCorrectAttaches | 333 | const attaches = baseCorrectAttaches |
343 | 334 | ||
344 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 335 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
345 | }) | 336 | }) |
346 | 337 | ||
347 | it('Should fail without an input file', async function () { | 338 | it('Should fail without an input file', async function () { |
348 | const fields = baseCorrectParams | 339 | const fields = baseCorrectParams |
349 | const attaches = {} | 340 | const attaches = {} |
350 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 341 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
351 | }) | 342 | }) |
352 | 343 | ||
353 | it('Should fail with an incorrect input file', async function () { | 344 | it('Should fail with an incorrect input file', async function () { |
@@ -355,7 +346,7 @@ describe('Test videos API validator', function () { | |||
355 | let attaches = { fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short_fake.webm') } | 346 | let attaches = { fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short_fake.webm') } |
356 | 347 | ||
357 | await checkUploadVideoParam( | 348 | await checkUploadVideoParam( |
358 | server.url, | 349 | server, |
359 | server.accessToken, | 350 | server.accessToken, |
360 | { ...fields, ...attaches }, | 351 | { ...fields, ...attaches }, |
361 | HttpStatusCode.UNPROCESSABLE_ENTITY_422, | 352 | HttpStatusCode.UNPROCESSABLE_ENTITY_422, |
@@ -364,7 +355,7 @@ describe('Test videos API validator', function () { | |||
364 | 355 | ||
365 | attaches = { fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mkv') } | 356 | attaches = { fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mkv') } |
366 | await checkUploadVideoParam( | 357 | await checkUploadVideoParam( |
367 | server.url, | 358 | server, |
368 | server.accessToken, | 359 | server.accessToken, |
369 | { ...fields, ...attaches }, | 360 | { ...fields, ...attaches }, |
370 | HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415, | 361 | HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415, |
@@ -379,7 +370,7 @@ describe('Test videos API validator', function () { | |||
379 | fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') | 370 | fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') |
380 | } | 371 | } |
381 | 372 | ||
382 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 373 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
383 | }) | 374 | }) |
384 | 375 | ||
385 | it('Should fail with a big thumbnail file', async function () { | 376 | it('Should fail with a big thumbnail file', async function () { |
@@ -389,7 +380,7 @@ describe('Test videos API validator', function () { | |||
389 | fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') | 380 | fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') |
390 | } | 381 | } |
391 | 382 | ||
392 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 383 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
393 | }) | 384 | }) |
394 | 385 | ||
395 | it('Should fail with an incorrect preview file', async function () { | 386 | it('Should fail with an incorrect preview file', async function () { |
@@ -399,7 +390,7 @@ describe('Test videos API validator', function () { | |||
399 | fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') | 390 | fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') |
400 | } | 391 | } |
401 | 392 | ||
402 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 393 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
403 | }) | 394 | }) |
404 | 395 | ||
405 | it('Should fail with a big preview file', async function () { | 396 | it('Should fail with a big preview file', async function () { |
@@ -409,17 +400,17 @@ describe('Test videos API validator', function () { | |||
409 | fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') | 400 | fixture: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') |
410 | } | 401 | } |
411 | 402 | ||
412 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) | 403 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.BAD_REQUEST_400, mode) |
413 | }) | 404 | }) |
414 | 405 | ||
415 | it('Should report the appropriate error', async function () { | 406 | it('Should report the appropriate error', async function () { |
416 | const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) }) | 407 | const fields = { ...baseCorrectParams, language: 'a'.repeat(15) } |
417 | const attaches = baseCorrectAttaches | 408 | const attaches = baseCorrectAttaches |
418 | 409 | ||
419 | const attributes = { ...fields, ...attaches } | 410 | const attributes = { ...fields, ...attaches } |
420 | const res = await checkUploadVideoParam(server.url, server.accessToken, attributes, HttpStatusCode.BAD_REQUEST_400, mode) | 411 | const body = await checkUploadVideoParam(server, server.accessToken, attributes, HttpStatusCode.BAD_REQUEST_400, mode) |
421 | 412 | ||
422 | const error = res.body as PeerTubeProblemDocument | 413 | const error = body as unknown as PeerTubeProblemDocument |
423 | 414 | ||
424 | if (mode === 'legacy') { | 415 | if (mode === 'legacy') { |
425 | expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/uploadLegacy') | 416 | expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/uploadLegacy') |
@@ -444,23 +435,27 @@ describe('Test videos API validator', function () { | |||
444 | 435 | ||
445 | { | 436 | { |
446 | const attaches = baseCorrectAttaches | 437 | const attaches = baseCorrectAttaches |
447 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode) | 438 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode) |
448 | } | 439 | } |
449 | 440 | ||
450 | { | 441 | { |
451 | const attaches = immutableAssign(baseCorrectAttaches, { | 442 | const attaches = { |
443 | ...baseCorrectAttaches, | ||
444 | |||
452 | videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') | 445 | videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4') |
453 | }) | 446 | } |
454 | 447 | ||
455 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode) | 448 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode) |
456 | } | 449 | } |
457 | 450 | ||
458 | { | 451 | { |
459 | const attaches = immutableAssign(baseCorrectAttaches, { | 452 | const attaches = { |
453 | ...baseCorrectAttaches, | ||
454 | |||
460 | videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.ogv') | 455 | videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.ogv') |
461 | }) | 456 | } |
462 | 457 | ||
463 | await checkUploadVideoParam(server.url, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode) | 458 | await checkUploadVideoParam(server, server.accessToken, { ...fields, ...attaches }, HttpStatusCode.OK_200, mode) |
464 | } | 459 | } |
465 | }) | 460 | }) |
466 | } | 461 | } |
@@ -489,8 +484,8 @@ describe('Test videos API validator', function () { | |||
489 | } | 484 | } |
490 | 485 | ||
491 | before(async function () { | 486 | before(async function () { |
492 | const res = await getVideosList(server.url) | 487 | const { data } = await server.videos.list() |
493 | video = res.body.data[0] | 488 | video = data[0] |
494 | }) | 489 | }) |
495 | 490 | ||
496 | it('Should fail with nothing', async function () { | 491 | it('Should fail with nothing', async function () { |
@@ -511,84 +506,84 @@ describe('Test videos API validator', function () { | |||
511 | path: path + '4da6fde3-88f7-4d16-b119-108df5630b06', | 506 | path: path + '4da6fde3-88f7-4d16-b119-108df5630b06', |
512 | token: server.accessToken, | 507 | token: server.accessToken, |
513 | fields, | 508 | fields, |
514 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 509 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
515 | }) | 510 | }) |
516 | }) | 511 | }) |
517 | 512 | ||
518 | it('Should fail with a long name', async function () { | 513 | it('Should fail with a long name', async function () { |
519 | const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) }) | 514 | const fields = { ...baseCorrectParams, name: 'super'.repeat(65) } |
520 | 515 | ||
521 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) | 516 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
522 | }) | 517 | }) |
523 | 518 | ||
524 | it('Should fail with a bad category', async function () { | 519 | it('Should fail with a bad category', async function () { |
525 | const fields = immutableAssign(baseCorrectParams, { category: 125 }) | 520 | const fields = { ...baseCorrectParams, category: 125 } |
526 | 521 | ||
527 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) | 522 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
528 | }) | 523 | }) |
529 | 524 | ||
530 | it('Should fail with a bad licence', async function () { | 525 | it('Should fail with a bad licence', async function () { |
531 | const fields = immutableAssign(baseCorrectParams, { licence: 125 }) | 526 | const fields = { ...baseCorrectParams, licence: 125 } |
532 | 527 | ||
533 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) | 528 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
534 | }) | 529 | }) |
535 | 530 | ||
536 | it('Should fail with a bad language', async function () { | 531 | it('Should fail with a bad language', async function () { |
537 | const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) }) | 532 | const fields = { ...baseCorrectParams, language: 'a'.repeat(15) } |
538 | 533 | ||
539 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) | 534 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
540 | }) | 535 | }) |
541 | 536 | ||
542 | it('Should fail with a long description', async function () { | 537 | it('Should fail with a long description', async function () { |
543 | const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) }) | 538 | const fields = { ...baseCorrectParams, description: 'super'.repeat(2500) } |
544 | 539 | ||
545 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) | 540 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
546 | }) | 541 | }) |
547 | 542 | ||
548 | it('Should fail with a long support text', async function () { | 543 | it('Should fail with a long support text', async function () { |
549 | const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) }) | 544 | const fields = { ...baseCorrectParams, support: 'super'.repeat(201) } |
550 | 545 | ||
551 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) | 546 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
552 | }) | 547 | }) |
553 | 548 | ||
554 | it('Should fail with a bad channel', async function () { | 549 | it('Should fail with a bad channel', async function () { |
555 | const fields = immutableAssign(baseCorrectParams, { channelId: 545454 }) | 550 | const fields = { ...baseCorrectParams, channelId: 545454 } |
556 | 551 | ||
557 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) | 552 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
558 | }) | 553 | }) |
559 | 554 | ||
560 | it('Should fail with too many tags', async function () { | 555 | it('Should fail with too many tags', async function () { |
561 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }) | 556 | const fields = { ...baseCorrectParams, tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] } |
562 | 557 | ||
563 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) | 558 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
564 | }) | 559 | }) |
565 | 560 | ||
566 | it('Should fail with a tag length too low', async function () { | 561 | it('Should fail with a tag length too low', async function () { |
567 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] }) | 562 | const fields = { ...baseCorrectParams, tags: [ 'tag1', 't' ] } |
568 | 563 | ||
569 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) | 564 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
570 | }) | 565 | }) |
571 | 566 | ||
572 | it('Should fail with a tag length too big', async function () { | 567 | 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' ] }) | 568 | const fields = { ...baseCorrectParams, tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] } |
574 | 569 | ||
575 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) | 570 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
576 | }) | 571 | }) |
577 | 572 | ||
578 | it('Should fail with a bad schedule update (miss updateAt)', async function () { | 573 | it('Should fail with a bad schedule update (miss updateAt)', async function () { |
579 | const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } }) | 574 | const fields = { ...baseCorrectParams, scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } } |
580 | 575 | ||
581 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) | 576 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
582 | }) | 577 | }) |
583 | 578 | ||
584 | it('Should fail with a bad schedule update (wrong updateAt)', async function () { | 579 | it('Should fail with a bad schedule update (wrong updateAt)', async function () { |
585 | const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { updateAt: 'toto', privacy: VideoPrivacy.PUBLIC } }) | 580 | const fields = { ...baseCorrectParams, scheduleUpdate: { updateAt: 'toto', privacy: VideoPrivacy.PUBLIC } } |
586 | 581 | ||
587 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) | 582 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
588 | }) | 583 | }) |
589 | 584 | ||
590 | it('Should fail with a bad originally published at param', async function () { | 585 | it('Should fail with a bad originally published at param', async function () { |
591 | const fields = immutableAssign(baseCorrectParams, { originallyPublishedAt: 'toto' }) | 586 | const fields = { ...baseCorrectParams, originallyPublishedAt: 'toto' } |
592 | 587 | ||
593 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) | 588 | await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
594 | }) | 589 | }) |
@@ -665,14 +660,14 @@ describe('Test videos API validator', function () { | |||
665 | path: path + video.shortUUID, | 660 | path: path + video.shortUUID, |
666 | token: userAccessToken, | 661 | token: userAccessToken, |
667 | fields, | 662 | fields, |
668 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 663 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
669 | }) | 664 | }) |
670 | }) | 665 | }) |
671 | 666 | ||
672 | it('Should fail with a video of another server') | 667 | it('Should fail with a video of another server') |
673 | 668 | ||
674 | it('Shoud report the appropriate error', async function () { | 669 | it('Shoud report the appropriate error', async function () { |
675 | const fields = immutableAssign(baseCorrectParams, { licence: 125 }) | 670 | const fields = { ...baseCorrectParams, licence: 125 } |
676 | 671 | ||
677 | const res = await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) | 672 | const res = await makePutBodyRequest({ url: server.url, path: path + video.shortUUID, token: server.accessToken, fields }) |
678 | const error = res.body as PeerTubeProblemDocument | 673 | const error = res.body as PeerTubeProblemDocument |
@@ -697,7 +692,7 @@ describe('Test videos API validator', function () { | |||
697 | path: path + video.shortUUID, | 692 | path: path + video.shortUUID, |
698 | token: server.accessToken, | 693 | token: server.accessToken, |
699 | fields, | 694 | fields, |
700 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 695 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
701 | }) | 696 | }) |
702 | }) | 697 | }) |
703 | }) | 698 | }) |
@@ -707,7 +702,7 @@ describe('Test videos API validator', function () { | |||
707 | const res = await makeGetRequest({ | 702 | const res = await makeGetRequest({ |
708 | url: server.url, | 703 | url: server.url, |
709 | path, | 704 | path, |
710 | statusCodeExpected: HttpStatusCode.OK_200 | 705 | expectedStatus: HttpStatusCode.OK_200 |
711 | }) | 706 | }) |
712 | 707 | ||
713 | expect(res.body.data).to.be.an('array') | 708 | expect(res.body.data).to.be.an('array') |
@@ -715,16 +710,16 @@ describe('Test videos API validator', function () { | |||
715 | }) | 710 | }) |
716 | 711 | ||
717 | it('Should fail without a correct uuid', async function () { | 712 | it('Should fail without a correct uuid', async function () { |
718 | await getVideo(server.url, 'coucou', HttpStatusCode.BAD_REQUEST_400) | 713 | await server.videos.get({ id: 'coucou', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
719 | }) | 714 | }) |
720 | 715 | ||
721 | it('Should return 404 with an incorrect video', async function () { | 716 | it('Should return 404 with an incorrect video', async function () { |
722 | await getVideo(server.url, '4da6fde3-88f7-4d16-b119-108df5630b06', HttpStatusCode.NOT_FOUND_404) | 717 | await server.videos.get({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 }) |
723 | }) | 718 | }) |
724 | 719 | ||
725 | it('Shoud report the appropriate error', async function () { | 720 | it('Shoud report the appropriate error', async function () { |
726 | const res = await getVideo(server.url, 'hi', HttpStatusCode.BAD_REQUEST_400) | 721 | const body = await server.videos.get({ id: 'hi', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
727 | const error = res.body as PeerTubeProblemDocument | 722 | const error = body as unknown as PeerTubeProblemDocument |
728 | 723 | ||
729 | expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/getVideo') | 724 | expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/getVideo') |
730 | 725 | ||
@@ -739,16 +734,16 @@ describe('Test videos API validator', function () { | |||
739 | }) | 734 | }) |
740 | 735 | ||
741 | it('Should succeed with the correct parameters', async function () { | 736 | it('Should succeed with the correct parameters', async function () { |
742 | await getVideo(server.url, video.shortUUID) | 737 | await server.videos.get({ id: video.shortUUID }) |
743 | }) | 738 | }) |
744 | }) | 739 | }) |
745 | 740 | ||
746 | describe('When rating a video', function () { | 741 | describe('When rating a video', function () { |
747 | let videoId | 742 | let videoId: number |
748 | 743 | ||
749 | before(async function () { | 744 | before(async function () { |
750 | const res = await getVideosList(server.url) | 745 | const { data } = await server.videos.list() |
751 | videoId = res.body.data[0].id | 746 | videoId = data[0].id |
752 | }) | 747 | }) |
753 | 748 | ||
754 | it('Should fail without a valid uuid', async function () { | 749 | it('Should fail without a valid uuid', async function () { |
@@ -767,7 +762,7 @@ describe('Test videos API validator', function () { | |||
767 | path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/rate', | 762 | path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/rate', |
768 | token: server.accessToken, | 763 | token: server.accessToken, |
769 | fields, | 764 | fields, |
770 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 765 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
771 | }) | 766 | }) |
772 | }) | 767 | }) |
773 | 768 | ||
@@ -787,7 +782,7 @@ describe('Test videos API validator', function () { | |||
787 | path: path + videoId + '/rate', | 782 | path: path + videoId + '/rate', |
788 | token: server.accessToken, | 783 | token: server.accessToken, |
789 | fields, | 784 | fields, |
790 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 785 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
791 | }) | 786 | }) |
792 | }) | 787 | }) |
793 | }) | 788 | }) |
@@ -797,27 +792,27 @@ describe('Test videos API validator', function () { | |||
797 | await makeDeleteRequest({ | 792 | await makeDeleteRequest({ |
798 | url: server.url, | 793 | url: server.url, |
799 | path, | 794 | path, |
800 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 795 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
801 | }) | 796 | }) |
802 | }) | 797 | }) |
803 | 798 | ||
804 | it('Should fail without a correct uuid', async function () { | 799 | it('Should fail without a correct uuid', async function () { |
805 | await removeVideo(server.url, server.accessToken, 'hello', HttpStatusCode.BAD_REQUEST_400) | 800 | await server.videos.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
806 | }) | 801 | }) |
807 | 802 | ||
808 | it('Should fail with a video which does not exist', async function () { | 803 | it('Should fail with a video which does not exist', async function () { |
809 | await removeVideo(server.url, server.accessToken, '4da6fde3-88f7-4d16-b119-108df5630b06', HttpStatusCode.NOT_FOUND_404) | 804 | await server.videos.remove({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 }) |
810 | }) | 805 | }) |
811 | 806 | ||
812 | it('Should fail with a video of another user without the appropriate right', async function () { | 807 | it('Should fail with a video of another user without the appropriate right', async function () { |
813 | await removeVideo(server.url, userAccessToken, video.uuid, HttpStatusCode.FORBIDDEN_403) | 808 | await server.videos.remove({ token: userAccessToken, id: video.uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
814 | }) | 809 | }) |
815 | 810 | ||
816 | it('Should fail with a video of another server') | 811 | it('Should fail with a video of another server') |
817 | 812 | ||
818 | it('Shoud report the appropriate error', async function () { | 813 | it('Shoud report the appropriate error', async function () { |
819 | const res = await removeVideo(server.url, server.accessToken, 'hello', HttpStatusCode.BAD_REQUEST_400) | 814 | const body = await server.videos.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
820 | const error = res.body as PeerTubeProblemDocument | 815 | const error = body as PeerTubeProblemDocument |
821 | 816 | ||
822 | expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/delVideo') | 817 | expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/delVideo') |
823 | 818 | ||
@@ -832,7 +827,7 @@ describe('Test videos API validator', function () { | |||
832 | }) | 827 | }) |
833 | 828 | ||
834 | it('Should succeed with the correct parameters', async function () { | 829 | it('Should succeed with the correct parameters', async function () { |
835 | await removeVideo(server.url, server.accessToken, video.uuid) | 830 | await server.videos.remove({ id: video.uuid }) |
836 | }) | 831 | }) |
837 | }) | 832 | }) |
838 | 833 | ||