aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/follows.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/check-params/follows.ts')
-rw-r--r--server/tests/api/check-params/follows.ts64
1 files changed, 31 insertions, 33 deletions
diff --git a/server/tests/api/check-params/follows.ts b/server/tests/api/check-params/follows.ts
index 0fd2b4925..dfe3f226d 100644
--- a/server/tests/api/check-params/follows.ts
+++ b/server/tests/api/check-params/follows.ts
@@ -1,21 +1,19 @@
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
5import { 4import {
5 checkBadCountPagination,
6 checkBadSortPagination,
7 checkBadStartPagination,
6 cleanupTests, 8 cleanupTests,
7 createSingleServer, 9 createSingleServer,
8 makeDeleteRequest, makeGetRequest, 10 makeDeleteRequest,
11 makeGetRequest,
9 makePostBodyRequest, 12 makePostBodyRequest,
10 PeerTubeServer, 13 PeerTubeServer,
11 setAccessTokensToServers 14 setAccessTokensToServers
12} from '../../../../shared/extra-utils' 15} from '@shared/extra-utils'
13import { 16import { HttpStatusCode } from '@shared/models'
14 checkBadCountPagination,
15 checkBadSortPagination,
16 checkBadStartPagination
17} from '../../../../shared/extra-utils/requests/check-api-params'
18import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
19 17
20describe('Test server follows API validators', function () { 18describe('Test server follows API validators', function () {
21 let server: PeerTubeServer 19 let server: PeerTubeServer
@@ -51,7 +49,7 @@ describe('Test server follows API validators', function () {
51 url: server.url, 49 url: server.url,
52 path, 50 path,
53 token: server.accessToken, 51 token: server.accessToken,
54 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 52 expectedStatus: HttpStatusCode.BAD_REQUEST_400
55 }) 53 })
56 }) 54 })
57 55
@@ -61,7 +59,7 @@ describe('Test server follows API validators', function () {
61 path, 59 path,
62 token: server.accessToken, 60 token: server.accessToken,
63 fields: { hosts: 'localhost:9002' }, 61 fields: { hosts: 'localhost:9002' },
64 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 62 expectedStatus: HttpStatusCode.BAD_REQUEST_400
65 }) 63 })
66 }) 64 })
67 65
@@ -71,7 +69,7 @@ describe('Test server follows API validators', function () {
71 path, 69 path,
72 fields: { hosts: [ 'localhost:9002', 'localhost:coucou' ] }, 70 fields: { hosts: [ 'localhost:9002', 'localhost:coucou' ] },
73 token: server.accessToken, 71 token: server.accessToken,
74 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 72 expectedStatus: HttpStatusCode.BAD_REQUEST_400
75 }) 73 })
76 }) 74 })
77 75
@@ -81,7 +79,7 @@ describe('Test server follows API validators', function () {
81 path, 79 path,
82 fields: { hosts: [ 'localhost:9002', 'http://localhost:9003' ] }, 80 fields: { hosts: [ 'localhost:9002', 'http://localhost:9003' ] },
83 token: server.accessToken, 81 token: server.accessToken,
84 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 82 expectedStatus: HttpStatusCode.BAD_REQUEST_400
85 }) 83 })
86 }) 84 })
87 85
@@ -91,7 +89,7 @@ describe('Test server follows API validators', function () {
91 path, 89 path,
92 fields: { urls: [ 'localhost:9002', 'localhost:9002' ] }, 90 fields: { urls: [ 'localhost:9002', 'localhost:9002' ] },
93 token: server.accessToken, 91 token: server.accessToken,
94 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 92 expectedStatus: HttpStatusCode.BAD_REQUEST_400
95 }) 93 })
96 }) 94 })
97 95
@@ -101,7 +99,7 @@ describe('Test server follows API validators', function () {
101 path, 99 path,
102 fields: { hosts: [ 'localhost:9002' ] }, 100 fields: { hosts: [ 'localhost:9002' ] },
103 token: 'fake_token', 101 token: 'fake_token',
104 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 102 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
105 }) 103 })
106 }) 104 })
107 105
@@ -111,7 +109,7 @@ describe('Test server follows API validators', function () {
111 path, 109 path,
112 fields: { hosts: [ 'localhost:9002' ] }, 110 fields: { hosts: [ 'localhost:9002' ] },
113 token: userAccessToken, 111 token: userAccessToken,
114 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 112 expectedStatus: HttpStatusCode.FORBIDDEN_403
115 }) 113 })
116 }) 114 })
117 }) 115 })
@@ -155,7 +153,7 @@ describe('Test server follows API validators', function () {
155 await makeGetRequest({ 153 await makeGetRequest({
156 url: server.url, 154 url: server.url,
157 path, 155 path,
158 statusCodeExpected: HttpStatusCode.OK_200, 156 expectedStatus: HttpStatusCode.OK_200,
159 query: { 157 query: {
160 state: 'accepted', 158 state: 'accepted',
161 actorType: 'Application' 159 actorType: 'Application'
@@ -204,7 +202,7 @@ describe('Test server follows API validators', function () {
204 await makeGetRequest({ 202 await makeGetRequest({
205 url: server.url, 203 url: server.url,
206 path, 204 path,
207 statusCodeExpected: HttpStatusCode.OK_200, 205 expectedStatus: HttpStatusCode.OK_200,
208 query: { 206 query: {
209 state: 'accepted' 207 state: 'accepted'
210 } 208 }
@@ -220,7 +218,7 @@ describe('Test server follows API validators', function () {
220 url: server.url, 218 url: server.url,
221 path: path + '/toto@localhost:9002', 219 path: path + '/toto@localhost:9002',
222 token: 'fake_token', 220 token: 'fake_token',
223 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 221 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
224 }) 222 })
225 }) 223 })
226 224
@@ -229,7 +227,7 @@ describe('Test server follows API validators', function () {
229 url: server.url, 227 url: server.url,
230 path: path + '/toto@localhost:9002', 228 path: path + '/toto@localhost:9002',
231 token: userAccessToken, 229 token: userAccessToken,
232 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 230 expectedStatus: HttpStatusCode.FORBIDDEN_403
233 }) 231 })
234 }) 232 })
235 233
@@ -238,7 +236,7 @@ describe('Test server follows API validators', function () {
238 url: server.url, 236 url: server.url,
239 path: path + '/toto', 237 path: path + '/toto',
240 token: server.accessToken, 238 token: server.accessToken,
241 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 239 expectedStatus: HttpStatusCode.BAD_REQUEST_400
242 }) 240 })
243 }) 241 })
244 242
@@ -247,7 +245,7 @@ describe('Test server follows API validators', function () {
247 url: server.url, 245 url: server.url,
248 path: path + '/toto@localhost:9003', 246 path: path + '/toto@localhost:9003',
249 token: server.accessToken, 247 token: server.accessToken,
250 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 248 expectedStatus: HttpStatusCode.NOT_FOUND_404
251 }) 249 })
252 }) 250 })
253 }) 251 })
@@ -260,7 +258,7 @@ describe('Test server follows API validators', function () {
260 url: server.url, 258 url: server.url,
261 path: path + '/toto@localhost:9002/accept', 259 path: path + '/toto@localhost:9002/accept',
262 token: 'fake_token', 260 token: 'fake_token',
263 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 261 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
264 }) 262 })
265 }) 263 })
266 264
@@ -269,7 +267,7 @@ describe('Test server follows API validators', function () {
269 url: server.url, 267 url: server.url,
270 path: path + '/toto@localhost:9002/accept', 268 path: path + '/toto@localhost:9002/accept',
271 token: userAccessToken, 269 token: userAccessToken,
272 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 270 expectedStatus: HttpStatusCode.FORBIDDEN_403
273 }) 271 })
274 }) 272 })
275 273
@@ -278,7 +276,7 @@ describe('Test server follows API validators', function () {
278 url: server.url, 276 url: server.url,
279 path: path + '/toto/accept', 277 path: path + '/toto/accept',
280 token: server.accessToken, 278 token: server.accessToken,
281 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 279 expectedStatus: HttpStatusCode.BAD_REQUEST_400
282 }) 280 })
283 }) 281 })
284 282
@@ -287,7 +285,7 @@ describe('Test server follows API validators', function () {
287 url: server.url, 285 url: server.url,
288 path: path + '/toto@localhost:9003/accept', 286 path: path + '/toto@localhost:9003/accept',
289 token: server.accessToken, 287 token: server.accessToken,
290 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 288 expectedStatus: HttpStatusCode.NOT_FOUND_404
291 }) 289 })
292 }) 290 })
293 }) 291 })
@@ -300,7 +298,7 @@ describe('Test server follows API validators', function () {
300 url: server.url, 298 url: server.url,
301 path: path + '/toto@localhost:9002/reject', 299 path: path + '/toto@localhost:9002/reject',
302 token: 'fake_token', 300 token: 'fake_token',
303 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 301 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
304 }) 302 })
305 }) 303 })
306 304
@@ -309,7 +307,7 @@ describe('Test server follows API validators', function () {
309 url: server.url, 307 url: server.url,
310 path: path + '/toto@localhost:9002/reject', 308 path: path + '/toto@localhost:9002/reject',
311 token: userAccessToken, 309 token: userAccessToken,
312 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 310 expectedStatus: HttpStatusCode.FORBIDDEN_403
313 }) 311 })
314 }) 312 })
315 313
@@ -318,7 +316,7 @@ describe('Test server follows API validators', function () {
318 url: server.url, 316 url: server.url,
319 path: path + '/toto/reject', 317 path: path + '/toto/reject',
320 token: server.accessToken, 318 token: server.accessToken,
321 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 319 expectedStatus: HttpStatusCode.BAD_REQUEST_400
322 }) 320 })
323 }) 321 })
324 322
@@ -327,7 +325,7 @@ describe('Test server follows API validators', function () {
327 url: server.url, 325 url: server.url,
328 path: path + '/toto@localhost:9003/reject', 326 path: path + '/toto@localhost:9003/reject',
329 token: server.accessToken, 327 token: server.accessToken,
330 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 328 expectedStatus: HttpStatusCode.NOT_FOUND_404
331 }) 329 })
332 }) 330 })
333 }) 331 })
@@ -340,7 +338,7 @@ describe('Test server follows API validators', function () {
340 url: server.url, 338 url: server.url,
341 path: path + '/localhost:9002', 339 path: path + '/localhost:9002',
342 token: 'fake_token', 340 token: 'fake_token',
343 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 341 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
344 }) 342 })
345 }) 343 })
346 344
@@ -349,7 +347,7 @@ describe('Test server follows API validators', function () {
349 url: server.url, 347 url: server.url,
350 path: path + '/localhost:9002', 348 path: path + '/localhost:9002',
351 token: userAccessToken, 349 token: userAccessToken,
352 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 350 expectedStatus: HttpStatusCode.FORBIDDEN_403
353 }) 351 })
354 }) 352 })
355 353
@@ -358,7 +356,7 @@ describe('Test server follows API validators', function () {
358 url: server.url, 356 url: server.url,
359 path: path + '/example.com', 357 path: path + '/example.com',
360 token: server.accessToken, 358 token: server.accessToken,
361 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 359 expectedStatus: HttpStatusCode.NOT_FOUND_404
362 }) 360 })
363 }) 361 })
364 }) 362 })