aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-05-07 11:53:46 +0200
committerChocobozzz <me@florianbigard.com>2021-05-07 11:53:46 +0200
commita1bb73f9b591686b2ddfeb3291f305dae9f7fc6c (patch)
tree0386b60da767075a890d45d947a6805ca32fd742 /shared
parentbc4c9cc1d75d591c217d61ab22a107b7f1044c76 (diff)
downloadPeerTube-a1bb73f9b591686b2ddfeb3291f305dae9f7fc6c.tar.gz
PeerTube-a1bb73f9b591686b2ddfeb3291f305dae9f7fc6c.tar.zst
PeerTube-a1bb73f9b591686b2ddfeb3291f305dae9f7fc6c.zip
Refactor a little bit live tests
Diffstat (limited to 'shared')
-rw-r--r--shared/extra-utils/server/config.ts15
-rw-r--r--shared/extra-utils/users/users.ts23
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
226function 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
226function deleteCustomConfig (url: string, token: string, statusCodeExpected = HttpStatusCode.OK_200) { 238function 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 @@
1import { omit } from 'lodash' 1import { omit } from 'lodash'
2import * as request from 'supertest' 2import * as request from 'supertest'
3import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
3import { UserUpdateMe } from '../../models/users' 4import { UserUpdateMe } from '../../models/users'
4import { UserAdminFlag } from '../../models/users/user-flag.model' 5import { UserAdminFlag } from '../../models/users/user-flag.model'
5import { UserRegister } from '../../models/users/user-register.model' 6import { UserRegister } from '../../models/users/user-register.model'
@@ -7,9 +8,8 @@ import { UserRole } from '../../models/users/user-role'
7import { makeGetRequest, makePostBodyRequest, makePutBodyRequest, updateImageRequest } from '../requests/requests' 8import { makeGetRequest, makePostBodyRequest, makePutBodyRequest, updateImageRequest } from '../requests/requests'
8import { ServerInfo } from '../server/servers' 9import { ServerInfo } from '../server/servers'
9import { userLogin } from './login' 10import { userLogin } from './login'
10import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
11 11
12type CreateUserArgs = { 12function 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}) {
23function 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
54async 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
55async function generateUserAccessToken (server: ServerInfo, username: string) { 69async 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,