aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-05-28 10:46:32 +0200
committerChocobozzz <me@florianbigard.com>2019-05-28 10:46:32 +0200
commite590b4a512617bbf63595b684386f68abea7d8b8 (patch)
treee5a173ffce942787ea8285239ee235a3f3607e65 /shared/extra-utils
parentcce1b3dfd386c77a02f2b4f18f60bd916a60a2d3 (diff)
downloadPeerTube-e590b4a512617bbf63595b684386f68abea7d8b8.tar.gz
PeerTube-e590b4a512617bbf63595b684386f68abea7d8b8.tar.zst
PeerTube-e590b4a512617bbf63595b684386f68abea7d8b8.zip
Add ability to specify channel on registration
Diffstat (limited to 'shared/extra-utils')
-rw-r--r--shared/extra-utils/users/users.ts27
1 files changed, 25 insertions, 2 deletions
diff --git a/shared/extra-utils/users/users.ts b/shared/extra-utils/users/users.ts
index 2bd37b8be..c00da19e0 100644
--- a/shared/extra-utils/users/users.ts
+++ b/shared/extra-utils/users/users.ts
@@ -1,10 +1,11 @@
1import * as request from 'supertest' 1import * as request from 'supertest'
2import { makePostBodyRequest, makePutBodyRequest, updateAvatarRequest } from '../requests/requests' 2import { makeGetRequest, makePostBodyRequest, makePutBodyRequest, updateAvatarRequest } from '../requests/requests'
3 3
4import { UserRole } from '../../index' 4import { UserCreate, UserRole } from '../../index'
5import { NSFWPolicyType } from '../../models/videos/nsfw-policy.type' 5import { NSFWPolicyType } from '../../models/videos/nsfw-policy.type'
6import { ServerInfo, userLogin } from '..' 6import { ServerInfo, userLogin } from '..'
7import { UserAdminFlag } from '../../models/users/user-flag.model' 7import { UserAdminFlag } from '../../models/users/user-flag.model'
8import { UserRegister } from '../../models/users/user-register.model'
8 9
9type CreateUserArgs = { url: string, 10type CreateUserArgs = { url: string,
10 accessToken: string, 11 accessToken: string,
@@ -70,6 +71,27 @@ function registerUser (url: string, username: string, password: string, specialS
70 .expect(specialStatus) 71 .expect(specialStatus)
71} 72}
72 73
74function registerUserWithChannel (options: {
75 url: string,
76 user: { username: string, password: string },
77 channel: { name: string, displayName: string }
78}) {
79 const path = '/api/v1/users/register'
80 const body: UserRegister = {
81 username: options.user.username,
82 password: options.user.password,
83 email: options.user.username + '@example.com',
84 channel: options.channel
85 }
86
87 return makePostBodyRequest({
88 url: options.url,
89 path,
90 fields: body,
91 statusCodeExpected: 204
92 })
93}
94
73function getMyUserInformation (url: string, accessToken: string, specialStatus = 200) { 95function getMyUserInformation (url: string, accessToken: string, specialStatus = 200) {
74 const path = '/api/v1/users/me' 96 const path = '/api/v1/users/me'
75 97
@@ -312,6 +334,7 @@ export {
312 getMyUserInformation, 334 getMyUserInformation,
313 getMyUserVideoRating, 335 getMyUserVideoRating,
314 deleteMe, 336 deleteMe,
337 registerUserWithChannel,
315 getMyUserVideoQuotaUsed, 338 getMyUserVideoQuotaUsed,
316 getUsersList, 339 getUsersList,
317 getUsersListPaginationAndSort, 340 getUsersListPaginationAndSort,