aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/users.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/check-params/users.ts')
-rw-r--r--server/tests/api/check-params/users.ts35
1 files changed, 33 insertions, 2 deletions
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts
index 5935104a5..95097817b 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'
6import { UserRole, VideoImport, VideoImportState } from '../../../../shared' 6import { UserRole, VideoImport, VideoImportState } from '../../../../shared'
7 7
8import { 8import {
9 addVideoChannel,
9 blockUser, 10 blockUser,
10 cleanupTests, 11 cleanupTests,
11 createUser, 12 createUser,
@@ -638,7 +639,7 @@ describe('Test users API validators', function () {
638 }) 639 })
639 }) 640 })
640 641
641 describe('When register a new user', function () { 642 describe('When registering a new user', function () {
642 const registrationPath = path + '/register' 643 const registrationPath = path + '/register'
643 const baseCorrectParams = { 644 const baseCorrectParams = {
644 username: 'user3', 645 username: 'user3',
@@ -724,12 +725,42 @@ describe('Test users API validators', function () {
724 }) 725 })
725 }) 726 })
726 727
728 it('Should fail with a bad channel name', async function () {
729 const fields = immutableAssign(baseCorrectParams, { channel: { name: '[]azf', displayName: 'toto' } })
730
731 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
732 })
733
734 it('Should fail with a bad channel display name', async function () {
735 const fields = immutableAssign(baseCorrectParams, { channel: { name: 'toto', displayName: '' } })
736
737 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
738 })
739
740 it('Should fail with a channel name that is the same than user username', async function () {
741 const source = { username: 'super_user', channel: { name: 'super_user', displayName: 'display name' } }
742 const fields = immutableAssign(baseCorrectParams, source)
743
744 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
745 })
746
747 it('Should fail with an existing channel', async function () {
748 const videoChannelAttributesArg = { name: 'existing_channel', displayName: 'hello', description: 'super description' }
749 await addVideoChannel(server.url, server.accessToken, videoChannelAttributesArg)
750
751 const fields = immutableAssign(baseCorrectParams, { channel: { name: 'existing_channel', displayName: 'toto' } })
752
753 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields, statusCodeExpected: 409 })
754 })
755
727 it('Should succeed with the correct params', async function () { 756 it('Should succeed with the correct params', async function () {
757 const fields = immutableAssign(baseCorrectParams, { channel: { name: 'super_channel', displayName: 'toto' } })
758
728 await makePostBodyRequest({ 759 await makePostBodyRequest({
729 url: server.url, 760 url: server.url,
730 path: registrationPath, 761 path: registrationPath,
731 token: server.accessToken, 762 token: server.accessToken,
732 fields: baseCorrectParams, 763 fields: fields,
733 statusCodeExpected: 204 764 statusCodeExpected: 204
734 }) 765 })
735 }) 766 })