diff options
author | Chocobozzz <me@florianbigard.com> | 2019-05-28 10:46:32 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-05-28 10:46:32 +0200 |
commit | e590b4a512617bbf63595b684386f68abea7d8b8 (patch) | |
tree | e5a173ffce942787ea8285239ee235a3f3607e65 /shared/extra-utils | |
parent | cce1b3dfd386c77a02f2b4f18f60bd916a60a2d3 (diff) | |
download | PeerTube-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.ts | 27 |
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 @@ | |||
1 | import * as request from 'supertest' | 1 | import * as request from 'supertest' |
2 | import { makePostBodyRequest, makePutBodyRequest, updateAvatarRequest } from '../requests/requests' | 2 | import { makeGetRequest, makePostBodyRequest, makePutBodyRequest, updateAvatarRequest } from '../requests/requests' |
3 | 3 | ||
4 | import { UserRole } from '../../index' | 4 | import { UserCreate, UserRole } from '../../index' |
5 | import { NSFWPolicyType } from '../../models/videos/nsfw-policy.type' | 5 | import { NSFWPolicyType } from '../../models/videos/nsfw-policy.type' |
6 | import { ServerInfo, userLogin } from '..' | 6 | import { ServerInfo, userLogin } from '..' |
7 | import { UserAdminFlag } from '../../models/users/user-flag.model' | 7 | import { UserAdminFlag } from '../../models/users/user-flag.model' |
8 | import { UserRegister } from '../../models/users/user-register.model' | ||
8 | 9 | ||
9 | type CreateUserArgs = { url: string, | 10 | type 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 | ||
74 | function 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 | |||
73 | function getMyUserInformation (url: string, accessToken: string, specialStatus = 200) { | 95 | function 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, |