diff options
Diffstat (limited to 'shared/extra-utils')
-rw-r--r-- | shared/extra-utils/server/config.ts | 15 | ||||
-rw-r--r-- | shared/extra-utils/users/users.ts | 23 |
2 files changed, 33 insertions, 5 deletions
diff --git a/shared/extra-utils/server/config.ts b/shared/extra-utils/server/config.ts index 026a5e61c..b70110852 100644 --- a/shared/extra-utils/server/config.ts +++ b/shared/extra-utils/server/config.ts | |||
@@ -223,6 +223,18 @@ function updateCustomSubConfig (url: string, token: string, newConfig: DeepParti | |||
223 | return updateCustomConfig(url, token, updateParams) | 223 | return updateCustomConfig(url, token, updateParams) |
224 | } | 224 | } |
225 | 225 | ||
226 | function getCustomConfigResolutions (enabled: boolean) { | ||
227 | return { | ||
228 | '240p': enabled, | ||
229 | '360p': enabled, | ||
230 | '480p': enabled, | ||
231 | '720p': enabled, | ||
232 | '1080p': enabled, | ||
233 | '1440p': enabled, | ||
234 | '2160p': enabled | ||
235 | } | ||
236 | } | ||
237 | |||
226 | function deleteCustomConfig (url: string, token: string, statusCodeExpected = HttpStatusCode.OK_200) { | 238 | function deleteCustomConfig (url: string, token: string, statusCodeExpected = HttpStatusCode.OK_200) { |
227 | const path = '/api/v1/config/custom' | 239 | const path = '/api/v1/config/custom' |
228 | 240 | ||
@@ -242,5 +254,6 @@ export { | |||
242 | updateCustomConfig, | 254 | updateCustomConfig, |
243 | getAbout, | 255 | getAbout, |
244 | deleteCustomConfig, | 256 | deleteCustomConfig, |
245 | updateCustomSubConfig | 257 | updateCustomSubConfig, |
258 | getCustomConfigResolutions | ||
246 | } | 259 | } |
diff --git a/shared/extra-utils/users/users.ts b/shared/extra-utils/users/users.ts index 6040dd9c0..0f15962ad 100644 --- a/shared/extra-utils/users/users.ts +++ b/shared/extra-utils/users/users.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | import { omit } from 'lodash' | 1 | import { omit } from 'lodash' |
2 | import * as request from 'supertest' | 2 | import * as request from 'supertest' |
3 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
3 | import { UserUpdateMe } from '../../models/users' | 4 | import { UserUpdateMe } from '../../models/users' |
4 | import { UserAdminFlag } from '../../models/users/user-flag.model' | 5 | import { UserAdminFlag } from '../../models/users/user-flag.model' |
5 | import { UserRegister } from '../../models/users/user-register.model' | 6 | import { UserRegister } from '../../models/users/user-register.model' |
@@ -7,9 +8,8 @@ import { UserRole } from '../../models/users/user-role' | |||
7 | import { makeGetRequest, makePostBodyRequest, makePutBodyRequest, updateImageRequest } from '../requests/requests' | 8 | import { makeGetRequest, makePostBodyRequest, makePutBodyRequest, updateImageRequest } from '../requests/requests' |
8 | import { ServerInfo } from '../server/servers' | 9 | import { ServerInfo } from '../server/servers' |
9 | import { userLogin } from './login' | 10 | import { userLogin } from './login' |
10 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
11 | 11 | ||
12 | type CreateUserArgs = { | 12 | function createUser (parameters: { |
13 | url: string | 13 | url: string |
14 | accessToken: string | 14 | accessToken: string |
15 | username: string | 15 | username: string |
@@ -19,8 +19,7 @@ type CreateUserArgs = { | |||
19 | role?: UserRole | 19 | role?: UserRole |
20 | adminFlags?: UserAdminFlag | 20 | adminFlags?: UserAdminFlag |
21 | specialStatus?: number | 21 | specialStatus?: number |
22 | } | 22 | }) { |
23 | function createUser (parameters: CreateUserArgs) { | ||
24 | const { | 23 | const { |
25 | url, | 24 | url, |
26 | accessToken, | 25 | accessToken, |
@@ -52,6 +51,21 @@ function createUser (parameters: CreateUserArgs) { | |||
52 | .expect(specialStatus) | 51 | .expect(specialStatus) |
53 | } | 52 | } |
54 | 53 | ||
54 | async function generateUser (server: ServerInfo, username: string) { | ||
55 | const password = 'my super password' | ||
56 | const resCreate = await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password }) | ||
57 | |||
58 | const token = await userLogin(server, { username, password }) | ||
59 | |||
60 | const resMe = await getMyUserInformation(server.url, token) | ||
61 | |||
62 | return { | ||
63 | token, | ||
64 | userId: resCreate.body.user.id, | ||
65 | userChannelId: resMe.body.videoChannels[0].id | ||
66 | } | ||
67 | } | ||
68 | |||
55 | async function generateUserAccessToken (server: ServerInfo, username: string) { | 69 | async function generateUserAccessToken (server: ServerInfo, username: string) { |
56 | const password = 'my super password' | 70 | const password = 'my super password' |
57 | await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password }) | 71 | await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password }) |
@@ -393,6 +407,7 @@ export { | |||
393 | resetPassword, | 407 | resetPassword, |
394 | renewUserScopedTokens, | 408 | renewUserScopedTokens, |
395 | updateMyAvatar, | 409 | updateMyAvatar, |
410 | generateUser, | ||
396 | askSendVerifyEmail, | 411 | askSendVerifyEmail, |
397 | generateUserAccessToken, | 412 | generateUserAccessToken, |
398 | verifyEmail, | 413 | verifyEmail, |