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 /server/tests/api | |
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 'server/tests/api')
-rw-r--r-- | server/tests/api/check-params/users.ts | 28 | ||||
-rw-r--r-- | server/tests/api/users/users.ts | 14 |
2 files changed, 38 insertions, 4 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 | }) |
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 { | |||
31 | updateMyUser, | 31 | updateMyUser, |
32 | updateUser, | 32 | updateUser, |
33 | uploadVideo, | 33 | uploadVideo, |
34 | userLogin | 34 | userLogin, |
35 | registerUserWithChannel, getVideoChannel | ||
35 | } from '../../../../shared/extra-utils' | 36 | } from '../../../../shared/extra-utils' |
36 | import { follow } from '../../../../shared/extra-utils/server/follows' | 37 | import { follow } from '../../../../shared/extra-utils/server/follows' |
37 | import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login' | 38 | import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login' |
@@ -617,7 +618,10 @@ describe('Test users', function () { | |||
617 | 618 | ||
618 | describe('Registering a new user', function () { | 619 | describe('Registering a new user', function () { |
619 | it('Should register a new user', async function () { | 620 | it('Should register a new user', async function () { |
620 | await registerUser(server.url, 'user_15', 'my super password') | 621 | const user = { username: 'user_15', password: 'my super password' } |
622 | const channel = { name: 'my_user_15_channel', displayName: 'my channel rocks' } | ||
623 | |||
624 | await registerUserWithChannel({ url: server.url, user, channel }) | ||
621 | }) | 625 | }) |
622 | 626 | ||
623 | it('Should be able to login with this registered user', async function () { | 627 | it('Should be able to login with this registered user', async function () { |
@@ -636,6 +640,12 @@ describe('Test users', function () { | |||
636 | expect(user.videoQuota).to.equal(5 * 1024 * 1024) | 640 | expect(user.videoQuota).to.equal(5 * 1024 * 1024) |
637 | }) | 641 | }) |
638 | 642 | ||
643 | it('Should have created the channel', async function () { | ||
644 | const res = await getVideoChannel(server.url, 'my_user_15_channel') | ||
645 | |||
646 | expect(res.body.displayName).to.equal('my channel rocks') | ||
647 | }) | ||
648 | |||
639 | it('Should remove me', async function () { | 649 | it('Should remove me', async function () { |
640 | { | 650 | { |
641 | const res = await getUsersList(server.url, server.accessToken) | 651 | const res = await getUsersList(server.url, server.accessToken) |