aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/requests
diff options
context:
space:
mode:
Diffstat (limited to 'shared/extra-utils/requests')
-rw-r--r--shared/extra-utils/requests/check-api-params.ts11
-rw-r--r--shared/extra-utils/requests/requests.ts4
2 files changed, 7 insertions, 8 deletions
diff --git a/shared/extra-utils/requests/check-api-params.ts b/shared/extra-utils/requests/check-api-params.ts
index 7f5ff775c..7df63b004 100644
--- a/shared/extra-utils/requests/check-api-params.ts
+++ b/shared/extra-utils/requests/check-api-params.ts
@@ -1,13 +1,12 @@
1import { HttpStatusCode } from '@shared/core-utils'
1import { makeGetRequest } from './requests' 2import { makeGetRequest } from './requests'
2import { immutableAssign } from '../miscs/miscs'
3import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
4 3
5function checkBadStartPagination (url: string, path: string, token?: string, query = {}) { 4function checkBadStartPagination (url: string, path: string, token?: string, query = {}) {
6 return makeGetRequest({ 5 return makeGetRequest({
7 url, 6 url,
8 path, 7 path,
9 token, 8 token,
10 query: immutableAssign(query, { start: 'hello' }), 9 query: { ...query, start: 'hello' },
11 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 10 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
12 }) 11 })
13} 12}
@@ -17,7 +16,7 @@ async function checkBadCountPagination (url: string, path: string, token?: strin
17 url, 16 url,
18 path, 17 path,
19 token, 18 token,
20 query: immutableAssign(query, { count: 'hello' }), 19 query: { ...query, count: 'hello' },
21 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 20 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
22 }) 21 })
23 22
@@ -25,7 +24,7 @@ async function checkBadCountPagination (url: string, path: string, token?: strin
25 url, 24 url,
26 path, 25 path,
27 token, 26 token,
28 query: immutableAssign(query, { count: 2000 }), 27 query: { ...query, count: 2000 },
29 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 28 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
30 }) 29 })
31} 30}
@@ -35,7 +34,7 @@ function checkBadSortPagination (url: string, path: string, token?: string, quer
35 url, 34 url,
36 path, 35 path,
37 token, 36 token,
38 query: immutableAssign(query, { sort: 'hello' }), 37 query: { ...query, sort: 'hello' },
39 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 38 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
40 }) 39 })
41} 40}
diff --git a/shared/extra-utils/requests/requests.ts b/shared/extra-utils/requests/requests.ts
index 3fbaa31d6..f9d112aca 100644
--- a/shared/extra-utils/requests/requests.ts
+++ b/shared/extra-utils/requests/requests.ts
@@ -4,8 +4,8 @@ import { isAbsolute, join } from 'path'
4import { decode } from 'querystring' 4import { decode } from 'querystring'
5import * as request from 'supertest' 5import * as request from 'supertest'
6import { URL } from 'url' 6import { URL } from 'url'
7import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 7import { HttpStatusCode } from '@shared/core-utils'
8import { buildAbsoluteFixturePath, root } from '../miscs/miscs' 8import { buildAbsoluteFixturePath, root } from '../miscs/tests'
9 9
10function get4KFileUrl () { 10function get4KFileUrl () {
11 return 'https://download.cpy.re/peertube/4k_file.txt' 11 return 'https://download.cpy.re/peertube/4k_file.txt'