From e590b4a512617bbf63595b684386f68abea7d8b8 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 28 May 2019 10:46:32 +0200 Subject: Add ability to specify channel on registration --- shared/extra-utils/users/users.ts | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'shared/extra-utils/users') 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 @@ import * as request from 'supertest' -import { makePostBodyRequest, makePutBodyRequest, updateAvatarRequest } from '../requests/requests' +import { makeGetRequest, makePostBodyRequest, makePutBodyRequest, updateAvatarRequest } from '../requests/requests' -import { UserRole } from '../../index' +import { UserCreate, UserRole } from '../../index' import { NSFWPolicyType } from '../../models/videos/nsfw-policy.type' import { ServerInfo, userLogin } from '..' import { UserAdminFlag } from '../../models/users/user-flag.model' +import { UserRegister } from '../../models/users/user-register.model' type CreateUserArgs = { url: string, accessToken: string, @@ -70,6 +71,27 @@ function registerUser (url: string, username: string, password: string, specialS .expect(specialStatus) } +function registerUserWithChannel (options: { + url: string, + user: { username: string, password: string }, + channel: { name: string, displayName: string } +}) { + const path = '/api/v1/users/register' + const body: UserRegister = { + username: options.user.username, + password: options.user.password, + email: options.user.username + '@example.com', + channel: options.channel + } + + return makePostBodyRequest({ + url: options.url, + path, + fields: body, + statusCodeExpected: 204 + }) +} + function getMyUserInformation (url: string, accessToken: string, specialStatus = 200) { const path = '/api/v1/users/me' @@ -312,6 +334,7 @@ export { getMyUserInformation, getMyUserVideoRating, deleteMe, + registerUserWithChannel, getMyUserVideoQuotaUsed, getUsersList, getUsersListPaginationAndSort, -- cgit v1.2.3