diff options
Diffstat (limited to 'server/tests/api/check-params/redundancy.ts')
-rw-r--r-- | server/tests/api/check-params/redundancy.ts | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/server/tests/api/check-params/redundancy.ts b/server/tests/api/check-params/redundancy.ts index 18b98a0f9..d9f905549 100644 --- a/server/tests/api/check-params/redundancy.ts +++ b/server/tests/api/check-params/redundancy.ts | |||
@@ -1,15 +1,13 @@ | |||
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 | import { VideoCreateResult } from '@shared/models' | ||
5 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
6 | import { | 4 | import { |
7 | checkBadCountPagination, | 5 | checkBadCountPagination, |
8 | checkBadSortPagination, | 6 | checkBadSortPagination, |
9 | checkBadStartPagination, | 7 | checkBadStartPagination, |
10 | cleanupTests, | 8 | cleanupTests, |
11 | doubleFollow, | ||
12 | createMultipleServers, | 9 | createMultipleServers, |
10 | doubleFollow, | ||
13 | makeDeleteRequest, | 11 | makeDeleteRequest, |
14 | makeGetRequest, | 12 | makeGetRequest, |
15 | makePostBodyRequest, | 13 | makePostBodyRequest, |
@@ -17,7 +15,8 @@ import { | |||
17 | PeerTubeServer, | 15 | PeerTubeServer, |
18 | setAccessTokensToServers, | 16 | setAccessTokensToServers, |
19 | waitJobs | 17 | waitJobs |
20 | } from '../../../../shared/extra-utils' | 18 | } from '@shared/extra-utils' |
19 | import { HttpStatusCode, VideoCreateResult } from '@shared/models' | ||
21 | 20 | ||
22 | describe('Test server redundancy API validators', function () { | 21 | describe('Test server redundancy API validators', function () { |
23 | let servers: PeerTubeServer[] | 22 | let servers: PeerTubeServer[] |
@@ -64,11 +63,11 @@ describe('Test server redundancy API validators', function () { | |||
64 | }) | 63 | }) |
65 | 64 | ||
66 | it('Should fail with an invalid token', async function () { | 65 | it('Should fail with an invalid token', async function () { |
67 | await makeGetRequest({ url, path, token: 'fake_token', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) | 66 | await makeGetRequest({ url, path, token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
68 | }) | 67 | }) |
69 | 68 | ||
70 | 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 () { |
71 | await makeGetRequest({ url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) | 70 | await makeGetRequest({ url, path, token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
72 | }) | 71 | }) |
73 | 72 | ||
74 | it('Should fail with a bad start pagination', async function () { | 73 | it('Should fail with a bad start pagination', async function () { |
@@ -92,7 +91,7 @@ describe('Test server redundancy API validators', function () { | |||
92 | }) | 91 | }) |
93 | 92 | ||
94 | it('Should succeed with the correct params', async function () { | 93 | it('Should succeed with the correct params', async function () { |
95 | await makeGetRequest({ url, path, token, query: { target: 'my-videos' }, statusCodeExpected: HttpStatusCode.OK_200 }) | 94 | await makeGetRequest({ url, path, token, query: { target: 'my-videos' }, expectedStatus: HttpStatusCode.OK_200 }) |
96 | }) | 95 | }) |
97 | }) | 96 | }) |
98 | 97 | ||
@@ -108,11 +107,11 @@ describe('Test server redundancy API validators', function () { | |||
108 | }) | 107 | }) |
109 | 108 | ||
110 | it('Should fail with an invalid token', async function () { | 109 | it('Should fail with an invalid token', async function () { |
111 | await makePostBodyRequest({ url, path, token: 'fake_token', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) | 110 | await makePostBodyRequest({ url, path, token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
112 | }) | 111 | }) |
113 | 112 | ||
114 | 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 () { |
115 | await makePostBodyRequest({ url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) | 114 | await makePostBodyRequest({ url, path, token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
116 | }) | 115 | }) |
117 | 116 | ||
118 | it('Should fail without a video id', async function () { | 117 | it('Should fail without a video id', async function () { |
@@ -124,7 +123,7 @@ describe('Test server redundancy API validators', function () { | |||
124 | }) | 123 | }) |
125 | 124 | ||
126 | it('Should fail with a not found video id', async function () { | 125 | it('Should fail with a not found video id', async function () { |
127 | await makePostBodyRequest({ url, path, token, fields: { videoId: 6565 }, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) | 126 | await makePostBodyRequest({ url, path, token, fields: { videoId: 6565 }, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) |
128 | }) | 127 | }) |
129 | 128 | ||
130 | it('Should fail with a local a video id', async function () { | 129 | it('Should fail with a local a video id', async function () { |
@@ -137,7 +136,7 @@ describe('Test server redundancy API validators', function () { | |||
137 | path, | 136 | path, |
138 | token, | 137 | token, |
139 | fields: { videoId: videoRemote.shortUUID }, | 138 | fields: { videoId: videoRemote.shortUUID }, |
140 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 139 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
141 | }) | 140 | }) |
142 | }) | 141 | }) |
143 | 142 | ||
@@ -151,7 +150,7 @@ describe('Test server redundancy API validators', function () { | |||
151 | path, | 150 | path, |
152 | token, | 151 | token, |
153 | fields: { videoId: videoRemote.uuid }, | 152 | fields: { videoId: videoRemote.uuid }, |
154 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | 153 | expectedStatus: HttpStatusCode.CONFLICT_409 |
155 | }) | 154 | }) |
156 | }) | 155 | }) |
157 | }) | 156 | }) |
@@ -168,11 +167,11 @@ describe('Test server redundancy API validators', function () { | |||
168 | }) | 167 | }) |
169 | 168 | ||
170 | it('Should fail with an invalid token', async function () { | 169 | it('Should fail with an invalid token', async function () { |
171 | await makeDeleteRequest({ url, path: path + '1', token: 'fake_token', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) | 170 | await makeDeleteRequest({ url, path: path + '1', token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
172 | }) | 171 | }) |
173 | 172 | ||
174 | it('Should fail if the user is not an administrator', async function () { | 173 | it('Should fail if the user is not an administrator', async function () { |
175 | await makeDeleteRequest({ url, path: path + '1', token: userAccessToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) | 174 | await makeDeleteRequest({ url, path: path + '1', token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
176 | }) | 175 | }) |
177 | 176 | ||
178 | it('Should fail with an incorrect video id', async function () { | 177 | it('Should fail with an incorrect video id', async function () { |
@@ -180,7 +179,7 @@ describe('Test server redundancy API validators', function () { | |||
180 | }) | 179 | }) |
181 | 180 | ||
182 | it('Should fail with a not found video redundancy', async function () { | 181 | it('Should fail with a not found video redundancy', async function () { |
183 | await makeDeleteRequest({ url, path: path + '454545', token, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) | 182 | await makeDeleteRequest({ url, path: path + '454545', token, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) |
184 | }) | 183 | }) |
185 | }) | 184 | }) |
186 | 185 | ||
@@ -193,7 +192,7 @@ describe('Test server redundancy API validators', function () { | |||
193 | path: path + '/localhost:' + servers[1].port, | 192 | path: path + '/localhost:' + servers[1].port, |
194 | fields: { redundancyAllowed: true }, | 193 | fields: { redundancyAllowed: true }, |
195 | token: 'fake_token', | 194 | token: 'fake_token', |
196 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 195 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
197 | }) | 196 | }) |
198 | }) | 197 | }) |
199 | 198 | ||
@@ -203,7 +202,7 @@ describe('Test server redundancy API validators', function () { | |||
203 | path: path + '/localhost:' + servers[1].port, | 202 | path: path + '/localhost:' + servers[1].port, |
204 | fields: { redundancyAllowed: true }, | 203 | fields: { redundancyAllowed: true }, |
205 | token: userAccessToken, | 204 | token: userAccessToken, |
206 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 205 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
207 | }) | 206 | }) |
208 | }) | 207 | }) |
209 | 208 | ||
@@ -213,7 +212,7 @@ describe('Test server redundancy API validators', function () { | |||
213 | path: path + '/example.com', | 212 | path: path + '/example.com', |
214 | fields: { redundancyAllowed: true }, | 213 | fields: { redundancyAllowed: true }, |
215 | token: servers[0].accessToken, | 214 | token: servers[0].accessToken, |
216 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 215 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
217 | }) | 216 | }) |
218 | }) | 217 | }) |
219 | 218 | ||
@@ -223,7 +222,7 @@ describe('Test server redundancy API validators', function () { | |||
223 | path: path + '/localhost:' + servers[1].port, | 222 | path: path + '/localhost:' + servers[1].port, |
224 | fields: { blabla: true }, | 223 | fields: { blabla: true }, |
225 | token: servers[0].accessToken, | 224 | token: servers[0].accessToken, |
226 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 225 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
227 | }) | 226 | }) |
228 | }) | 227 | }) |
229 | 228 | ||
@@ -233,7 +232,7 @@ describe('Test server redundancy API validators', function () { | |||
233 | path: path + '/localhost:' + servers[1].port, | 232 | path: path + '/localhost:' + servers[1].port, |
234 | fields: { redundancyAllowed: true }, | 233 | fields: { redundancyAllowed: true }, |
235 | token: servers[0].accessToken, | 234 | token: servers[0].accessToken, |
236 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 235 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
237 | }) | 236 | }) |
238 | }) | 237 | }) |
239 | }) | 238 | }) |