diff options
Diffstat (limited to 'server/tests/api/check-params/users.ts')
-rw-r--r-- | server/tests/api/check-params/users.ts | 28 |
1 files changed, 26 insertions, 2 deletions
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' | |||
6 | import { UserRole, VideoImport, VideoImportState } from '../../../../shared' | 6 | import { UserRole, VideoImport, VideoImportState } from '../../../../shared' |
7 | 7 | ||
8 | import { | 8 | import { |
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,35 @@ 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 an existing channel', async function () { | ||
741 | const videoChannelAttributesArg = { name: 'existing_channel', displayName: 'hello', description: 'super description' } | ||
742 | await addVideoChannel(server.url, server.accessToken, videoChannelAttributesArg) | ||
743 | |||
744 | const fields = immutableAssign(baseCorrectParams, { channel: { name: 'existing_channel', displayName: 'toto' } }) | ||
745 | |||
746 | await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields, statusCodeExpected: 409 }) | ||
747 | }) | ||
748 | |||
727 | it('Should succeed with the correct params', async function () { | 749 | it('Should succeed with the correct params', async function () { |
750 | const fields = immutableAssign(baseCorrectParams, { channel: { name: 'super_channel', displayName: 'toto' } }) | ||
751 | |||
728 | await makePostBodyRequest({ | 752 | await makePostBodyRequest({ |
729 | url: server.url, | 753 | url: server.url, |
730 | path: registrationPath, | 754 | path: registrationPath, |
731 | token: server.accessToken, | 755 | token: server.accessToken, |
732 | fields: baseCorrectParams, | 756 | fields: fields, |
733 | statusCodeExpected: 204 | 757 | statusCodeExpected: 204 |
734 | }) | 758 | }) |
735 | }) | 759 | }) |