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.ts146
1 files changed, 67 insertions, 79 deletions
diff --git a/server/tests/api/check-params/abuses.ts b/server/tests/api/check-params/abuses.ts
index 2054776cc..e158e50dc 100644
--- a/server/tests/api/check-params/abuses.ts
+++ b/server/tests/api/check-params/abuses.ts
@@ -1,46 +1,40 @@
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 { AbuseCreate, AbuseState } from '@shared/models' 4import { HttpStatusCode } from '@shared/core-utils'
5import { 5import {
6 addAbuseMessage, 6 AbusesCommand,
7 checkBadCountPagination,
8 checkBadSortPagination,
9 checkBadStartPagination,
7 cleanupTests, 10 cleanupTests,
8 createUser, 11 createUser,
9 deleteAbuse,
10 deleteAbuseMessage,
11 doubleFollow, 12 doubleFollow,
12 flushAndRunServer, 13 flushAndRunServer,
13 generateUserAccessToken, 14 generateUserAccessToken,
14 getAdminAbusesList,
15 getVideoIdFromUUID, 15 getVideoIdFromUUID,
16 listAbuseMessages,
17 makeGetRequest, 16 makeGetRequest,
18 makePostBodyRequest, 17 makePostBodyRequest,
19 reportAbuse,
20 ServerInfo, 18 ServerInfo,
21 setAccessTokensToServers, 19 setAccessTokensToServers,
22 updateAbuse,
23 uploadVideo, 20 uploadVideo,
24 userLogin, 21 userLogin,
25 waitJobs 22 waitJobs
26} from '../../../../shared/extra-utils' 23} from '@shared/extra-utils'
27import { 24import { AbuseCreate, AbuseState } from '@shared/models'
28 checkBadCountPagination,
29 checkBadSortPagination,
30 checkBadStartPagination
31} from '../../../../shared/extra-utils/requests/check-api-params'
32import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
33 25
34describe('Test abuses API validators', function () { 26describe('Test abuses API validators', function () {
35 const basePath = '/api/v1/abuses/' 27 const basePath = '/api/v1/abuses/'
36 28
37 let server: ServerInfo 29 let server: ServerInfo
38 30
39 let userAccessToken = '' 31 let userToken = ''
40 let userAccessToken2 = '' 32 let userToken2 = ''
41 let abuseId: number 33 let abuseId: number
42 let messageId: number 34 let messageId: number
43 35
36 let command: AbusesCommand
37
44 // --------------------------------------------------------------- 38 // ---------------------------------------------------------------
45 39
46 before(async function () { 40 before(async function () {
@@ -53,14 +47,14 @@ describe('Test abuses API validators', function () {
53 const username = 'user1' 47 const username = 'user1'
54 const password = 'my super password' 48 const password = 'my super password'
55 await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password }) 49 await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password })
56 userAccessToken = await userLogin(server, { username, password }) 50 userToken = await userLogin(server, { username, password })
57 51
58 { 52 userToken2 = await generateUserAccessToken(server, 'user_2')
59 userAccessToken2 = await generateUserAccessToken(server, 'user_2')
60 }
61 53
62 const res = await uploadVideo(server.url, server.accessToken, {}) 54 const res = await uploadVideo(server.url, server.accessToken, {})
63 server.video = res.body.video 55 server.video = res.body.video
56
57 command = server.abusesCommand
64 }) 58 })
65 59
66 describe('When listing abuses for admins', function () { 60 describe('When listing abuses for admins', function () {
@@ -90,7 +84,7 @@ describe('Test abuses API validators', function () {
90 await makeGetRequest({ 84 await makeGetRequest({
91 url: server.url, 85 url: server.url,
92 path, 86 path,
93 token: userAccessToken, 87 token: userToken,
94 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 88 statusCodeExpected: HttpStatusCode.FORBIDDEN_403
95 }) 89 })
96 }) 90 })
@@ -134,15 +128,15 @@ describe('Test abuses API validators', function () {
134 const path = '/api/v1/users/me/abuses' 128 const path = '/api/v1/users/me/abuses'
135 129
136 it('Should fail with a bad start pagination', async function () { 130 it('Should fail with a bad start pagination', async function () {
137 await checkBadStartPagination(server.url, path, userAccessToken) 131 await checkBadStartPagination(server.url, path, userToken)
138 }) 132 })
139 133
140 it('Should fail with a bad count pagination', async function () { 134 it('Should fail with a bad count pagination', async function () {
141 await checkBadCountPagination(server.url, path, userAccessToken) 135 await checkBadCountPagination(server.url, path, userToken)
142 }) 136 })
143 137
144 it('Should fail with an incorrect sort', async function () { 138 it('Should fail with an incorrect sort', async function () {
145 await checkBadSortPagination(server.url, path, userAccessToken) 139 await checkBadSortPagination(server.url, path, userToken)
146 }) 140 })
147 141
148 it('Should fail with a non authenticated user', async function () { 142 it('Should fail with a non authenticated user', async function () {
@@ -154,12 +148,12 @@ describe('Test abuses API validators', function () {
154 }) 148 })
155 149
156 it('Should fail with a bad id filter', async function () { 150 it('Should fail with a bad id filter', async function () {
157 await makeGetRequest({ url: server.url, path, token: userAccessToken, query: { id: 'toto' } }) 151 await makeGetRequest({ url: server.url, path, token: userToken, query: { id: 'toto' } })
158 }) 152 })
159 153
160 it('Should fail with a bad state filter', async function () { 154 it('Should fail with a bad state filter', async function () {
161 await makeGetRequest({ url: server.url, path, token: userAccessToken, query: { state: 'toto' } }) 155 await makeGetRequest({ url: server.url, path, token: userToken, query: { state: 'toto' } })
162 await makeGetRequest({ url: server.url, path, token: userAccessToken, query: { state: 0 } }) 156 await makeGetRequest({ url: server.url, path, token: userToken, query: { state: 0 } })
163 }) 157 })
164 158
165 it('Should succeed with the correct params', async function () { 159 it('Should succeed with the correct params', async function () {
@@ -168,7 +162,7 @@ describe('Test abuses API validators', function () {
168 state: 2 162 state: 2
169 } 163 }
170 164
171 await makeGetRequest({ url: server.url, path, token: userAccessToken, query, statusCodeExpected: HttpStatusCode.OK_200 }) 165 await makeGetRequest({ url: server.url, path, token: userToken, query, statusCodeExpected: HttpStatusCode.OK_200 })
172 }) 166 })
173 }) 167 })
174 168
@@ -177,12 +171,12 @@ describe('Test abuses API validators', function () {
177 171
178 it('Should fail with nothing', async function () { 172 it('Should fail with nothing', async function () {
179 const fields = {} 173 const fields = {}
180 await makePostBodyRequest({ url: server.url, path, token: userAccessToken, fields }) 174 await makePostBodyRequest({ url: server.url, path, token: userToken, fields })
181 }) 175 })
182 176
183 it('Should fail with a wrong video', async function () { 177 it('Should fail with a wrong video', async function () {
184 const fields = { video: { id: 'blabla' }, reason: 'my super reason' } 178 const fields = { video: { id: 'blabla' }, reason: 'my super reason' }
185 await makePostBodyRequest({ url: server.url, path: path, token: userAccessToken, fields }) 179 await makePostBodyRequest({ url: server.url, path: path, token: userToken, fields })
186 }) 180 })
187 181
188 it('Should fail with an unknown video', async function () { 182 it('Should fail with an unknown video', async function () {
@@ -190,7 +184,7 @@ describe('Test abuses API validators', function () {
190 await makePostBodyRequest({ 184 await makePostBodyRequest({
191 url: server.url, 185 url: server.url,
192 path, 186 path,
193 token: userAccessToken, 187 token: userToken,
194 fields, 188 fields,
195 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 189 statusCodeExpected: HttpStatusCode.NOT_FOUND_404
196 }) 190 })
@@ -198,7 +192,7 @@ describe('Test abuses API validators', function () {
198 192
199 it('Should fail with a wrong comment', async function () { 193 it('Should fail with a wrong comment', async function () {
200 const fields = { comment: { id: 'blabla' }, reason: 'my super reason' } 194 const fields = { comment: { id: 'blabla' }, reason: 'my super reason' }
201 await makePostBodyRequest({ url: server.url, path: path, token: userAccessToken, fields }) 195 await makePostBodyRequest({ url: server.url, path: path, token: userToken, fields })
202 }) 196 })
203 197
204 it('Should fail with an unknown comment', async function () { 198 it('Should fail with an unknown comment', async function () {
@@ -206,7 +200,7 @@ describe('Test abuses API validators', function () {
206 await makePostBodyRequest({ 200 await makePostBodyRequest({
207 url: server.url, 201 url: server.url,
208 path, 202 path,
209 token: userAccessToken, 203 token: userToken,
210 fields, 204 fields,
211 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 205 statusCodeExpected: HttpStatusCode.NOT_FOUND_404
212 }) 206 })
@@ -214,7 +208,7 @@ describe('Test abuses API validators', function () {
214 208
215 it('Should fail with a wrong account', async function () { 209 it('Should fail with a wrong account', async function () {
216 const fields = { account: { id: 'blabla' }, reason: 'my super reason' } 210 const fields = { account: { id: 'blabla' }, reason: 'my super reason' }
217 await makePostBodyRequest({ url: server.url, path: path, token: userAccessToken, fields }) 211 await makePostBodyRequest({ url: server.url, path: path, token: userToken, fields })
218 }) 212 })
219 213
220 it('Should fail with an unknown account', async function () { 214 it('Should fail with an unknown account', async function () {
@@ -222,7 +216,7 @@ describe('Test abuses API validators', function () {
222 await makePostBodyRequest({ 216 await makePostBodyRequest({
223 url: server.url, 217 url: server.url,
224 path, 218 path,
225 token: userAccessToken, 219 token: userToken,
226 fields, 220 fields,
227 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 221 statusCodeExpected: HttpStatusCode.NOT_FOUND_404
228 }) 222 })
@@ -233,7 +227,7 @@ describe('Test abuses API validators', function () {
233 await makePostBodyRequest({ 227 await makePostBodyRequest({
234 url: server.url, 228 url: server.url,
235 path, 229 path,
236 token: userAccessToken, 230 token: userToken,
237 fields, 231 fields,
238 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 232 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
239 }) 233 })
@@ -248,13 +242,13 @@ describe('Test abuses API validators', function () {
248 it('Should fail with a reason too short', async function () { 242 it('Should fail with a reason too short', async function () {
249 const fields = { video: { id: server.video.id }, reason: 'h' } 243 const fields = { video: { id: server.video.id }, reason: 'h' }
250 244
251 await makePostBodyRequest({ url: server.url, path, token: userAccessToken, fields }) 245 await makePostBodyRequest({ url: server.url, path, token: userToken, fields })
252 }) 246 })
253 247
254 it('Should fail with a too big reason', async function () { 248 it('Should fail with a too big reason', async function () {
255 const fields = { video: { id: server.video.id }, reason: 'super'.repeat(605) } 249 const fields = { video: { id: server.video.id }, reason: 'super'.repeat(605) }
256 250
257 await makePostBodyRequest({ url: server.url, path, token: userAccessToken, fields }) 251 await makePostBodyRequest({ url: server.url, path, token: userToken, fields })
258 }) 252 })
259 253
260 it('Should succeed with the correct parameters (basic)', async function () { 254 it('Should succeed with the correct parameters (basic)', async function () {
@@ -263,7 +257,7 @@ describe('Test abuses API validators', function () {
263 const res = await makePostBodyRequest({ 257 const res = await makePostBodyRequest({
264 url: server.url, 258 url: server.url,
265 path, 259 path,
266 token: userAccessToken, 260 token: userToken,
267 fields, 261 fields,
268 statusCodeExpected: HttpStatusCode.OK_200 262 statusCodeExpected: HttpStatusCode.OK_200
269 }) 263 })
@@ -273,19 +267,19 @@ describe('Test abuses API validators', function () {
273 it('Should fail with a wrong predefined reason', async function () { 267 it('Should fail with a wrong predefined reason', async function () {
274 const fields = { video: { id: server.video.id }, reason: 'my super reason', predefinedReasons: [ 'wrongPredefinedReason' ] } 268 const fields = { video: { id: server.video.id }, reason: 'my super reason', predefinedReasons: [ 'wrongPredefinedReason' ] }
275 269
276 await makePostBodyRequest({ url: server.url, path, token: userAccessToken, fields }) 270 await makePostBodyRequest({ url: server.url, path, token: userToken, fields })
277 }) 271 })
278 272
279 it('Should fail with negative timestamps', async function () { 273 it('Should fail with negative timestamps', async function () {
280 const fields = { video: { id: server.video.id, startAt: -1 }, reason: 'my super reason' } 274 const fields = { video: { id: server.video.id, startAt: -1 }, reason: 'my super reason' }
281 275
282 await makePostBodyRequest({ url: server.url, path, token: userAccessToken, fields }) 276 await makePostBodyRequest({ url: server.url, path, token: userToken, fields })
283 }) 277 })
284 278
285 it('Should fail mith misordered startAt/endAt', async function () { 279 it('Should fail mith misordered startAt/endAt', async function () {
286 const fields = { video: { id: server.video.id, startAt: 5, endAt: 1 }, reason: 'my super reason' } 280 const fields = { video: { id: server.video.id, startAt: 5, endAt: 1 }, reason: 'my super reason' }
287 281
288 await makePostBodyRequest({ url: server.url, path, token: userAccessToken, fields }) 282 await makePostBodyRequest({ url: server.url, path, token: userToken, fields })
289 }) 283 })
290 284
291 it('Should succeed with the corret parameters (advanced)', async function () { 285 it('Should succeed with the corret parameters (advanced)', async function () {
@@ -299,37 +293,37 @@ describe('Test abuses API validators', function () {
299 predefinedReasons: [ 'serverRules' ] 293 predefinedReasons: [ 'serverRules' ]
300 } 294 }
301 295
302 await makePostBodyRequest({ url: server.url, path, token: userAccessToken, fields, statusCodeExpected: HttpStatusCode.OK_200 }) 296 await makePostBodyRequest({ url: server.url, path, token: userToken, fields, statusCodeExpected: HttpStatusCode.OK_200 })
303 }) 297 })
304 }) 298 })
305 299
306 describe('When updating an abuse', function () { 300 describe('When updating an abuse', function () {
307 301
308 it('Should fail with a non authenticated user', async function () { 302 it('Should fail with a non authenticated user', async function () {
309 await updateAbuse(server.url, 'blabla', abuseId, {}, HttpStatusCode.UNAUTHORIZED_401) 303 await command.update({ token: 'blabla', abuseId, body: {}, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
310 }) 304 })
311 305
312 it('Should fail with a non admin user', async function () { 306 it('Should fail with a non admin user', async function () {
313 await updateAbuse(server.url, userAccessToken, abuseId, {}, HttpStatusCode.FORBIDDEN_403) 307 await command.update({ token: userToken, abuseId, body: {}, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
314 }) 308 })
315 309
316 it('Should fail with a bad abuse id', async function () { 310 it('Should fail with a bad abuse id', async function () {
317 await updateAbuse(server.url, server.accessToken, 45, {}, HttpStatusCode.NOT_FOUND_404) 311 await command.update({ abuseId: 45, body: {}, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
318 }) 312 })
319 313
320 it('Should fail with a bad state', async function () { 314 it('Should fail with a bad state', async function () {
321 const body = { state: 5 } 315 const body = { state: 5 }
322 await updateAbuse(server.url, server.accessToken, abuseId, body, HttpStatusCode.BAD_REQUEST_400) 316 await command.update({ abuseId, body, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
323 }) 317 })
324 318
325 it('Should fail with a bad moderation comment', async function () { 319 it('Should fail with a bad moderation comment', async function () {
326 const body = { moderationComment: 'b'.repeat(3001) } 320 const body = { moderationComment: 'b'.repeat(3001) }
327 await updateAbuse(server.url, server.accessToken, abuseId, body, HttpStatusCode.BAD_REQUEST_400) 321 await command.update({ abuseId, body, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
328 }) 322 })
329 323
330 it('Should succeed with the correct params', async function () { 324 it('Should succeed with the correct params', async function () {
331 const body = { state: AbuseState.ACCEPTED } 325 const body = { state: AbuseState.ACCEPTED }
332 await updateAbuse(server.url, server.accessToken, abuseId, body) 326 await command.update({ abuseId, body })
333 }) 327 })
334 }) 328 })
335 329
@@ -337,23 +331,23 @@ describe('Test abuses API validators', function () {
337 const message = 'my super message' 331 const message = 'my super message'
338 332
339 it('Should fail with an invalid abuse id', async function () { 333 it('Should fail with an invalid abuse id', async function () {
340 await addAbuseMessage(server.url, userAccessToken2, 888, message, HttpStatusCode.NOT_FOUND_404) 334 await command.addMessage({ token: userToken2, abuseId: 888, message, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
341 }) 335 })
342 336
343 it('Should fail with a non authenticated user', async function () { 337 it('Should fail with a non authenticated user', async function () {
344 await addAbuseMessage(server.url, 'fake_token', abuseId, message, HttpStatusCode.UNAUTHORIZED_401) 338 await command.addMessage({ token: 'fake_token', abuseId, message, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
345 }) 339 })
346 340
347 it('Should fail with an invalid logged in user', async function () { 341 it('Should fail with an invalid logged in user', async function () {
348 await addAbuseMessage(server.url, userAccessToken2, abuseId, message, HttpStatusCode.FORBIDDEN_403) 342 await command.addMessage({ token: userToken2, abuseId, message, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
349 }) 343 })
350 344
351 it('Should fail with an invalid message', async function () { 345 it('Should fail with an invalid message', async function () {
352 await addAbuseMessage(server.url, userAccessToken, abuseId, 'a'.repeat(5000), HttpStatusCode.BAD_REQUEST_400) 346 await command.addMessage({ token: userToken, abuseId, message: 'a'.repeat(5000), expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
353 }) 347 })
354 348
355 it('Should suceed with the correct params', async function () { 349 it('Should suceed with the correct params', async function () {
356 const res = await addAbuseMessage(server.url, userAccessToken, abuseId, message) 350 const res = await command.addMessage({ token: userToken, abuseId, message })
357 messageId = res.body.abuseMessage.id 351 messageId = res.body.abuseMessage.id
358 }) 352 })
359 }) 353 })
@@ -361,61 +355,60 @@ describe('Test abuses API validators', function () {
361 describe('When listing abuse messages', function () { 355 describe('When listing abuse messages', function () {
362 356
363 it('Should fail with an invalid abuse id', async function () { 357 it('Should fail with an invalid abuse id', async function () {
364 await listAbuseMessages(server.url, userAccessToken, 888, HttpStatusCode.NOT_FOUND_404) 358 await command.listMessages({ token: userToken, abuseId: 888, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
365 }) 359 })
366 360
367 it('Should fail with a non authenticated user', async function () { 361 it('Should fail with a non authenticated user', async function () {
368 await listAbuseMessages(server.url, 'fake_token', abuseId, HttpStatusCode.UNAUTHORIZED_401) 362 await command.listMessages({ token: 'fake_token', abuseId, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
369 }) 363 })
370 364
371 it('Should fail with an invalid logged in user', async function () { 365 it('Should fail with an invalid logged in user', async function () {
372 await listAbuseMessages(server.url, userAccessToken2, abuseId, HttpStatusCode.FORBIDDEN_403) 366 await command.listMessages({ token: userToken2, abuseId, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
373 }) 367 })
374 368
375 it('Should succeed with the correct params', async function () { 369 it('Should succeed with the correct params', async function () {
376 await listAbuseMessages(server.url, userAccessToken, abuseId) 370 await command.listMessages({ token: userToken, abuseId })
377 }) 371 })
378 }) 372 })
379 373
380 describe('When deleting an abuse message', function () { 374 describe('When deleting an abuse message', function () {
381
382 it('Should fail with an invalid abuse id', async function () { 375 it('Should fail with an invalid abuse id', async function () {
383 await deleteAbuseMessage(server.url, userAccessToken, 888, messageId, HttpStatusCode.NOT_FOUND_404) 376 await command.deleteMessage({ token: userToken, abuseId: 888, messageId, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
384 }) 377 })
385 378
386 it('Should fail with an invalid message id', async function () { 379 it('Should fail with an invalid message id', async function () {
387 await deleteAbuseMessage(server.url, userAccessToken, abuseId, 888, HttpStatusCode.NOT_FOUND_404) 380 await command.deleteMessage({ token: userToken, abuseId, messageId: 888, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
388 }) 381 })
389 382
390 it('Should fail with a non authenticated user', async function () { 383 it('Should fail with a non authenticated user', async function () {
391 await deleteAbuseMessage(server.url, 'fake_token', abuseId, messageId, HttpStatusCode.UNAUTHORIZED_401) 384 await command.deleteMessage({ token: 'fake_token', abuseId, messageId, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
392 }) 385 })
393 386
394 it('Should fail with an invalid logged in user', async function () { 387 it('Should fail with an invalid logged in user', async function () {
395 await deleteAbuseMessage(server.url, userAccessToken2, abuseId, messageId, HttpStatusCode.FORBIDDEN_403) 388 await command.deleteMessage({ token: userToken2, abuseId, messageId, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
396 }) 389 })
397 390
398 it('Should succeed with the correct params', async function () { 391 it('Should succeed with the correct params', async function () {
399 await deleteAbuseMessage(server.url, userAccessToken, abuseId, messageId) 392 await command.deleteMessage({ token: userToken, abuseId, messageId })
400 }) 393 })
401 }) 394 })
402 395
403 describe('When deleting a video abuse', function () { 396 describe('When deleting a video abuse', function () {
404 397
405 it('Should fail with a non authenticated user', async function () { 398 it('Should fail with a non authenticated user', async function () {
406 await deleteAbuse(server.url, 'blabla', abuseId, HttpStatusCode.UNAUTHORIZED_401) 399 await command.delete({ token: 'blabla', abuseId, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
407 }) 400 })
408 401
409 it('Should fail with a non admin user', async function () { 402 it('Should fail with a non admin user', async function () {
410 await deleteAbuse(server.url, userAccessToken, abuseId, HttpStatusCode.FORBIDDEN_403) 403 await command.delete({ token: userToken, abuseId, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
411 }) 404 })
412 405
413 it('Should fail with a bad abuse id', async function () { 406 it('Should fail with a bad abuse id', async function () {
414 await deleteAbuse(server.url, server.accessToken, 45, HttpStatusCode.NOT_FOUND_404) 407 await command.delete({ abuseId: 45, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
415 }) 408 })
416 409
417 it('Should succeed with the correct params', async function () { 410 it('Should succeed with the correct params', async function () {
418 await deleteAbuse(server.url, server.accessToken, abuseId) 411 await command.delete({ abuseId })
419 }) 412 })
420 }) 413 })
421 414
@@ -432,25 +425,20 @@ describe('Test abuses API validators', function () {
432 await doubleFollow(anotherServer, server) 425 await doubleFollow(anotherServer, server)
433 426
434 const server2VideoId = await getVideoIdFromUUID(anotherServer.url, server.video.uuid) 427 const server2VideoId = await getVideoIdFromUUID(anotherServer.url, server.video.uuid)
435 await reportAbuse({ 428 await anotherServer.abusesCommand.report({ reason: 'remote server', videoId: server2VideoId })
436 url: anotherServer.url,
437 token: anotherServer.accessToken,
438 reason: 'remote server',
439 videoId: server2VideoId
440 })
441 429
442 await waitJobs([ server, anotherServer ]) 430 await waitJobs([ server, anotherServer ])
443 431
444 const res = await getAdminAbusesList({ url: server.url, token: server.accessToken, sort: '-createdAt' }) 432 const body = await command.getAdminList({ sort: '-createdAt' })
445 remoteAbuseId = res.body.data[0].id 433 remoteAbuseId = body.data[0].id
446 }) 434 })
447 435
448 it('Should fail when listing abuse messages of a remote abuse', async function () { 436 it('Should fail when listing abuse messages of a remote abuse', async function () {
449 await listAbuseMessages(server.url, server.accessToken, remoteAbuseId, HttpStatusCode.BAD_REQUEST_400) 437 await command.listMessages({ abuseId: remoteAbuseId, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
450 }) 438 })
451 439
452 it('Should fail when creating abuse message of a remote abuse', async function () { 440 it('Should fail when creating abuse message of a remote abuse', async function () {
453 await addAbuseMessage(server.url, server.accessToken, remoteAbuseId, 'message', HttpStatusCode.BAD_REQUEST_400) 441 await command.addMessage({ abuseId: remoteAbuseId, message: 'message', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
454 }) 442 })
455 443
456 after(async function () { 444 after(async function () {