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.ts74
1 files changed, 37 insertions, 37 deletions
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts
index 33c48a009..bce3f0774 100644
--- a/server/tests/api/check-params/users.ts
+++ b/server/tests/api/check-params/users.ts
@@ -60,27 +60,27 @@ describe('Test users API validators', function () {
60 60
61 { 61 {
62 const user = { username: 'user1' } 62 const user = { username: 'user1' }
63 await server.usersCommand.create({ ...user }) 63 await server.users.create({ ...user })
64 userToken = await server.loginCommand.getAccessToken(user) 64 userToken = await server.login.getAccessToken(user)
65 } 65 }
66 66
67 { 67 {
68 const moderator = { username: 'moderator1' } 68 const moderator = { username: 'moderator1' }
69 await server.usersCommand.create({ ...moderator, role: UserRole.MODERATOR }) 69 await server.users.create({ ...moderator, role: UserRole.MODERATOR })
70 moderatorToken = await server.loginCommand.getAccessToken(moderator) 70 moderatorToken = await server.login.getAccessToken(moderator)
71 } 71 }
72 72
73 { 73 {
74 const moderator = { username: 'moderator2' } 74 const moderator = { username: 'moderator2' }
75 await server.usersCommand.create({ ...moderator, role: UserRole.MODERATOR }) 75 await server.users.create({ ...moderator, role: UserRole.MODERATOR })
76 } 76 }
77 77
78 { 78 {
79 video = await server.videosCommand.upload() 79 video = await server.videos.upload()
80 } 80 }
81 81
82 { 82 {
83 const { data } = await server.usersCommand.list() 83 const { data } = await server.users.list()
84 userId = data.find(u => u.username === 'user1').id 84 userId = data.find(u => u.username === 'user1').id
85 rootId = data.find(u => u.username === 'root').id 85 rootId = data.find(u => u.username === 'root').id
86 moderatorId = data.find(u => u.username === 'moderator2').id 86 moderatorId = data.find(u => u.username === 'moderator2').id
@@ -341,7 +341,7 @@ describe('Test users API validators', function () {
341 341
342 it('Should fail with a non admin user', async function () { 342 it('Should fail with a non admin user', async function () {
343 const user = { username: 'user1' } 343 const user = { username: 'user1' }
344 userToken = await server.loginCommand.getAccessToken(user) 344 userToken = await server.login.getAccessToken(user)
345 345
346 const fields = { 346 const fields = {
347 username: 'user3', 347 username: 'user3',
@@ -596,28 +596,28 @@ describe('Test users API validators', function () {
596 describe('When managing my scoped tokens', function () { 596 describe('When managing my scoped tokens', function () {
597 597
598 it('Should fail to get my scoped tokens with an non authenticated user', async function () { 598 it('Should fail to get my scoped tokens with an non authenticated user', async function () {
599 await server.usersCommand.getMyScopedTokens({ token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 599 await server.users.getMyScopedTokens({ token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
600 }) 600 })
601 601
602 it('Should fail to get my scoped tokens with a bad token', async function () { 602 it('Should fail to get my scoped tokens with a bad token', async function () {
603 await server.usersCommand.getMyScopedTokens({ token: 'bad', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 603 await server.users.getMyScopedTokens({ token: 'bad', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
604 604
605 }) 605 })
606 606
607 it('Should succeed to get my scoped tokens', async function () { 607 it('Should succeed to get my scoped tokens', async function () {
608 await server.usersCommand.getMyScopedTokens() 608 await server.users.getMyScopedTokens()
609 }) 609 })
610 610
611 it('Should fail to renew my scoped tokens with an non authenticated user', async function () { 611 it('Should fail to renew my scoped tokens with an non authenticated user', async function () {
612 await server.usersCommand.renewMyScopedTokens({ token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 612 await server.users.renewMyScopedTokens({ token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
613 }) 613 })
614 614
615 it('Should fail to renew my scoped tokens with a bad token', async function () { 615 it('Should fail to renew my scoped tokens with a bad token', async function () {
616 await server.usersCommand.renewMyScopedTokens({ token: 'bad', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 616 await server.users.renewMyScopedTokens({ token: 'bad', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
617 }) 617 })
618 618
619 it('Should succeed to renew my scoped tokens', async function () { 619 it('Should succeed to renew my scoped tokens', async function () {
620 await server.usersCommand.renewMyScopedTokens() 620 await server.users.renewMyScopedTokens()
621 }) 621 })
622 }) 622 })
623 623
@@ -769,11 +769,11 @@ describe('Test users API validators', function () {
769 769
770 describe('When getting my information', function () { 770 describe('When getting my information', function () {
771 it('Should fail with a non authenticated user', async function () { 771 it('Should fail with a non authenticated user', async function () {
772 await server.usersCommand.getMyInfo({ token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 772 await server.users.getMyInfo({ token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
773 }) 773 })
774 774
775 it('Should success with the correct parameters', async function () { 775 it('Should success with the correct parameters', async function () {
776 await server.usersCommand.getMyInfo({ token: userToken }) 776 await server.users.getMyInfo({ token: userToken })
777 }) 777 })
778 }) 778 })
779 779
@@ -781,7 +781,7 @@ describe('Test users API validators', function () {
781 let command: UsersCommand 781 let command: UsersCommand
782 782
783 before(function () { 783 before(function () {
784 command = server.usersCommand 784 command = server.users
785 }) 785 })
786 786
787 it('Should fail with a non authenticated user', async function () { 787 it('Should fail with a non authenticated user', async function () {
@@ -846,54 +846,54 @@ describe('Test users API validators', function () {
846 it('Should fail with an incorrect id', async function () { 846 it('Should fail with an incorrect id', async function () {
847 const options = { userId: 'blabla' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 } 847 const options = { userId: 'blabla' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }
848 848
849 await server.usersCommand.remove(options) 849 await server.users.remove(options)
850 await server.usersCommand.banUser({ userId: 'blabla' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 850 await server.users.banUser({ userId: 'blabla' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
851 await server.usersCommand.unbanUser({ userId: 'blabla' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 851 await server.users.unbanUser({ userId: 'blabla' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
852 }) 852 })
853 853
854 it('Should fail with the root user', async function () { 854 it('Should fail with the root user', async function () {
855 const options = { userId: rootId, expectedStatus: HttpStatusCode.BAD_REQUEST_400 } 855 const options = { userId: rootId, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }
856 856
857 await server.usersCommand.remove(options) 857 await server.users.remove(options)
858 await server.usersCommand.banUser(options) 858 await server.users.banUser(options)
859 await server.usersCommand.unbanUser(options) 859 await server.users.unbanUser(options)
860 }) 860 })
861 861
862 it('Should return 404 with a non existing id', async function () { 862 it('Should return 404 with a non existing id', async function () {
863 const options = { userId: 4545454, expectedStatus: HttpStatusCode.NOT_FOUND_404 } 863 const options = { userId: 4545454, expectedStatus: HttpStatusCode.NOT_FOUND_404 }
864 864
865 await server.usersCommand.remove(options) 865 await server.users.remove(options)
866 await server.usersCommand.banUser(options) 866 await server.users.banUser(options)
867 await server.usersCommand.unbanUser(options) 867 await server.users.unbanUser(options)
868 }) 868 })
869 869
870 it('Should fail with a non admin user', async function () { 870 it('Should fail with a non admin user', async function () {
871 const options = { userId, token: userToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 } 871 const options = { userId, token: userToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }
872 872
873 await server.usersCommand.remove(options) 873 await server.users.remove(options)
874 await server.usersCommand.banUser(options) 874 await server.users.banUser(options)
875 await server.usersCommand.unbanUser(options) 875 await server.users.unbanUser(options)
876 }) 876 })
877 877
878 it('Should fail on a moderator with a moderator', async function () { 878 it('Should fail on a moderator with a moderator', async function () {
879 const options = { userId: moderatorId, token: moderatorToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 } 879 const options = { userId: moderatorId, token: moderatorToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }
880 880
881 await server.usersCommand.remove(options) 881 await server.users.remove(options)
882 await server.usersCommand.banUser(options) 882 await server.users.banUser(options)
883 await server.usersCommand.unbanUser(options) 883 await server.users.unbanUser(options)
884 }) 884 })
885 885
886 it('Should succeed on a user with a moderator', async function () { 886 it('Should succeed on a user with a moderator', async function () {
887 const options = { userId, token: moderatorToken } 887 const options = { userId, token: moderatorToken }
888 888
889 await server.usersCommand.banUser(options) 889 await server.users.banUser(options)
890 await server.usersCommand.unbanUser(options) 890 await server.users.unbanUser(options)
891 }) 891 })
892 }) 892 })
893 893
894 describe('When deleting our account', function () { 894 describe('When deleting our account', function () {
895 it('Should fail with with the root account', async function () { 895 it('Should fail with with the root account', async function () {
896 await server.usersCommand.deleteMe({ expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 896 await server.users.deleteMe({ expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
897 }) 897 })
898 }) 898 })
899 899
@@ -1011,7 +1011,7 @@ describe('Test users API validators', function () {
1011 1011
1012 it('Should fail with an existing channel', async function () { 1012 it('Should fail with an existing channel', async function () {
1013 const attributes = { name: 'existing_channel', displayName: 'hello', description: 'super description' } 1013 const attributes = { name: 'existing_channel', displayName: 'hello', description: 'super description' }
1014 await server.channelsCommand.create({ attributes }) 1014 await server.channels.create({ attributes })
1015 1015
1016 const fields = { ...baseCorrectParams, channel: { name: 'existing_channel', displayName: 'toto' } } 1016 const fields = { ...baseCorrectParams, channel: { name: 'existing_channel', displayName: 'toto' } }
1017 1017
@@ -1055,7 +1055,7 @@ describe('Test users API validators', function () {
1055 1055
1056 describe('When registering multiple users on a server with users limit', function () { 1056 describe('When registering multiple users on a server with users limit', function () {
1057 it('Should fail when after 3 registrations', async function () { 1057 it('Should fail when after 3 registrations', async function () {
1058 await server.usersCommand.register({ username: 'user42', expectedStatus: HttpStatusCode.FORBIDDEN_403 }) 1058 await server.users.register({ username: 'user42', expectedStatus: HttpStatusCode.FORBIDDEN_403 })
1059 }) 1059 })
1060 }) 1060 })
1061 1061