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 --- server/tests/api/check-params/users.ts | 28 ++++++++++++++++++++++++++-- server/tests/api/users/users.ts | 14 ++++++++++++-- 2 files changed, 38 insertions(+), 4 deletions(-) (limited to 'server/tests') diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index 5935104a5..d26032ea5 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts @@ -6,6 +6,7 @@ import { join } from 'path' import { UserRole, VideoImport, VideoImportState } from '../../../../shared' import { + addVideoChannel, blockUser, cleanupTests, createUser, @@ -638,7 +639,7 @@ describe('Test users API validators', function () { }) }) - describe('When register a new user', function () { + describe('When registering a new user', function () { const registrationPath = path + '/register' const baseCorrectParams = { username: 'user3', @@ -724,12 +725,35 @@ describe('Test users API validators', function () { }) }) + it('Should fail with a bad channel name', async function () { + const fields = immutableAssign(baseCorrectParams, { channel: { name: '[]azf', displayName: 'toto' } }) + + await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }) + }) + + it('Should fail with a bad channel display name', async function () { + const fields = immutableAssign(baseCorrectParams, { channel: { name: 'toto', displayName: '' } }) + + await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }) + }) + + it('Should fail with an existing channel', async function () { + const videoChannelAttributesArg = { name: 'existing_channel', displayName: 'hello', description: 'super description' } + await addVideoChannel(server.url, server.accessToken, videoChannelAttributesArg) + + const fields = immutableAssign(baseCorrectParams, { channel: { name: 'existing_channel', displayName: 'toto' } }) + + await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields, statusCodeExpected: 409 }) + }) + it('Should succeed with the correct params', async function () { + const fields = immutableAssign(baseCorrectParams, { channel: { name: 'super_channel', displayName: 'toto' } }) + await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, - fields: baseCorrectParams, + fields: fields, statusCodeExpected: 204 }) }) diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts index c1a24b838..9d2ef786f 100644 --- a/server/tests/api/users/users.ts +++ b/server/tests/api/users/users.ts @@ -31,7 +31,8 @@ import { updateMyUser, updateUser, uploadVideo, - userLogin + userLogin, + registerUserWithChannel, getVideoChannel } from '../../../../shared/extra-utils' import { follow } from '../../../../shared/extra-utils/server/follows' import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login' @@ -617,7 +618,10 @@ describe('Test users', function () { describe('Registering a new user', function () { it('Should register a new user', async function () { - await registerUser(server.url, 'user_15', 'my super password') + const user = { username: 'user_15', password: 'my super password' } + const channel = { name: 'my_user_15_channel', displayName: 'my channel rocks' } + + await registerUserWithChannel({ url: server.url, user, channel }) }) it('Should be able to login with this registered user', async function () { @@ -636,6 +640,12 @@ describe('Test users', function () { expect(user.videoQuota).to.equal(5 * 1024 * 1024) }) + it('Should have created the channel', async function () { + const res = await getVideoChannel(server.url, 'my_user_15_channel') + + expect(res.body.displayName).to.equal('my channel rocks') + }) + it('Should remove me', async function () { { const res = await getUsersList(server.url, server.accessToken) -- cgit v1.2.3