aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/redundancy.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/redundancy.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/redundancy.ts')
-rw-r--r--server/tests/api/check-params/redundancy.ts33
1 files changed, 17 insertions, 16 deletions
diff --git a/server/tests/api/check-params/redundancy.ts b/server/tests/api/check-params/redundancy.ts
index cb0cc0854..3e04865ee 100644
--- a/server/tests/api/check-params/redundancy.ts
+++ b/server/tests/api/check-params/redundancy.ts
@@ -16,6 +16,7 @@ import {
16 setAccessTokensToServers, uploadVideoAndGetId, 16 setAccessTokensToServers, uploadVideoAndGetId,
17 userLogin, waitJobs, getVideoIdFromUUID 17 userLogin, waitJobs, getVideoIdFromUUID
18} from '../../../../shared/extra-utils' 18} from '../../../../shared/extra-utils'
19import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
19 20
20describe('Test server redundancy API validators', function () { 21describe('Test server redundancy API validators', function () {
21 let servers: ServerInfo[] 22 let servers: ServerInfo[]
@@ -62,11 +63,11 @@ describe('Test server redundancy API validators', function () {
62 }) 63 })
63 64
64 it('Should fail with an invalid token', async function () { 65 it('Should fail with an invalid token', async function () {
65 await makeGetRequest({ url, path, token: 'fake_token', statusCodeExpected: 401 }) 66 await makeGetRequest({ url, path, token: 'fake_token', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
66 }) 67 })
67 68
68 it('Should fail if the user is not an administrator', async function () { 69 it('Should fail if the user is not an administrator', async function () {
69 await makeGetRequest({ url, path, token: userAccessToken, statusCodeExpected: 403 }) 70 await makeGetRequest({ url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 })
70 }) 71 })
71 72
72 it('Should fail with a bad start pagination', async function () { 73 it('Should fail with a bad start pagination', async function () {
@@ -90,7 +91,7 @@ describe('Test server redundancy API validators', function () {
90 }) 91 })
91 92
92 it('Should succeed with the correct params', async function () { 93 it('Should succeed with the correct params', async function () {
93 await makeGetRequest({ url, path, token, query: { target: 'my-videos' }, statusCodeExpected: 200 }) 94 await makeGetRequest({ url, path, token, query: { target: 'my-videos' }, statusCodeExpected: HttpStatusCode.OK_200 })
94 }) 95 })
95 }) 96 })
96 97
@@ -106,11 +107,11 @@ describe('Test server redundancy API validators', function () {
106 }) 107 })
107 108
108 it('Should fail with an invalid token', async function () { 109 it('Should fail with an invalid token', async function () {
109 await makePostBodyRequest({ url, path, token: 'fake_token', statusCodeExpected: 401 }) 110 await makePostBodyRequest({ url, path, token: 'fake_token', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
110 }) 111 })
111 112
112 it('Should fail if the user is not an administrator', async function () { 113 it('Should fail if the user is not an administrator', async function () {
113 await makePostBodyRequest({ url, path, token: userAccessToken, statusCodeExpected: 403 }) 114 await makePostBodyRequest({ url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 })
114 }) 115 })
115 116
116 it('Should fail without a video id', async function () { 117 it('Should fail without a video id', async function () {
@@ -122,7 +123,7 @@ describe('Test server redundancy API validators', function () {
122 }) 123 })
123 124
124 it('Should fail with a not found video id', async function () { 125 it('Should fail with a not found video id', async function () {
125 await makePostBodyRequest({ url, path, token, fields: { videoId: 6565 }, statusCodeExpected: 404 }) 126 await makePostBodyRequest({ url, path, token, fields: { videoId: 6565 }, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 })
126 }) 127 })
127 128
128 it('Should fail with a local a video id', async function () { 129 it('Should fail with a local a video id', async function () {
@@ -130,7 +131,7 @@ describe('Test server redundancy API validators', function () {
130 }) 131 })
131 132
132 it('Should succeed with the correct params', async function () { 133 it('Should succeed with the correct params', async function () {
133 await makePostBodyRequest({ url, path, token, fields: { videoId: videoIdRemote }, statusCodeExpected: 204 }) 134 await makePostBodyRequest({ url, path, token, fields: { videoId: videoIdRemote }, statusCodeExpected: HttpStatusCode.NO_CONTENT_204 })
134 }) 135 })
135 136
136 it('Should fail if the video is already duplicated', async function () { 137 it('Should fail if the video is already duplicated', async function () {
@@ -138,7 +139,7 @@ describe('Test server redundancy API validators', function () {
138 139
139 await waitJobs(servers) 140 await waitJobs(servers)
140 141
141 await makePostBodyRequest({ url, path, token, fields: { videoId: videoIdRemote }, statusCodeExpected: 409 }) 142 await makePostBodyRequest({ url, path, token, fields: { videoId: videoIdRemote }, statusCodeExpected: HttpStatusCode.CONFLICT_409 })
142 }) 143 })
143 }) 144 })
144 145
@@ -154,11 +155,11 @@ describe('Test server redundancy API validators', function () {
154 }) 155 })
155 156
156 it('Should fail with an invalid token', async function () { 157 it('Should fail with an invalid token', async function () {
157 await makeDeleteRequest({ url, path: path + '1', token: 'fake_token', statusCodeExpected: 401 }) 158 await makeDeleteRequest({ url, path: path + '1', token: 'fake_token', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
158 }) 159 })
159 160
160 it('Should fail if the user is not an administrator', async function () { 161 it('Should fail if the user is not an administrator', async function () {
161 await makeDeleteRequest({ url, path: path + '1', token: userAccessToken, statusCodeExpected: 403 }) 162 await makeDeleteRequest({ url, path: path + '1', token: userAccessToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 })
162 }) 163 })
163 164
164 it('Should fail with an incorrect video id', async function () { 165 it('Should fail with an incorrect video id', async function () {
@@ -166,7 +167,7 @@ describe('Test server redundancy API validators', function () {
166 }) 167 })
167 168
168 it('Should fail with a not found video redundancy', async function () { 169 it('Should fail with a not found video redundancy', async function () {
169 await makeDeleteRequest({ url, path: path + '454545', token, statusCodeExpected: 404 }) 170 await makeDeleteRequest({ url, path: path + '454545', token, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 })
170 }) 171 })
171 }) 172 })
172 173
@@ -179,7 +180,7 @@ describe('Test server redundancy API validators', function () {
179 path: path + '/localhost:' + servers[1].port, 180 path: path + '/localhost:' + servers[1].port,
180 fields: { redundancyAllowed: true }, 181 fields: { redundancyAllowed: true },
181 token: 'fake_token', 182 token: 'fake_token',
182 statusCodeExpected: 401 183 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
183 }) 184 })
184 }) 185 })
185 186
@@ -189,7 +190,7 @@ describe('Test server redundancy API validators', function () {
189 path: path + '/localhost:' + servers[1].port, 190 path: path + '/localhost:' + servers[1].port,
190 fields: { redundancyAllowed: true }, 191 fields: { redundancyAllowed: true },
191 token: userAccessToken, 192 token: userAccessToken,
192 statusCodeExpected: 403 193 statusCodeExpected: HttpStatusCode.FORBIDDEN_403
193 }) 194 })
194 }) 195 })
195 196
@@ -199,7 +200,7 @@ describe('Test server redundancy API validators', function () {
199 path: path + '/example.com', 200 path: path + '/example.com',
200 fields: { redundancyAllowed: true }, 201 fields: { redundancyAllowed: true },
201 token: servers[0].accessToken, 202 token: servers[0].accessToken,
202 statusCodeExpected: 404 203 statusCodeExpected: HttpStatusCode.NOT_FOUND_404
203 }) 204 })
204 }) 205 })
205 206
@@ -209,7 +210,7 @@ describe('Test server redundancy API validators', function () {
209 path: path + '/localhost:' + servers[1].port, 210 path: path + '/localhost:' + servers[1].port,
210 fields: { blabla: true }, 211 fields: { blabla: true },
211 token: servers[0].accessToken, 212 token: servers[0].accessToken,
212 statusCodeExpected: 400 213 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
213 }) 214 })
214 }) 215 })
215 216
@@ -219,7 +220,7 @@ describe('Test server redundancy API validators', function () {
219 path: path + '/localhost:' + servers[1].port, 220 path: path + '/localhost:' + servers[1].port,
220 fields: { redundancyAllowed: true }, 221 fields: { redundancyAllowed: true },
221 token: servers[0].accessToken, 222 token: servers[0].accessToken,
222 statusCodeExpected: 204 223 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
223 }) 224 })
224 }) 225 })
225 }) 226 })