diff options
Diffstat (limited to 'shared/extra-utils/server')
-rw-r--r-- | shared/extra-utils/server/clients.ts | 3 | ||||
-rw-r--r-- | shared/extra-utils/server/config.ts | 12 | ||||
-rw-r--r-- | shared/extra-utils/server/contact-form.ts | 3 | ||||
-rw-r--r-- | shared/extra-utils/server/follows.ts | 15 | ||||
-rw-r--r-- | shared/extra-utils/server/jobs.ts | 5 | ||||
-rw-r--r-- | shared/extra-utils/server/plugins.ts | 57 | ||||
-rw-r--r-- | shared/extra-utils/server/redundancy.ts | 9 | ||||
-rw-r--r-- | shared/extra-utils/server/stats.ts | 3 |
8 files changed, 62 insertions, 45 deletions
diff --git a/shared/extra-utils/server/clients.ts b/shared/extra-utils/server/clients.ts index dc631e823..894fe4911 100644 --- a/shared/extra-utils/server/clients.ts +++ b/shared/extra-utils/server/clients.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | import * as request from 'supertest' | 1 | import * as request from 'supertest' |
2 | import { URL } from 'url' | 2 | import { URL } from 'url' |
3 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
3 | 4 | ||
4 | function getClient (url: string) { | 5 | function getClient (url: string) { |
5 | const path = '/api/v1/oauth-clients/local' | 6 | const path = '/api/v1/oauth-clients/local' |
@@ -8,7 +9,7 @@ function getClient (url: string) { | |||
8 | .get(path) | 9 | .get(path) |
9 | .set('Host', new URL(url).host) | 10 | .set('Host', new URL(url).host) |
10 | .set('Accept', 'application/json') | 11 | .set('Accept', 'application/json') |
11 | .expect(200) | 12 | .expect(HttpStatusCode.OK_200) |
12 | .expect('Content-Type', /json/) | 13 | .expect('Content-Type', /json/) |
13 | } | 14 | } |
14 | 15 | ||
diff --git a/shared/extra-utils/server/config.ts b/shared/extra-utils/server/config.ts index 7c1ad0a75..3b6afe9ff 100644 --- a/shared/extra-utils/server/config.ts +++ b/shared/extra-utils/server/config.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { makeDeleteRequest, makeGetRequest, makePutBodyRequest } from '../requests/requests' | 1 | import { makeDeleteRequest, makeGetRequest, makePutBodyRequest } from '../requests/requests' |
2 | import { CustomConfig } from '../../models/server/custom-config.model' | 2 | import { CustomConfig } from '../../models/server/custom-config.model' |
3 | import { DeepPartial } from '@shared/core-utils' | 3 | import { DeepPartial, HttpStatusCode } from '@shared/core-utils' |
4 | import { merge } from 'lodash' | 4 | import { merge } from 'lodash' |
5 | 5 | ||
6 | function getConfig (url: string) { | 6 | function getConfig (url: string) { |
@@ -9,7 +9,7 @@ function getConfig (url: string) { | |||
9 | return makeGetRequest({ | 9 | return makeGetRequest({ |
10 | url, | 10 | url, |
11 | path, | 11 | path, |
12 | statusCodeExpected: 200 | 12 | statusCodeExpected: HttpStatusCode.OK_200 |
13 | }) | 13 | }) |
14 | } | 14 | } |
15 | 15 | ||
@@ -19,11 +19,11 @@ function getAbout (url: string) { | |||
19 | return makeGetRequest({ | 19 | return makeGetRequest({ |
20 | url, | 20 | url, |
21 | path, | 21 | path, |
22 | statusCodeExpected: 200 | 22 | statusCodeExpected: HttpStatusCode.OK_200 |
23 | }) | 23 | }) |
24 | } | 24 | } |
25 | 25 | ||
26 | function getCustomConfig (url: string, token: string, statusCodeExpected = 200) { | 26 | function getCustomConfig (url: string, token: string, statusCodeExpected = HttpStatusCode.OK_200) { |
27 | const path = '/api/v1/config/custom' | 27 | const path = '/api/v1/config/custom' |
28 | 28 | ||
29 | return makeGetRequest({ | 29 | return makeGetRequest({ |
@@ -34,7 +34,7 @@ function getCustomConfig (url: string, token: string, statusCodeExpected = 200) | |||
34 | }) | 34 | }) |
35 | } | 35 | } |
36 | 36 | ||
37 | function updateCustomConfig (url: string, token: string, newCustomConfig: CustomConfig, statusCodeExpected = 200) { | 37 | function updateCustomConfig (url: string, token: string, newCustomConfig: CustomConfig, statusCodeExpected = HttpStatusCode.OK_200) { |
38 | const path = '/api/v1/config/custom' | 38 | const path = '/api/v1/config/custom' |
39 | 39 | ||
40 | return makePutBodyRequest({ | 40 | return makePutBodyRequest({ |
@@ -204,7 +204,7 @@ function updateCustomSubConfig (url: string, token: string, newConfig: DeepParti | |||
204 | return updateCustomConfig(url, token, updateParams) | 204 | return updateCustomConfig(url, token, updateParams) |
205 | } | 205 | } |
206 | 206 | ||
207 | function deleteCustomConfig (url: string, token: string, statusCodeExpected = 200) { | 207 | function deleteCustomConfig (url: string, token: string, statusCodeExpected = HttpStatusCode.OK_200) { |
208 | const path = '/api/v1/config/custom' | 208 | const path = '/api/v1/config/custom' |
209 | 209 | ||
210 | return makeDeleteRequest({ | 210 | return makeDeleteRequest({ |
diff --git a/shared/extra-utils/server/contact-form.ts b/shared/extra-utils/server/contact-form.ts index d50f83241..6c9232cc6 100644 --- a/shared/extra-utils/server/contact-form.ts +++ b/shared/extra-utils/server/contact-form.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | import * as request from 'supertest' | 1 | import * as request from 'supertest' |
2 | import { ContactForm } from '../../models/server' | 2 | import { ContactForm } from '../../models/server' |
3 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
3 | 4 | ||
4 | function sendContactForm (options: { | 5 | function sendContactForm (options: { |
5 | url: string | 6 | url: string |
@@ -20,7 +21,7 @@ function sendContactForm (options: { | |||
20 | return request(options.url) | 21 | return request(options.url) |
21 | .post(path) | 22 | .post(path) |
22 | .send(body) | 23 | .send(body) |
23 | .expect(options.expectedStatus || 204) | 24 | .expect(options.expectedStatus || HttpStatusCode.NO_CONTENT_204) |
24 | } | 25 | } |
25 | 26 | ||
26 | // --------------------------------------------------------------------------- | 27 | // --------------------------------------------------------------------------- |
diff --git a/shared/extra-utils/server/follows.ts b/shared/extra-utils/server/follows.ts index 006d59199..6aae4a31d 100644 --- a/shared/extra-utils/server/follows.ts +++ b/shared/extra-utils/server/follows.ts | |||
@@ -3,6 +3,7 @@ import { ServerInfo } from './servers' | |||
3 | import { waitJobs } from './jobs' | 3 | import { waitJobs } from './jobs' |
4 | import { makePostBodyRequest } from '../requests/requests' | 4 | import { makePostBodyRequest } from '../requests/requests' |
5 | import { ActivityPubActorType, FollowState } from '@shared/models' | 5 | import { ActivityPubActorType, FollowState } from '@shared/models' |
6 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
6 | 7 | ||
7 | function getFollowersListPaginationAndSort (options: { | 8 | function getFollowersListPaginationAndSort (options: { |
8 | url: string | 9 | url: string |
@@ -29,11 +30,11 @@ function getFollowersListPaginationAndSort (options: { | |||
29 | .get(path) | 30 | .get(path) |
30 | .query(query) | 31 | .query(query) |
31 | .set('Accept', 'application/json') | 32 | .set('Accept', 'application/json') |
32 | .expect(200) | 33 | .expect(HttpStatusCode.OK_200) |
33 | .expect('Content-Type', /json/) | 34 | .expect('Content-Type', /json/) |
34 | } | 35 | } |
35 | 36 | ||
36 | function acceptFollower (url: string, token: string, follower: string, statusCodeExpected = 204) { | 37 | function acceptFollower (url: string, token: string, follower: string, statusCodeExpected = HttpStatusCode.NO_CONTENT_204) { |
37 | const path = '/api/v1/server/followers/' + follower + '/accept' | 38 | const path = '/api/v1/server/followers/' + follower + '/accept' |
38 | 39 | ||
39 | return makePostBodyRequest({ | 40 | return makePostBodyRequest({ |
@@ -44,7 +45,7 @@ function acceptFollower (url: string, token: string, follower: string, statusCod | |||
44 | }) | 45 | }) |
45 | } | 46 | } |
46 | 47 | ||
47 | function rejectFollower (url: string, token: string, follower: string, statusCodeExpected = 204) { | 48 | function rejectFollower (url: string, token: string, follower: string, statusCodeExpected = HttpStatusCode.NO_CONTENT_204) { |
48 | const path = '/api/v1/server/followers/' + follower + '/reject' | 49 | const path = '/api/v1/server/followers/' + follower + '/reject' |
49 | 50 | ||
50 | return makePostBodyRequest({ | 51 | return makePostBodyRequest({ |
@@ -80,11 +81,11 @@ function getFollowingListPaginationAndSort (options: { | |||
80 | .get(path) | 81 | .get(path) |
81 | .query(query) | 82 | .query(query) |
82 | .set('Accept', 'application/json') | 83 | .set('Accept', 'application/json') |
83 | .expect(200) | 84 | .expect(HttpStatusCode.OK_200) |
84 | .expect('Content-Type', /json/) | 85 | .expect('Content-Type', /json/) |
85 | } | 86 | } |
86 | 87 | ||
87 | function follow (follower: string, following: string[], accessToken: string, expectedStatus = 204) { | 88 | function follow (follower: string, following: string[], accessToken: string, expectedStatus = HttpStatusCode.NO_CONTENT_204) { |
88 | const path = '/api/v1/server/following' | 89 | const path = '/api/v1/server/following' |
89 | 90 | ||
90 | const followingHosts = following.map(f => f.replace(/^http:\/\//, '')) | 91 | const followingHosts = following.map(f => f.replace(/^http:\/\//, '')) |
@@ -96,7 +97,7 @@ function follow (follower: string, following: string[], accessToken: string, exp | |||
96 | .expect(expectedStatus) | 97 | .expect(expectedStatus) |
97 | } | 98 | } |
98 | 99 | ||
99 | async function unfollow (url: string, accessToken: string, target: ServerInfo, expectedStatus = 204) { | 100 | async function unfollow (url: string, accessToken: string, target: ServerInfo, expectedStatus = HttpStatusCode.NO_CONTENT_204) { |
100 | const path = '/api/v1/server/following/' + target.host | 101 | const path = '/api/v1/server/following/' + target.host |
101 | 102 | ||
102 | return request(url) | 103 | return request(url) |
@@ -106,7 +107,7 @@ async function unfollow (url: string, accessToken: string, target: ServerInfo, e | |||
106 | .expect(expectedStatus) | 107 | .expect(expectedStatus) |
107 | } | 108 | } |
108 | 109 | ||
109 | function removeFollower (url: string, accessToken: string, follower: ServerInfo, expectedStatus = 204) { | 110 | function removeFollower (url: string, accessToken: string, follower: ServerInfo, expectedStatus = HttpStatusCode.NO_CONTENT_204) { |
110 | const path = '/api/v1/server/followers/peertube@' + follower.host | 111 | const path = '/api/v1/server/followers/peertube@' + follower.host |
111 | 112 | ||
112 | return request(url) | 113 | return request(url) |
diff --git a/shared/extra-utils/server/jobs.ts b/shared/extra-utils/server/jobs.ts index d984b3d1e..cac00e9ab 100644 --- a/shared/extra-utils/server/jobs.ts +++ b/shared/extra-utils/server/jobs.ts | |||
@@ -3,6 +3,7 @@ import { Job, JobState, JobType } from '../../models' | |||
3 | import { wait } from '../miscs/miscs' | 3 | import { wait } from '../miscs/miscs' |
4 | import { ServerInfo } from './servers' | 4 | import { ServerInfo } from './servers' |
5 | import { makeGetRequest } from '../../../shared/extra-utils' | 5 | import { makeGetRequest } from '../../../shared/extra-utils' |
6 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
6 | 7 | ||
7 | function getJobsList (url: string, accessToken: string, state: JobState) { | 8 | function getJobsList (url: string, accessToken: string, state: JobState) { |
8 | const path = '/api/v1/jobs/' + state | 9 | const path = '/api/v1/jobs/' + state |
@@ -11,7 +12,7 @@ function getJobsList (url: string, accessToken: string, state: JobState) { | |||
11 | .get(path) | 12 | .get(path) |
12 | .set('Accept', 'application/json') | 13 | .set('Accept', 'application/json') |
13 | .set('Authorization', 'Bearer ' + accessToken) | 14 | .set('Authorization', 'Bearer ' + accessToken) |
14 | .expect(200) | 15 | .expect(HttpStatusCode.OK_200) |
15 | .expect('Content-Type', /json/) | 16 | .expect('Content-Type', /json/) |
16 | } | 17 | } |
17 | 18 | ||
@@ -38,7 +39,7 @@ function getJobsListPaginationAndSort (options: { | |||
38 | url, | 39 | url, |
39 | path, | 40 | path, |
40 | token: accessToken, | 41 | token: accessToken, |
41 | statusCodeExpected: 200, | 42 | statusCodeExpected: HttpStatusCode.OK_200, |
42 | query | 43 | query |
43 | }) | 44 | }) |
44 | } | 45 | } |
diff --git a/shared/extra-utils/server/plugins.ts b/shared/extra-utils/server/plugins.ts index 83db2f6b8..864954ee7 100644 --- a/shared/extra-utils/server/plugins.ts +++ b/shared/extra-utils/server/plugins.ts | |||
@@ -9,6 +9,7 @@ import { PluginType } from '../../models/plugins/plugin.type' | |||
9 | import { buildServerDirectory, root } from '../miscs/miscs' | 9 | import { buildServerDirectory, root } from '../miscs/miscs' |
10 | import { makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests' | 10 | import { makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests' |
11 | import { ServerInfo } from './servers' | 11 | import { ServerInfo } from './servers' |
12 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
12 | 13 | ||
13 | function listPlugins (parameters: { | 14 | function listPlugins (parameters: { |
14 | url: string | 15 | url: string |
@@ -18,9 +19,9 @@ function listPlugins (parameters: { | |||
18 | sort?: string | 19 | sort?: string |
19 | pluginType?: PluginType | 20 | pluginType?: PluginType |
20 | uninstalled?: boolean | 21 | uninstalled?: boolean |
21 | expectedStatus?: number | 22 | expectedStatus?: HttpStatusCode |
22 | }) { | 23 | }) { |
23 | const { url, accessToken, start, count, sort, pluginType, uninstalled, expectedStatus = 200 } = parameters | 24 | const { url, accessToken, start, count, sort, pluginType, uninstalled, expectedStatus = HttpStatusCode.OK_200 } = parameters |
24 | const path = '/api/v1/plugins' | 25 | const path = '/api/v1/plugins' |
25 | 26 | ||
26 | return makeGetRequest({ | 27 | return makeGetRequest({ |
@@ -47,9 +48,19 @@ function listAvailablePlugins (parameters: { | |||
47 | pluginType?: PluginType | 48 | pluginType?: PluginType |
48 | currentPeerTubeEngine?: string | 49 | currentPeerTubeEngine?: string |
49 | search?: string | 50 | search?: string |
50 | expectedStatus?: number | 51 | expectedStatus?: HttpStatusCode |
51 | }) { | 52 | }) { |
52 | const { url, accessToken, start, count, sort, pluginType, search, currentPeerTubeEngine, expectedStatus = 200 } = parameters | 53 | const { |
54 | url, | ||
55 | accessToken, | ||
56 | start, | ||
57 | count, | ||
58 | sort, | ||
59 | pluginType, | ||
60 | search, | ||
61 | currentPeerTubeEngine, | ||
62 | expectedStatus = HttpStatusCode.OK_200 | ||
63 | } = parameters | ||
53 | const path = '/api/v1/plugins/available' | 64 | const path = '/api/v1/plugins/available' |
54 | 65 | ||
55 | const query: PeertubePluginIndexList = { | 66 | const query: PeertubePluginIndexList = { |
@@ -74,9 +85,9 @@ function getPlugin (parameters: { | |||
74 | url: string | 85 | url: string |
75 | accessToken: string | 86 | accessToken: string |
76 | npmName: string | 87 | npmName: string |
77 | expectedStatus?: number | 88 | expectedStatus?: HttpStatusCode |
78 | }) { | 89 | }) { |
79 | const { url, accessToken, npmName, expectedStatus = 200 } = parameters | 90 | const { url, accessToken, npmName, expectedStatus = HttpStatusCode.OK_200 } = parameters |
80 | const path = '/api/v1/plugins/' + npmName | 91 | const path = '/api/v1/plugins/' + npmName |
81 | 92 | ||
82 | return makeGetRequest({ | 93 | return makeGetRequest({ |
@@ -92,9 +103,9 @@ function updatePluginSettings (parameters: { | |||
92 | accessToken: string | 103 | accessToken: string |
93 | npmName: string | 104 | npmName: string |
94 | settings: any | 105 | settings: any |
95 | expectedStatus?: number | 106 | expectedStatus?: HttpStatusCode |
96 | }) { | 107 | }) { |
97 | const { url, accessToken, npmName, settings, expectedStatus = 204 } = parameters | 108 | const { url, accessToken, npmName, settings, expectedStatus = HttpStatusCode.NO_CONTENT_204 } = parameters |
98 | const path = '/api/v1/plugins/' + npmName + '/settings' | 109 | const path = '/api/v1/plugins/' + npmName + '/settings' |
99 | 110 | ||
100 | return makePutBodyRequest({ | 111 | return makePutBodyRequest({ |
@@ -110,9 +121,9 @@ function getPluginRegisteredSettings (parameters: { | |||
110 | url: string | 121 | url: string |
111 | accessToken: string | 122 | accessToken: string |
112 | npmName: string | 123 | npmName: string |
113 | expectedStatus?: number | 124 | expectedStatus?: HttpStatusCode |
114 | }) { | 125 | }) { |
115 | const { url, accessToken, npmName, expectedStatus = 200 } = parameters | 126 | const { url, accessToken, npmName, expectedStatus = HttpStatusCode.OK_200 } = parameters |
116 | const path = '/api/v1/plugins/' + npmName + '/registered-settings' | 127 | const path = '/api/v1/plugins/' + npmName + '/registered-settings' |
117 | 128 | ||
118 | return makeGetRequest({ | 129 | return makeGetRequest({ |
@@ -141,9 +152,9 @@ async function testHelloWorldRegisteredSettings (server: ServerInfo) { | |||
141 | function getPublicSettings (parameters: { | 152 | function getPublicSettings (parameters: { |
142 | url: string | 153 | url: string |
143 | npmName: string | 154 | npmName: string |
144 | expectedStatus?: number | 155 | expectedStatus?: HttpStatusCode |
145 | }) { | 156 | }) { |
146 | const { url, npmName, expectedStatus = 200 } = parameters | 157 | const { url, npmName, expectedStatus = HttpStatusCode.OK_200 } = parameters |
147 | const path = '/api/v1/plugins/' + npmName + '/public-settings' | 158 | const path = '/api/v1/plugins/' + npmName + '/public-settings' |
148 | 159 | ||
149 | return makeGetRequest({ | 160 | return makeGetRequest({ |
@@ -156,9 +167,9 @@ function getPublicSettings (parameters: { | |||
156 | function getPluginTranslations (parameters: { | 167 | function getPluginTranslations (parameters: { |
157 | url: string | 168 | url: string |
158 | locale: string | 169 | locale: string |
159 | expectedStatus?: number | 170 | expectedStatus?: HttpStatusCode |
160 | }) { | 171 | }) { |
161 | const { url, locale, expectedStatus = 200 } = parameters | 172 | const { url, locale, expectedStatus = HttpStatusCode.OK_200 } = parameters |
162 | const path = '/plugins/translations/' + locale + '.json' | 173 | const path = '/plugins/translations/' + locale + '.json' |
163 | 174 | ||
164 | return makeGetRequest({ | 175 | return makeGetRequest({ |
@@ -173,9 +184,9 @@ function installPlugin (parameters: { | |||
173 | accessToken: string | 184 | accessToken: string |
174 | path?: string | 185 | path?: string |
175 | npmName?: string | 186 | npmName?: string |
176 | expectedStatus?: number | 187 | expectedStatus?: HttpStatusCode |
177 | }) { | 188 | }) { |
178 | const { url, accessToken, npmName, path, expectedStatus = 200 } = parameters | 189 | const { url, accessToken, npmName, path, expectedStatus = HttpStatusCode.OK_200 } = parameters |
179 | const apiPath = '/api/v1/plugins/install' | 190 | const apiPath = '/api/v1/plugins/install' |
180 | 191 | ||
181 | return makePostBodyRequest({ | 192 | return makePostBodyRequest({ |
@@ -192,9 +203,9 @@ function updatePlugin (parameters: { | |||
192 | accessToken: string | 203 | accessToken: string |
193 | path?: string | 204 | path?: string |
194 | npmName?: string | 205 | npmName?: string |
195 | expectedStatus?: number | 206 | expectedStatus?: HttpStatusCode |
196 | }) { | 207 | }) { |
197 | const { url, accessToken, npmName, path, expectedStatus = 200 } = parameters | 208 | const { url, accessToken, npmName, path, expectedStatus = HttpStatusCode.OK_200 } = parameters |
198 | const apiPath = '/api/v1/plugins/update' | 209 | const apiPath = '/api/v1/plugins/update' |
199 | 210 | ||
200 | return makePostBodyRequest({ | 211 | return makePostBodyRequest({ |
@@ -210,9 +221,9 @@ function uninstallPlugin (parameters: { | |||
210 | url: string | 221 | url: string |
211 | accessToken: string | 222 | accessToken: string |
212 | npmName: string | 223 | npmName: string |
213 | expectedStatus?: number | 224 | expectedStatus?: HttpStatusCode |
214 | }) { | 225 | }) { |
215 | const { url, accessToken, npmName, expectedStatus = 204 } = parameters | 226 | const { url, accessToken, npmName, expectedStatus = HttpStatusCode.NO_CONTENT_204 } = parameters |
216 | const apiPath = '/api/v1/plugins/uninstall' | 227 | const apiPath = '/api/v1/plugins/uninstall' |
217 | 228 | ||
218 | return makePostBodyRequest({ | 229 | return makePostBodyRequest({ |
@@ -230,7 +241,7 @@ function getPluginsCSS (url: string) { | |||
230 | return makeGetRequest({ | 241 | return makeGetRequest({ |
231 | url, | 242 | url, |
232 | path, | 243 | path, |
233 | statusCodeExpected: 200 | 244 | statusCodeExpected: HttpStatusCode.OK_200 |
234 | }) | 245 | }) |
235 | } | 246 | } |
236 | 247 | ||
@@ -260,7 +271,7 @@ function getExternalAuth (options: { | |||
260 | npmVersion: string | 271 | npmVersion: string |
261 | authName: string | 272 | authName: string |
262 | query?: any | 273 | query?: any |
263 | statusCodeExpected?: number | 274 | statusCodeExpected?: HttpStatusCode |
264 | }) { | 275 | }) { |
265 | const { url, npmName, npmVersion, authName, statusCodeExpected, query } = options | 276 | const { url, npmName, npmVersion, authName, statusCodeExpected, query } = options |
266 | 277 | ||
@@ -270,7 +281,7 @@ function getExternalAuth (options: { | |||
270 | url, | 281 | url, |
271 | path, | 282 | path, |
272 | query, | 283 | query, |
273 | statusCodeExpected: statusCodeExpected || 200, | 284 | statusCodeExpected: statusCodeExpected || HttpStatusCode.OK_200, |
274 | redirects: 0 | 285 | redirects: 0 |
275 | }) | 286 | }) |
276 | } | 287 | } |
diff --git a/shared/extra-utils/server/redundancy.ts b/shared/extra-utils/server/redundancy.ts index 08467e4c0..3aca4ebfd 100644 --- a/shared/extra-utils/server/redundancy.ts +++ b/shared/extra-utils/server/redundancy.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | import { makeDeleteRequest, makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests' | 1 | import { makeDeleteRequest, makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests' |
2 | import { VideoRedundanciesTarget } from '@shared/models' | 2 | import { VideoRedundanciesTarget } from '@shared/models' |
3 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
3 | 4 | ||
4 | function updateRedundancy (url: string, accessToken: string, host: string, redundancyAllowed: boolean, expectedStatus = 204) { | 5 | function updateRedundancy (url: string, accessToken: string, host: string, redundancyAllowed: boolean, expectedStatus = 204) { |
5 | const path = '/api/v1/server/redundancy/' + host | 6 | const path = '/api/v1/server/redundancy/' + host |
@@ -20,7 +21,7 @@ function listVideoRedundancies (options: { | |||
20 | start?: number | 21 | start?: number |
21 | count?: number | 22 | count?: number |
22 | sort?: string | 23 | sort?: string |
23 | statusCodeExpected?: number | 24 | statusCodeExpected?: HttpStatusCode |
24 | }) { | 25 | }) { |
25 | const path = '/api/v1/server/redundancy/videos' | 26 | const path = '/api/v1/server/redundancy/videos' |
26 | 27 | ||
@@ -36,7 +37,7 @@ function listVideoRedundancies (options: { | |||
36 | sort: sort ?? 'name', | 37 | sort: sort ?? 'name', |
37 | target | 38 | target |
38 | }, | 39 | }, |
39 | statusCodeExpected: statusCodeExpected || 200 | 40 | statusCodeExpected: statusCodeExpected || HttpStatusCode.OK_200 |
40 | }) | 41 | }) |
41 | } | 42 | } |
42 | 43 | ||
@@ -53,7 +54,7 @@ function addVideoRedundancy (options: { | |||
53 | token: accessToken, | 54 | token: accessToken, |
54 | path, | 55 | path, |
55 | fields: { videoId }, | 56 | fields: { videoId }, |
56 | statusCodeExpected: 204 | 57 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 |
57 | }) | 58 | }) |
58 | } | 59 | } |
59 | 60 | ||
@@ -69,7 +70,7 @@ function removeVideoRedundancy (options: { | |||
69 | url, | 70 | url, |
70 | token: accessToken, | 71 | token: accessToken, |
71 | path, | 72 | path, |
72 | statusCodeExpected: 204 | 73 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 |
73 | }) | 74 | }) |
74 | } | 75 | } |
75 | 76 | ||
diff --git a/shared/extra-utils/server/stats.ts b/shared/extra-utils/server/stats.ts index 6f079ad18..b9dae24e2 100644 --- a/shared/extra-utils/server/stats.ts +++ b/shared/extra-utils/server/stats.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | import { makeGetRequest } from '../requests/requests' | 1 | import { makeGetRequest } from '../requests/requests' |
2 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
2 | 3 | ||
3 | function getStats (url: string, useCache = false) { | 4 | function getStats (url: string, useCache = false) { |
4 | const path = '/api/v1/server/stats' | 5 | const path = '/api/v1/server/stats' |
@@ -11,7 +12,7 @@ function getStats (url: string, useCache = false) { | |||
11 | url, | 12 | url, |
12 | path, | 13 | path, |
13 | query, | 14 | query, |
14 | statusCodeExpected: 200 | 15 | statusCodeExpected: HttpStatusCode.OK_200 |
15 | }) | 16 | }) |
16 | } | 17 | } |
17 | 18 | ||