aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/video-captions.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/video-captions.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/video-captions.ts')
-rw-r--r--server/tests/api/check-params/video-captions.ts41
1 files changed, 28 insertions, 13 deletions
diff --git a/server/tests/api/check-params/video-captions.ts b/server/tests/api/check-params/video-captions.ts
index a5f5c3322..e42e8db81 100644
--- a/server/tests/api/check-params/video-captions.ts
+++ b/server/tests/api/check-params/video-captions.ts
@@ -15,6 +15,7 @@ import {
15} from '../../../../shared/extra-utils' 15} from '../../../../shared/extra-utils'
16import { join } from 'path' 16import { join } from 'path'
17import { createVideoCaption } from '../../../../shared/extra-utils/videos/video-captions' 17import { createVideoCaption } from '../../../../shared/extra-utils/videos/video-captions'
18import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
18 19
19describe('Test video captions API validator', function () { 20describe('Test video captions API validator', function () {
20 const path = '/api/v1/videos/' 21 const path = '/api/v1/videos/'
@@ -107,7 +108,7 @@ describe('Test video captions API validator', function () {
107 path: captionPath, 108 path: captionPath,
108 fields, 109 fields,
109 attaches, 110 attaches,
110 statusCodeExpected: 401 111 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
111 }) 112 })
112 }) 113 })
113 114
@@ -120,7 +121,7 @@ describe('Test video captions API validator', function () {
120 token: 'blabla', 121 token: 'blabla',
121 fields, 122 fields,
122 attaches, 123 attaches,
123 statusCodeExpected: 401 124 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
124 }) 125 })
125 }) 126 })
126 127
@@ -138,7 +139,7 @@ describe('Test video captions API validator', function () {
138 // token: server.accessToken, 139 // token: server.accessToken,
139 // fields, 140 // fields,
140 // attaches, 141 // attaches,
141 // statusCodeExpected: 400 142 // statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
142 // }) 143 // })
143 // }) 144 // })
144 145
@@ -151,7 +152,7 @@ describe('Test video captions API validator', function () {
151 // videoId: videoUUID, 152 // videoId: videoUUID,
152 // fixture: 'subtitle-bad.txt', 153 // fixture: 'subtitle-bad.txt',
153 // mimeType: 'application/octet-stream', 154 // mimeType: 'application/octet-stream',
154 // statusCodeExpected: 400 155 // statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
155 // }) 156 // })
156 // }) 157 // })
157 158
@@ -180,7 +181,7 @@ describe('Test video captions API validator', function () {
180 // token: server.accessToken, 181 // token: server.accessToken,
181 // fields, 182 // fields,
182 // attaches, 183 // attaches,
183 // statusCodeExpected: 500 184 // statusCodeExpected: HttpStatusCode.INTERNAL_SERVER_ERROR_500
184 // }) 185 // })
185 // }) 186 // })
186 187
@@ -193,7 +194,7 @@ describe('Test video captions API validator', function () {
193 token: server.accessToken, 194 token: server.accessToken,
194 fields, 195 fields,
195 attaches, 196 attaches,
196 statusCodeExpected: 204 197 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
197 }) 198 })
198 }) 199 })
199 }) 200 })
@@ -204,11 +205,15 @@ describe('Test video captions API validator', function () {
204 }) 205 })
205 206
206 it('Should fail with an unknown id', async function () { 207 it('Should fail with an unknown id', async function () {
207 await makeGetRequest({ url: server.url, path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/captions', statusCodeExpected: 404 }) 208 await makeGetRequest({
209 url: server.url,
210 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/captions',
211 statusCodeExpected: HttpStatusCode.NOT_FOUND_404
212 })
208 }) 213 })
209 214
210 it('Should success with the correct parameters', async function () { 215 it('Should success with the correct parameters', async function () {
211 await makeGetRequest({ url: server.url, path: path + videoUUID + '/captions', statusCodeExpected: 200 }) 216 await makeGetRequest({ url: server.url, path: path + videoUUID + '/captions', statusCodeExpected: HttpStatusCode.OK_200 })
212 }) 217 })
213 }) 218 })
214 219
@@ -226,7 +231,7 @@ describe('Test video captions API validator', function () {
226 url: server.url, 231 url: server.url,
227 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/captions/fr', 232 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/captions/fr',
228 token: server.accessToken, 233 token: server.accessToken,
229 statusCodeExpected: 404 234 statusCodeExpected: HttpStatusCode.NOT_FOUND_404
230 }) 235 })
231 }) 236 })
232 237
@@ -250,22 +255,32 @@ describe('Test video captions API validator', function () {
250 255
251 it('Should fail without access token', async function () { 256 it('Should fail without access token', async function () {
252 const captionPath = path + videoUUID + '/captions/fr' 257 const captionPath = path + videoUUID + '/captions/fr'
253 await makeDeleteRequest({ url: server.url, path: captionPath, statusCodeExpected: 401 }) 258 await makeDeleteRequest({ url: server.url, path: captionPath, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
254 }) 259 })
255 260
256 it('Should fail with a bad access token', async function () { 261 it('Should fail with a bad access token', async function () {
257 const captionPath = path + videoUUID + '/captions/fr' 262 const captionPath = path + videoUUID + '/captions/fr'
258 await makeDeleteRequest({ url: server.url, path: captionPath, token: 'coucou', statusCodeExpected: 401 }) 263 await makeDeleteRequest({ url: server.url, path: captionPath, token: 'coucou', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
259 }) 264 })
260 265
261 it('Should fail with another user', async function () { 266 it('Should fail with another user', async function () {
262 const captionPath = path + videoUUID + '/captions/fr' 267 const captionPath = path + videoUUID + '/captions/fr'
263 await makeDeleteRequest({ url: server.url, path: captionPath, token: userAccessToken, statusCodeExpected: 403 }) 268 await makeDeleteRequest({
269 url: server.url,
270 path: captionPath,
271 token: userAccessToken,
272 statusCodeExpected: HttpStatusCode.FORBIDDEN_403
273 })
264 }) 274 })
265 275
266 it('Should success with the correct parameters', async function () { 276 it('Should success with the correct parameters', async function () {
267 const captionPath = path + videoUUID + '/captions/fr' 277 const captionPath = path + videoUUID + '/captions/fr'
268 await makeDeleteRequest({ url: server.url, path: captionPath, token: server.accessToken, statusCodeExpected: 204 }) 278 await makeDeleteRequest({
279 url: server.url,
280 path: captionPath,
281 token: server.accessToken,
282 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
283 })
269 }) 284 })
270 }) 285 })
271 286