aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/user-subscriptions.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-12-07 14:32:36 +0100
committerGitHub <noreply@github.com>2020-12-07 14:32:36 +0100
commit2d53be0267acc49cda46707b885096193a1f4e9c (patch)
tree887061a34bc67f40acbb96a6278f9544bf83caeb /server/tests/api/check-params/user-subscriptions.ts
parentadc1f09c0dbd997f34028c1c82d1c118dc8ead80 (diff)
downloadPeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.gz
PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.zst
PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.zip
replace numbers with typed http status codes (#3409)
Diffstat (limited to 'server/tests/api/check-params/user-subscriptions.ts')
-rw-r--r--server/tests/api/check-params/user-subscriptions.ts51
1 files changed, 26 insertions, 25 deletions
diff --git a/server/tests/api/check-params/user-subscriptions.ts b/server/tests/api/check-params/user-subscriptions.ts
index 1edba4d64..538201647 100644
--- a/server/tests/api/check-params/user-subscriptions.ts
+++ b/server/tests/api/check-params/user-subscriptions.ts
@@ -20,6 +20,7 @@ import {
20 checkBadStartPagination 20 checkBadStartPagination
21} from '../../../../shared/extra-utils/requests/check-api-params' 21} from '../../../../shared/extra-utils/requests/check-api-params'
22import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 22import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
23import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
23 24
24describe('Test user subscriptions API validators', function () { 25describe('Test user subscriptions API validators', function () {
25 const path = '/api/v1/users/me/subscriptions' 26 const path = '/api/v1/users/me/subscriptions'
@@ -60,7 +61,7 @@ describe('Test user subscriptions API validators', function () {
60 await makeGetRequest({ 61 await makeGetRequest({
61 url: server.url, 62 url: server.url,
62 path, 63 path,
63 statusCodeExpected: 401 64 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
64 }) 65 })
65 }) 66 })
66 67
@@ -69,7 +70,7 @@ describe('Test user subscriptions API validators', function () {
69 url: server.url, 70 url: server.url,
70 path, 71 path,
71 token: userAccessToken, 72 token: userAccessToken,
72 statusCodeExpected: 200 73 statusCodeExpected: HttpStatusCode.OK_200
73 }) 74 })
74 }) 75 })
75 }) 76 })
@@ -93,7 +94,7 @@ describe('Test user subscriptions API validators', function () {
93 await makeGetRequest({ 94 await makeGetRequest({
94 url: server.url, 95 url: server.url,
95 path, 96 path,
96 statusCodeExpected: 401 97 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
97 }) 98 })
98 }) 99 })
99 100
@@ -102,7 +103,7 @@ describe('Test user subscriptions API validators', function () {
102 url: server.url, 103 url: server.url,
103 path, 104 path,
104 token: userAccessToken, 105 token: userAccessToken,
105 statusCodeExpected: 200 106 statusCodeExpected: HttpStatusCode.OK_200
106 }) 107 })
107 }) 108 })
108 }) 109 })
@@ -113,7 +114,7 @@ describe('Test user subscriptions API validators', function () {
113 url: server.url, 114 url: server.url,
114 path, 115 path,
115 fields: { uri: 'user1_channel@localhost:' + server.port }, 116 fields: { uri: 'user1_channel@localhost:' + server.port },
116 statusCodeExpected: 401 117 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
117 }) 118 })
118 }) 119 })
119 120
@@ -123,7 +124,7 @@ describe('Test user subscriptions API validators', function () {
123 path, 124 path,
124 token: server.accessToken, 125 token: server.accessToken,
125 fields: { uri: 'root' }, 126 fields: { uri: 'root' },
126 statusCodeExpected: 400 127 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
127 }) 128 })
128 129
129 await makePostBodyRequest({ 130 await makePostBodyRequest({
@@ -131,7 +132,7 @@ describe('Test user subscriptions API validators', function () {
131 path, 132 path,
132 token: server.accessToken, 133 token: server.accessToken,
133 fields: { uri: 'root@' }, 134 fields: { uri: 'root@' },
134 statusCodeExpected: 400 135 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
135 }) 136 })
136 137
137 await makePostBodyRequest({ 138 await makePostBodyRequest({
@@ -139,7 +140,7 @@ describe('Test user subscriptions API validators', function () {
139 path, 140 path,
140 token: server.accessToken, 141 token: server.accessToken,
141 fields: { uri: 'root@hello@' }, 142 fields: { uri: 'root@hello@' },
142 statusCodeExpected: 400 143 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
143 }) 144 })
144 }) 145 })
145 146
@@ -151,7 +152,7 @@ describe('Test user subscriptions API validators', function () {
151 path, 152 path,
152 token: server.accessToken, 153 token: server.accessToken,
153 fields: { uri: 'user1_channel@localhost:' + server.port }, 154 fields: { uri: 'user1_channel@localhost:' + server.port },
154 statusCodeExpected: 204 155 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
155 }) 156 })
156 157
157 await waitJobs([ server ]) 158 await waitJobs([ server ])
@@ -163,7 +164,7 @@ describe('Test user subscriptions API validators', function () {
163 await makeGetRequest({ 164 await makeGetRequest({
164 url: server.url, 165 url: server.url,
165 path: path + '/user1_channel@localhost:' + server.port, 166 path: path + '/user1_channel@localhost:' + server.port,
166 statusCodeExpected: 401 167 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
167 }) 168 })
168 }) 169 })
169 170
@@ -172,21 +173,21 @@ describe('Test user subscriptions API validators', function () {
172 url: server.url, 173 url: server.url,
173 path: path + '/root', 174 path: path + '/root',
174 token: server.accessToken, 175 token: server.accessToken,
175 statusCodeExpected: 400 176 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
176 }) 177 })
177 178
178 await makeGetRequest({ 179 await makeGetRequest({
179 url: server.url, 180 url: server.url,
180 path: path + '/root@', 181 path: path + '/root@',
181 token: server.accessToken, 182 token: server.accessToken,
182 statusCodeExpected: 400 183 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
183 }) 184 })
184 185
185 await makeGetRequest({ 186 await makeGetRequest({
186 url: server.url, 187 url: server.url,
187 path: path + '/root@hello@', 188 path: path + '/root@hello@',
188 token: server.accessToken, 189 token: server.accessToken,
189 statusCodeExpected: 400 190 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
190 }) 191 })
191 }) 192 })
192 193
@@ -195,7 +196,7 @@ describe('Test user subscriptions API validators', function () {
195 url: server.url, 196 url: server.url,
196 path: path + '/root1@localhost:' + server.port, 197 path: path + '/root1@localhost:' + server.port,
197 token: server.accessToken, 198 token: server.accessToken,
198 statusCodeExpected: 404 199 statusCodeExpected: HttpStatusCode.NOT_FOUND_404
199 }) 200 })
200 }) 201 })
201 202
@@ -204,7 +205,7 @@ describe('Test user subscriptions API validators', function () {
204 url: server.url, 205 url: server.url,
205 path: path + '/user1_channel@localhost:' + server.port, 206 path: path + '/user1_channel@localhost:' + server.port,
206 token: server.accessToken, 207 token: server.accessToken,
207 statusCodeExpected: 200 208 statusCodeExpected: HttpStatusCode.OK_200
208 }) 209 })
209 }) 210 })
210 }) 211 })
@@ -216,7 +217,7 @@ describe('Test user subscriptions API validators', function () {
216 await makeGetRequest({ 217 await makeGetRequest({
217 url: server.url, 218 url: server.url,
218 path: existPath, 219 path: existPath,
219 statusCodeExpected: 401 220 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
220 }) 221 })
221 }) 222 })
222 223
@@ -226,7 +227,7 @@ describe('Test user subscriptions API validators', function () {
226 path: existPath, 227 path: existPath,
227 query: { uris: 'toto' }, 228 query: { uris: 'toto' },
228 token: server.accessToken, 229 token: server.accessToken,
229 statusCodeExpected: 400 230 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
230 }) 231 })
231 232
232 await makeGetRequest({ 233 await makeGetRequest({
@@ -234,7 +235,7 @@ describe('Test user subscriptions API validators', function () {
234 path: existPath, 235 path: existPath,
235 query: { 'uris[]': 1 }, 236 query: { 'uris[]': 1 },
236 token: server.accessToken, 237 token: server.accessToken,
237 statusCodeExpected: 400 238 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
238 }) 239 })
239 }) 240 })
240 241
@@ -244,7 +245,7 @@ describe('Test user subscriptions API validators', function () {
244 path: existPath, 245 path: existPath,
245 query: { 'uris[]': 'coucou@localhost:' + server.port }, 246 query: { 'uris[]': 'coucou@localhost:' + server.port },
246 token: server.accessToken, 247 token: server.accessToken,
247 statusCodeExpected: 200 248 statusCodeExpected: HttpStatusCode.OK_200
248 }) 249 })
249 }) 250 })
250 }) 251 })
@@ -254,7 +255,7 @@ describe('Test user subscriptions API validators', function () {
254 await makeDeleteRequest({ 255 await makeDeleteRequest({
255 url: server.url, 256 url: server.url,
256 path: path + '/user1_channel@localhost:' + server.port, 257 path: path + '/user1_channel@localhost:' + server.port,
257 statusCodeExpected: 401 258 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
258 }) 259 })
259 }) 260 })
260 261
@@ -263,21 +264,21 @@ describe('Test user subscriptions API validators', function () {
263 url: server.url, 264 url: server.url,
264 path: path + '/root', 265 path: path + '/root',
265 token: server.accessToken, 266 token: server.accessToken,
266 statusCodeExpected: 400 267 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
267 }) 268 })
268 269
269 await makeDeleteRequest({ 270 await makeDeleteRequest({
270 url: server.url, 271 url: server.url,
271 path: path + '/root@', 272 path: path + '/root@',
272 token: server.accessToken, 273 token: server.accessToken,
273 statusCodeExpected: 400 274 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
274 }) 275 })
275 276
276 await makeDeleteRequest({ 277 await makeDeleteRequest({
277 url: server.url, 278 url: server.url,
278 path: path + '/root@hello@', 279 path: path + '/root@hello@',
279 token: server.accessToken, 280 token: server.accessToken,
280 statusCodeExpected: 400 281 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
281 }) 282 })
282 }) 283 })
283 284
@@ -286,7 +287,7 @@ describe('Test user subscriptions API validators', function () {
286 url: server.url, 287 url: server.url,
287 path: path + '/root1@localhost:' + server.port, 288 path: path + '/root1@localhost:' + server.port,
288 token: server.accessToken, 289 token: server.accessToken,
289 statusCodeExpected: 404 290 statusCodeExpected: HttpStatusCode.NOT_FOUND_404
290 }) 291 })
291 }) 292 })
292 293
@@ -295,7 +296,7 @@ describe('Test user subscriptions API validators', function () {
295 url: server.url, 296 url: server.url,
296 path: path + '/user1_channel@localhost:' + server.port, 297 path: path + '/user1_channel@localhost:' + server.port,
297 token: server.accessToken, 298 token: server.accessToken,
298 statusCodeExpected: 204 299 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
299 }) 300 })
300 }) 301 })
301 }) 302 })