diff options
Diffstat (limited to 'server/tests/api/check-params/user-subscriptions.ts')
-rw-r--r-- | server/tests/api/check-params/user-subscriptions.ts | 68 |
1 files changed, 32 insertions, 36 deletions
diff --git a/server/tests/api/check-params/user-subscriptions.ts b/server/tests/api/check-params/user-subscriptions.ts index 22cf130c2..624069c80 100644 --- a/server/tests/api/check-params/user-subscriptions.ts +++ b/server/tests/api/check-params/user-subscriptions.ts | |||
@@ -1,24 +1,20 @@ | |||
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 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | |||
5 | import { | 4 | import { |
5 | checkBadCountPagination, | ||
6 | checkBadSortPagination, | ||
7 | checkBadStartPagination, | ||
6 | cleanupTests, | 8 | cleanupTests, |
7 | createSingleServer, | 9 | createSingleServer, |
8 | makeDeleteRequest, | 10 | makeDeleteRequest, |
9 | makeGetRequest, | 11 | makeGetRequest, |
10 | makePostBodyRequest, | 12 | makePostBodyRequest, |
11 | PeerTubeServer, | 13 | PeerTubeServer, |
12 | setAccessTokensToServers | 14 | setAccessTokensToServers, |
13 | } from '../../../../shared/extra-utils' | 15 | waitJobs |
14 | 16 | } from '@shared/extra-utils' | |
15 | import { | 17 | import { HttpStatusCode } from '@shared/models' |
16 | checkBadCountPagination, | ||
17 | checkBadSortPagination, | ||
18 | checkBadStartPagination | ||
19 | } from '../../../../shared/extra-utils/requests/check-api-params' | ||
20 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | ||
21 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
22 | 18 | ||
23 | describe('Test user subscriptions API validators', function () { | 19 | describe('Test user subscriptions API validators', function () { |
24 | const path = '/api/v1/users/me/subscriptions' | 20 | const path = '/api/v1/users/me/subscriptions' |
@@ -59,7 +55,7 @@ describe('Test user subscriptions API validators', function () { | |||
59 | await makeGetRequest({ | 55 | await makeGetRequest({ |
60 | url: server.url, | 56 | url: server.url, |
61 | path, | 57 | path, |
62 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 58 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
63 | }) | 59 | }) |
64 | }) | 60 | }) |
65 | 61 | ||
@@ -68,7 +64,7 @@ describe('Test user subscriptions API validators', function () { | |||
68 | url: server.url, | 64 | url: server.url, |
69 | path, | 65 | path, |
70 | token: userAccessToken, | 66 | token: userAccessToken, |
71 | statusCodeExpected: HttpStatusCode.OK_200 | 67 | expectedStatus: HttpStatusCode.OK_200 |
72 | }) | 68 | }) |
73 | }) | 69 | }) |
74 | }) | 70 | }) |
@@ -92,7 +88,7 @@ describe('Test user subscriptions API validators', function () { | |||
92 | await makeGetRequest({ | 88 | await makeGetRequest({ |
93 | url: server.url, | 89 | url: server.url, |
94 | path, | 90 | path, |
95 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 91 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
96 | }) | 92 | }) |
97 | }) | 93 | }) |
98 | 94 | ||
@@ -101,7 +97,7 @@ describe('Test user subscriptions API validators', function () { | |||
101 | url: server.url, | 97 | url: server.url, |
102 | path, | 98 | path, |
103 | token: userAccessToken, | 99 | token: userAccessToken, |
104 | statusCodeExpected: HttpStatusCode.OK_200 | 100 | expectedStatus: HttpStatusCode.OK_200 |
105 | }) | 101 | }) |
106 | }) | 102 | }) |
107 | }) | 103 | }) |
@@ -112,7 +108,7 @@ describe('Test user subscriptions API validators', function () { | |||
112 | url: server.url, | 108 | url: server.url, |
113 | path, | 109 | path, |
114 | fields: { uri: 'user1_channel@localhost:' + server.port }, | 110 | fields: { uri: 'user1_channel@localhost:' + server.port }, |
115 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 111 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
116 | }) | 112 | }) |
117 | }) | 113 | }) |
118 | 114 | ||
@@ -122,7 +118,7 @@ describe('Test user subscriptions API validators', function () { | |||
122 | path, | 118 | path, |
123 | token: server.accessToken, | 119 | token: server.accessToken, |
124 | fields: { uri: 'root' }, | 120 | fields: { uri: 'root' }, |
125 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 121 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
126 | }) | 122 | }) |
127 | 123 | ||
128 | await makePostBodyRequest({ | 124 | await makePostBodyRequest({ |
@@ -130,7 +126,7 @@ describe('Test user subscriptions API validators', function () { | |||
130 | path, | 126 | path, |
131 | token: server.accessToken, | 127 | token: server.accessToken, |
132 | fields: { uri: 'root@' }, | 128 | fields: { uri: 'root@' }, |
133 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 129 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
134 | }) | 130 | }) |
135 | 131 | ||
136 | await makePostBodyRequest({ | 132 | await makePostBodyRequest({ |
@@ -138,7 +134,7 @@ describe('Test user subscriptions API validators', function () { | |||
138 | path, | 134 | path, |
139 | token: server.accessToken, | 135 | token: server.accessToken, |
140 | fields: { uri: 'root@hello@' }, | 136 | fields: { uri: 'root@hello@' }, |
141 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 137 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
142 | }) | 138 | }) |
143 | }) | 139 | }) |
144 | 140 | ||
@@ -150,7 +146,7 @@ describe('Test user subscriptions API validators', function () { | |||
150 | path, | 146 | path, |
151 | token: server.accessToken, | 147 | token: server.accessToken, |
152 | fields: { uri: 'user1_channel@localhost:' + server.port }, | 148 | fields: { uri: 'user1_channel@localhost:' + server.port }, |
153 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 149 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
154 | }) | 150 | }) |
155 | 151 | ||
156 | await waitJobs([ server ]) | 152 | await waitJobs([ server ]) |
@@ -162,7 +158,7 @@ describe('Test user subscriptions API validators', function () { | |||
162 | await makeGetRequest({ | 158 | await makeGetRequest({ |
163 | url: server.url, | 159 | url: server.url, |
164 | path: path + '/user1_channel@localhost:' + server.port, | 160 | path: path + '/user1_channel@localhost:' + server.port, |
165 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 161 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
166 | }) | 162 | }) |
167 | }) | 163 | }) |
168 | 164 | ||
@@ -171,21 +167,21 @@ describe('Test user subscriptions API validators', function () { | |||
171 | url: server.url, | 167 | url: server.url, |
172 | path: path + '/root', | 168 | path: path + '/root', |
173 | token: server.accessToken, | 169 | token: server.accessToken, |
174 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 170 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
175 | }) | 171 | }) |
176 | 172 | ||
177 | await makeGetRequest({ | 173 | await makeGetRequest({ |
178 | url: server.url, | 174 | url: server.url, |
179 | path: path + '/root@', | 175 | path: path + '/root@', |
180 | token: server.accessToken, | 176 | token: server.accessToken, |
181 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 177 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
182 | }) | 178 | }) |
183 | 179 | ||
184 | await makeGetRequest({ | 180 | await makeGetRequest({ |
185 | url: server.url, | 181 | url: server.url, |
186 | path: path + '/root@hello@', | 182 | path: path + '/root@hello@', |
187 | token: server.accessToken, | 183 | token: server.accessToken, |
188 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 184 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
189 | }) | 185 | }) |
190 | }) | 186 | }) |
191 | 187 | ||
@@ -194,7 +190,7 @@ describe('Test user subscriptions API validators', function () { | |||
194 | url: server.url, | 190 | url: server.url, |
195 | path: path + '/root1@localhost:' + server.port, | 191 | path: path + '/root1@localhost:' + server.port, |
196 | token: server.accessToken, | 192 | token: server.accessToken, |
197 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 193 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
198 | }) | 194 | }) |
199 | }) | 195 | }) |
200 | 196 | ||
@@ -203,7 +199,7 @@ describe('Test user subscriptions API validators', function () { | |||
203 | url: server.url, | 199 | url: server.url, |
204 | path: path + '/user1_channel@localhost:' + server.port, | 200 | path: path + '/user1_channel@localhost:' + server.port, |
205 | token: server.accessToken, | 201 | token: server.accessToken, |
206 | statusCodeExpected: HttpStatusCode.OK_200 | 202 | expectedStatus: HttpStatusCode.OK_200 |
207 | }) | 203 | }) |
208 | }) | 204 | }) |
209 | }) | 205 | }) |
@@ -215,7 +211,7 @@ describe('Test user subscriptions API validators', function () { | |||
215 | await makeGetRequest({ | 211 | await makeGetRequest({ |
216 | url: server.url, | 212 | url: server.url, |
217 | path: existPath, | 213 | path: existPath, |
218 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 214 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
219 | }) | 215 | }) |
220 | }) | 216 | }) |
221 | 217 | ||
@@ -225,7 +221,7 @@ describe('Test user subscriptions API validators', function () { | |||
225 | path: existPath, | 221 | path: existPath, |
226 | query: { uris: 'toto' }, | 222 | query: { uris: 'toto' }, |
227 | token: server.accessToken, | 223 | token: server.accessToken, |
228 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 224 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
229 | }) | 225 | }) |
230 | 226 | ||
231 | await makeGetRequest({ | 227 | await makeGetRequest({ |
@@ -233,7 +229,7 @@ describe('Test user subscriptions API validators', function () { | |||
233 | path: existPath, | 229 | path: existPath, |
234 | query: { 'uris[]': 1 }, | 230 | query: { 'uris[]': 1 }, |
235 | token: server.accessToken, | 231 | token: server.accessToken, |
236 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 232 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
237 | }) | 233 | }) |
238 | }) | 234 | }) |
239 | 235 | ||
@@ -243,7 +239,7 @@ describe('Test user subscriptions API validators', function () { | |||
243 | path: existPath, | 239 | path: existPath, |
244 | query: { 'uris[]': 'coucou@localhost:' + server.port }, | 240 | query: { 'uris[]': 'coucou@localhost:' + server.port }, |
245 | token: server.accessToken, | 241 | token: server.accessToken, |
246 | statusCodeExpected: HttpStatusCode.OK_200 | 242 | expectedStatus: HttpStatusCode.OK_200 |
247 | }) | 243 | }) |
248 | }) | 244 | }) |
249 | }) | 245 | }) |
@@ -253,7 +249,7 @@ describe('Test user subscriptions API validators', function () { | |||
253 | await makeDeleteRequest({ | 249 | await makeDeleteRequest({ |
254 | url: server.url, | 250 | url: server.url, |
255 | path: path + '/user1_channel@localhost:' + server.port, | 251 | path: path + '/user1_channel@localhost:' + server.port, |
256 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 252 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
257 | }) | 253 | }) |
258 | }) | 254 | }) |
259 | 255 | ||
@@ -262,21 +258,21 @@ describe('Test user subscriptions API validators', function () { | |||
262 | url: server.url, | 258 | url: server.url, |
263 | path: path + '/root', | 259 | path: path + '/root', |
264 | token: server.accessToken, | 260 | token: server.accessToken, |
265 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 261 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
266 | }) | 262 | }) |
267 | 263 | ||
268 | await makeDeleteRequest({ | 264 | await makeDeleteRequest({ |
269 | url: server.url, | 265 | url: server.url, |
270 | path: path + '/root@', | 266 | path: path + '/root@', |
271 | token: server.accessToken, | 267 | token: server.accessToken, |
272 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 268 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
273 | }) | 269 | }) |
274 | 270 | ||
275 | await makeDeleteRequest({ | 271 | await makeDeleteRequest({ |
276 | url: server.url, | 272 | url: server.url, |
277 | path: path + '/root@hello@', | 273 | path: path + '/root@hello@', |
278 | token: server.accessToken, | 274 | token: server.accessToken, |
279 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 275 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
280 | }) | 276 | }) |
281 | }) | 277 | }) |
282 | 278 | ||
@@ -285,7 +281,7 @@ describe('Test user subscriptions API validators', function () { | |||
285 | url: server.url, | 281 | url: server.url, |
286 | path: path + '/root1@localhost:' + server.port, | 282 | path: path + '/root1@localhost:' + server.port, |
287 | token: server.accessToken, | 283 | token: server.accessToken, |
288 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 284 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
289 | }) | 285 | }) |
290 | }) | 286 | }) |
291 | 287 | ||
@@ -294,7 +290,7 @@ describe('Test user subscriptions API validators', function () { | |||
294 | url: server.url, | 290 | url: server.url, |
295 | path: path + '/user1_channel@localhost:' + server.port, | 291 | path: path + '/user1_channel@localhost:' + server.port, |
296 | token: server.accessToken, | 292 | token: server.accessToken, |
297 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 293 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
298 | }) | 294 | }) |
299 | }) | 295 | }) |
300 | }) | 296 | }) |