diff options
author | Chocobozzz <me@florianbigard.com> | 2020-01-31 16:56:52 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-02-03 08:31:02 +0100 |
commit | a15871560f80e07386c1dabb8370cd2664ecfd1f (patch) | |
tree | 44440e140c9e43b0d7f97ade777a76e649e0553d /shared/extra-utils/server | |
parent | a22046d166805222ca76060e471b6cb3d419a32d (diff) | |
download | PeerTube-contain.tar.gz PeerTube-contain.tar.zst PeerTube-contain.zip |
Move to eslintcontain
Diffstat (limited to 'shared/extra-utils/server')
-rw-r--r-- | shared/extra-utils/server/clients.ts | 4 | ||||
-rw-r--r-- | shared/extra-utils/server/contact-form.ts | 10 | ||||
-rw-r--r-- | shared/extra-utils/server/follows.ts | 26 | ||||
-rw-r--r-- | shared/extra-utils/server/jobs.ts | 22 | ||||
-rw-r--r-- | shared/extra-utils/server/plugins.ts | 72 | ||||
-rw-r--r-- | shared/extra-utils/server/redundancy.ts | 18 | ||||
-rw-r--r-- | shared/extra-utils/server/servers.ts | 27 |
7 files changed, 89 insertions, 90 deletions
diff --git a/shared/extra-utils/server/clients.ts b/shared/extra-utils/server/clients.ts index 273aac747..dc631e823 100644 --- a/shared/extra-utils/server/clients.ts +++ b/shared/extra-utils/server/clients.ts | |||
@@ -1,12 +1,12 @@ | |||
1 | import * as request from 'supertest' | 1 | import * as request from 'supertest' |
2 | import * as urlUtil from 'url' | 2 | import { URL } from 'url' |
3 | 3 | ||
4 | function getClient (url: string) { | 4 | function getClient (url: string) { |
5 | const path = '/api/v1/oauth-clients/local' | 5 | const path = '/api/v1/oauth-clients/local' |
6 | 6 | ||
7 | return request(url) | 7 | return request(url) |
8 | .get(path) | 8 | .get(path) |
9 | .set('Host', urlUtil.parse(url).host) | 9 | .set('Host', new URL(url).host) |
10 | .set('Accept', 'application/json') | 10 | .set('Accept', 'application/json') |
11 | .expect(200) | 11 | .expect(200) |
12 | .expect('Content-Type', /json/) | 12 | .expect('Content-Type', /json/) |
diff --git a/shared/extra-utils/server/contact-form.ts b/shared/extra-utils/server/contact-form.ts index e002e03dd..d50f83241 100644 --- a/shared/extra-utils/server/contact-form.ts +++ b/shared/extra-utils/server/contact-form.ts | |||
@@ -2,11 +2,11 @@ import * as request from 'supertest' | |||
2 | import { ContactForm } from '../../models/server' | 2 | import { ContactForm } from '../../models/server' |
3 | 3 | ||
4 | function sendContactForm (options: { | 4 | function sendContactForm (options: { |
5 | url: string, | 5 | url: string |
6 | fromEmail: string, | 6 | fromEmail: string |
7 | fromName: string, | 7 | fromName: string |
8 | subject: string, | 8 | subject: string |
9 | body: string, | 9 | body: string |
10 | expectedStatus?: number | 10 | expectedStatus?: number |
11 | }) { | 11 | }) { |
12 | const path = '/api/v1/server/contact' | 12 | const path = '/api/v1/server/contact' |
diff --git a/shared/extra-utils/server/follows.ts b/shared/extra-utils/server/follows.ts index 3f7729c20..006d59199 100644 --- a/shared/extra-utils/server/follows.ts +++ b/shared/extra-utils/server/follows.ts | |||
@@ -5,12 +5,12 @@ import { makePostBodyRequest } from '../requests/requests' | |||
5 | import { ActivityPubActorType, FollowState } from '@shared/models' | 5 | import { ActivityPubActorType, FollowState } from '@shared/models' |
6 | 6 | ||
7 | function getFollowersListPaginationAndSort (options: { | 7 | function getFollowersListPaginationAndSort (options: { |
8 | url: string, | 8 | url: string |
9 | start: number, | 9 | start: number |
10 | count: number, | 10 | count: number |
11 | sort: string, | 11 | sort: string |
12 | search?: string, | 12 | search?: string |
13 | actorType?: ActivityPubActorType, | 13 | actorType?: ActivityPubActorType |
14 | state?: FollowState | 14 | state?: FollowState |
15 | }) { | 15 | }) { |
16 | const { url, start, count, sort, search, state, actorType } = options | 16 | const { url, start, count, sort, search, state, actorType } = options |
@@ -56,12 +56,12 @@ function rejectFollower (url: string, token: string, follower: string, statusCod | |||
56 | } | 56 | } |
57 | 57 | ||
58 | function getFollowingListPaginationAndSort (options: { | 58 | function getFollowingListPaginationAndSort (options: { |
59 | url: string, | 59 | url: string |
60 | start: number, | 60 | start: number |
61 | count: number, | 61 | count: number |
62 | sort: string, | 62 | sort: string |
63 | search?: string, | 63 | search?: string |
64 | actorType?: ActivityPubActorType, | 64 | actorType?: ActivityPubActorType |
65 | state?: FollowState | 65 | state?: FollowState |
66 | }) { | 66 | }) { |
67 | const { url, start, count, sort, search, state, actorType } = options | 67 | const { url, start, count, sort, search, state, actorType } = options |
@@ -92,7 +92,7 @@ function follow (follower: string, following: string[], accessToken: string, exp | |||
92 | .post(path) | 92 | .post(path) |
93 | .set('Accept', 'application/json') | 93 | .set('Accept', 'application/json') |
94 | .set('Authorization', 'Bearer ' + accessToken) | 94 | .set('Authorization', 'Bearer ' + accessToken) |
95 | .send({ 'hosts': followingHosts }) | 95 | .send({ hosts: followingHosts }) |
96 | .expect(expectedStatus) | 96 | .expect(expectedStatus) |
97 | } | 97 | } |
98 | 98 | ||
diff --git a/shared/extra-utils/server/jobs.ts b/shared/extra-utils/server/jobs.ts index 56fe5fa2a..d984b3d1e 100644 --- a/shared/extra-utils/server/jobs.ts +++ b/shared/extra-utils/server/jobs.ts | |||
@@ -8,20 +8,20 @@ function getJobsList (url: string, accessToken: string, state: JobState) { | |||
8 | const path = '/api/v1/jobs/' + state | 8 | const path = '/api/v1/jobs/' + state |
9 | 9 | ||
10 | return request(url) | 10 | return request(url) |
11 | .get(path) | 11 | .get(path) |
12 | .set('Accept', 'application/json') | 12 | .set('Accept', 'application/json') |
13 | .set('Authorization', 'Bearer ' + accessToken) | 13 | .set('Authorization', 'Bearer ' + accessToken) |
14 | .expect(200) | 14 | .expect(200) |
15 | .expect('Content-Type', /json/) | 15 | .expect('Content-Type', /json/) |
16 | } | 16 | } |
17 | 17 | ||
18 | function getJobsListPaginationAndSort (options: { | 18 | function getJobsListPaginationAndSort (options: { |
19 | url: string, | 19 | url: string |
20 | accessToken: string, | 20 | accessToken: string |
21 | state: JobState, | 21 | state: JobState |
22 | start: number, | 22 | start: number |
23 | count: number, | 23 | count: number |
24 | sort: string, | 24 | sort: string |
25 | jobType?: JobType | 25 | jobType?: JobType |
26 | }) { | 26 | }) { |
27 | const { url, accessToken, state, start, count, sort, jobType } = options | 27 | const { url, accessToken, state, start, count, sort, jobType } = options |
diff --git a/shared/extra-utils/server/plugins.ts b/shared/extra-utils/server/plugins.ts index 5c0d1e511..2d02d823d 100644 --- a/shared/extra-utils/server/plugins.ts +++ b/shared/extra-utils/server/plugins.ts | |||
@@ -7,13 +7,13 @@ import { root } from '../miscs/miscs' | |||
7 | import { join } from 'path' | 7 | import { join } from 'path' |
8 | 8 | ||
9 | function listPlugins (parameters: { | 9 | function listPlugins (parameters: { |
10 | url: string, | 10 | url: string |
11 | accessToken: string, | 11 | accessToken: string |
12 | start?: number, | 12 | start?: number |
13 | count?: number, | 13 | count?: number |
14 | sort?: string, | 14 | sort?: string |
15 | pluginType?: PluginType, | 15 | pluginType?: PluginType |
16 | uninstalled?: boolean, | 16 | uninstalled?: boolean |
17 | expectedStatus?: number | 17 | expectedStatus?: number |
18 | }) { | 18 | }) { |
19 | const { url, accessToken, start, count, sort, pluginType, uninstalled, expectedStatus = 200 } = parameters | 19 | const { url, accessToken, start, count, sort, pluginType, uninstalled, expectedStatus = 200 } = parameters |
@@ -35,13 +35,13 @@ function listPlugins (parameters: { | |||
35 | } | 35 | } |
36 | 36 | ||
37 | function listAvailablePlugins (parameters: { | 37 | function listAvailablePlugins (parameters: { |
38 | url: string, | 38 | url: string |
39 | accessToken: string, | 39 | accessToken: string |
40 | start?: number, | 40 | start?: number |
41 | count?: number, | 41 | count?: number |
42 | sort?: string, | 42 | sort?: string |
43 | pluginType?: PluginType, | 43 | pluginType?: PluginType |
44 | currentPeerTubeEngine?: string, | 44 | currentPeerTubeEngine?: string |
45 | search?: string | 45 | search?: string |
46 | expectedStatus?: number | 46 | expectedStatus?: number |
47 | }) { | 47 | }) { |
@@ -67,9 +67,9 @@ function listAvailablePlugins (parameters: { | |||
67 | } | 67 | } |
68 | 68 | ||
69 | function getPlugin (parameters: { | 69 | function getPlugin (parameters: { |
70 | url: string, | 70 | url: string |
71 | accessToken: string, | 71 | accessToken: string |
72 | npmName: string, | 72 | npmName: string |
73 | expectedStatus?: number | 73 | expectedStatus?: number |
74 | }) { | 74 | }) { |
75 | const { url, accessToken, npmName, expectedStatus = 200 } = parameters | 75 | const { url, accessToken, npmName, expectedStatus = 200 } = parameters |
@@ -84,10 +84,10 @@ function getPlugin (parameters: { | |||
84 | } | 84 | } |
85 | 85 | ||
86 | function updatePluginSettings (parameters: { | 86 | function updatePluginSettings (parameters: { |
87 | url: string, | 87 | url: string |
88 | accessToken: string, | 88 | accessToken: string |
89 | npmName: string, | 89 | npmName: string |
90 | settings: any, | 90 | settings: any |
91 | expectedStatus?: number | 91 | expectedStatus?: number |
92 | }) { | 92 | }) { |
93 | const { url, accessToken, npmName, settings, expectedStatus = 204 } = parameters | 93 | const { url, accessToken, npmName, settings, expectedStatus = 204 } = parameters |
@@ -103,9 +103,9 @@ function updatePluginSettings (parameters: { | |||
103 | } | 103 | } |
104 | 104 | ||
105 | function getPluginRegisteredSettings (parameters: { | 105 | function getPluginRegisteredSettings (parameters: { |
106 | url: string, | 106 | url: string |
107 | accessToken: string, | 107 | accessToken: string |
108 | npmName: string, | 108 | npmName: string |
109 | expectedStatus?: number | 109 | expectedStatus?: number |
110 | }) { | 110 | }) { |
111 | const { url, accessToken, npmName, expectedStatus = 200 } = parameters | 111 | const { url, accessToken, npmName, expectedStatus = 200 } = parameters |
@@ -120,8 +120,8 @@ function getPluginRegisteredSettings (parameters: { | |||
120 | } | 120 | } |
121 | 121 | ||
122 | function getPublicSettings (parameters: { | 122 | function getPublicSettings (parameters: { |
123 | url: string, | 123 | url: string |
124 | npmName: string, | 124 | npmName: string |
125 | expectedStatus?: number | 125 | expectedStatus?: number |
126 | }) { | 126 | }) { |
127 | const { url, npmName, expectedStatus = 200 } = parameters | 127 | const { url, npmName, expectedStatus = 200 } = parameters |
@@ -135,8 +135,8 @@ function getPublicSettings (parameters: { | |||
135 | } | 135 | } |
136 | 136 | ||
137 | function getPluginTranslations (parameters: { | 137 | function getPluginTranslations (parameters: { |
138 | url: string, | 138 | url: string |
139 | locale: string, | 139 | locale: string |
140 | expectedStatus?: number | 140 | expectedStatus?: number |
141 | }) { | 141 | }) { |
142 | const { url, locale, expectedStatus = 200 } = parameters | 142 | const { url, locale, expectedStatus = 200 } = parameters |
@@ -150,9 +150,9 @@ function getPluginTranslations (parameters: { | |||
150 | } | 150 | } |
151 | 151 | ||
152 | function installPlugin (parameters: { | 152 | function installPlugin (parameters: { |
153 | url: string, | 153 | url: string |
154 | accessToken: string, | 154 | accessToken: string |
155 | path?: string, | 155 | path?: string |
156 | npmName?: string | 156 | npmName?: string |
157 | expectedStatus?: number | 157 | expectedStatus?: number |
158 | }) { | 158 | }) { |
@@ -169,9 +169,9 @@ function installPlugin (parameters: { | |||
169 | } | 169 | } |
170 | 170 | ||
171 | function updatePlugin (parameters: { | 171 | function updatePlugin (parameters: { |
172 | url: string, | 172 | url: string |
173 | accessToken: string, | 173 | accessToken: string |
174 | path?: string, | 174 | path?: string |
175 | npmName?: string | 175 | npmName?: string |
176 | expectedStatus?: number | 176 | expectedStatus?: number |
177 | }) { | 177 | }) { |
@@ -188,8 +188,8 @@ function updatePlugin (parameters: { | |||
188 | } | 188 | } |
189 | 189 | ||
190 | function uninstallPlugin (parameters: { | 190 | function uninstallPlugin (parameters: { |
191 | url: string, | 191 | url: string |
192 | accessToken: string, | 192 | accessToken: string |
193 | npmName: string | 193 | npmName: string |
194 | expectedStatus?: number | 194 | expectedStatus?: number |
195 | }) { | 195 | }) { |
diff --git a/shared/extra-utils/server/redundancy.ts b/shared/extra-utils/server/redundancy.ts index 7b488e23e..08467e4c0 100644 --- a/shared/extra-utils/server/redundancy.ts +++ b/shared/extra-utils/server/redundancy.ts | |||
@@ -15,11 +15,11 @@ function updateRedundancy (url: string, accessToken: string, host: string, redun | |||
15 | 15 | ||
16 | function listVideoRedundancies (options: { | 16 | function listVideoRedundancies (options: { |
17 | url: string | 17 | url: string |
18 | accessToken: string, | 18 | accessToken: string |
19 | target: VideoRedundanciesTarget, | 19 | target: VideoRedundanciesTarget |
20 | start?: number, | 20 | start?: number |
21 | count?: number, | 21 | count?: number |
22 | sort?: string, | 22 | sort?: string |
23 | statusCodeExpected?: number | 23 | statusCodeExpected?: number |
24 | }) { | 24 | }) { |
25 | const path = '/api/v1/server/redundancy/videos' | 25 | const path = '/api/v1/server/redundancy/videos' |
@@ -41,8 +41,8 @@ function listVideoRedundancies (options: { | |||
41 | } | 41 | } |
42 | 42 | ||
43 | function addVideoRedundancy (options: { | 43 | function addVideoRedundancy (options: { |
44 | url: string, | 44 | url: string |
45 | accessToken: string, | 45 | accessToken: string |
46 | videoId: number | 46 | videoId: number |
47 | }) { | 47 | }) { |
48 | const path = '/api/v1/server/redundancy/videos' | 48 | const path = '/api/v1/server/redundancy/videos' |
@@ -58,8 +58,8 @@ function addVideoRedundancy (options: { | |||
58 | } | 58 | } |
59 | 59 | ||
60 | function removeVideoRedundancy (options: { | 60 | function removeVideoRedundancy (options: { |
61 | url: string, | 61 | url: string |
62 | accessToken: string, | 62 | accessToken: string |
63 | redundancyId: number | 63 | redundancyId: number |
64 | }) { | 64 | }) { |
65 | const { url, accessToken, redundancyId } = options | 65 | const { url, accessToken, redundancyId } = options |
diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts index a0720d778..a0f0ce9c9 100644 --- a/shared/extra-utils/server/servers.ts +++ b/shared/extra-utils/server/servers.ts | |||
@@ -1,16 +1,15 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */ |
2 | 2 | ||
3 | import { ChildProcess, exec, fork } from 'child_process' | 3 | import { ChildProcess, exec, fork } from 'child_process' |
4 | import { join } from 'path' | 4 | import { join } from 'path' |
5 | import { root, wait } from '../miscs/miscs' | 5 | import { root, wait } from '../miscs/miscs' |
6 | import { copy, pathExists, readdir, readFile, remove } from 'fs-extra' | 6 | import { copy, pathExists, readdir, readFile, remove } from 'fs-extra' |
7 | import { existsSync } from 'fs' | ||
8 | import { expect } from 'chai' | 7 | import { expect } from 'chai' |
9 | import { VideoChannel } from '../../models/videos' | 8 | import { VideoChannel } from '../../models/videos' |
10 | import { randomInt } from '../../core-utils/miscs/miscs' | 9 | import { randomInt } from '../../core-utils/miscs/miscs' |
11 | 10 | ||
12 | interface ServerInfo { | 11 | interface ServerInfo { |
13 | app: ChildProcess, | 12 | app: ChildProcess |
14 | url: string | 13 | url: string |
15 | host: string | 14 | host: string |
16 | 15 | ||
@@ -20,13 +19,13 @@ interface ServerInfo { | |||
20 | serverNumber: number | 19 | serverNumber: number |
21 | 20 | ||
22 | client: { | 21 | client: { |
23 | id: string, | 22 | id: string |
24 | secret: string | 23 | secret: string |
25 | } | 24 | } |
26 | 25 | ||
27 | user: { | 26 | user: { |
28 | username: string, | 27 | username: string |
29 | password: string, | 28 | password: string |
30 | email?: string | 29 | email?: string |
31 | } | 30 | } |
32 | 31 | ||
@@ -57,7 +56,7 @@ function parallelTests () { | |||
57 | } | 56 | } |
58 | 57 | ||
59 | function flushAndRunMultipleServers (totalServers: number, configOverride?: Object) { | 58 | function flushAndRunMultipleServers (totalServers: number, configOverride?: Object) { |
60 | let apps = [] | 59 | const apps = [] |
61 | let i = 0 | 60 | let i = 0 |
62 | 61 | ||
63 | return new Promise<ServerInfo[]>(res => { | 62 | return new Promise<ServerInfo[]>(res => { |
@@ -203,20 +202,20 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = [] | |||
203 | 202 | ||
204 | // Capture things if we want to | 203 | // Capture things if we want to |
205 | for (const key of Object.keys(regexps)) { | 204 | for (const key of Object.keys(regexps)) { |
206 | const regexp = regexps[ key ] | 205 | const regexp = regexps[key] |
207 | const matches = data.toString().match(regexp) | 206 | const matches = data.toString().match(regexp) |
208 | if (matches !== null) { | 207 | if (matches !== null) { |
209 | if (key === 'client_id') server.client.id = matches[ 1 ] | 208 | if (key === 'client_id') server.client.id = matches[1] |
210 | else if (key === 'client_secret') server.client.secret = matches[ 1 ] | 209 | else if (key === 'client_secret') server.client.secret = matches[1] |
211 | else if (key === 'user_username') server.user.username = matches[ 1 ] | 210 | else if (key === 'user_username') server.user.username = matches[1] |
212 | else if (key === 'user_password') server.user.password = matches[ 1 ] | 211 | else if (key === 'user_password') server.user.password = matches[1] |
213 | } | 212 | } |
214 | } | 213 | } |
215 | 214 | ||
216 | // Check if all required sentences are here | 215 | // Check if all required sentences are here |
217 | for (const key of Object.keys(serverRunString)) { | 216 | for (const key of Object.keys(serverRunString)) { |
218 | if (data.toString().indexOf(key) !== -1) serverRunString[ key ] = true | 217 | if (data.toString().indexOf(key) !== -1) serverRunString[key] = true |
219 | if (serverRunString[ key ] === false) dontContinue = true | 218 | if (serverRunString[key] === false) dontContinue = true |
220 | } | 219 | } |
221 | 220 | ||
222 | // If no, there is maybe one thing not already initialized (client/user credentials generation...) | 221 | // If no, there is maybe one thing not already initialized (client/user credentials generation...) |