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.ts56
1 files changed, 54 insertions, 2 deletions
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts
index b3fb61f6c..8b2ed1b04 100644
--- a/server/tests/api/check-params/users.ts
+++ b/server/tests/api/check-params/users.ts
@@ -94,6 +94,7 @@ describe('Test users API validators', function () {
94 email: 'test@example.com', 94 email: 'test@example.com',
95 password: 'my super password', 95 password: 'my super password',
96 videoQuota: -1, 96 videoQuota: -1,
97 videoQuotaDaily: -1,
97 role: UserRole.USER 98 role: UserRole.USER
98 } 99 }
99 100
@@ -173,12 +174,24 @@ describe('Test users API validators', function () {
173 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 174 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
174 }) 175 })
175 176
177 it('Should fail without a videoQuotaDaily', async function () {
178 const fields = omit(baseCorrectParams, 'videoQuotaDaily')
179
180 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
181 })
182
176 it('Should fail with an invalid videoQuota', async function () { 183 it('Should fail with an invalid videoQuota', async function () {
177 const fields = immutableAssign(baseCorrectParams, { videoQuota: -5 }) 184 const fields = immutableAssign(baseCorrectParams, { videoQuota: -5 })
178 185
179 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 186 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
180 }) 187 })
181 188
189 it('Should fail with an invalid videoQuotaDaily', async function () {
190 const fields = immutableAssign(baseCorrectParams, { videoQuotaDaily: -7 })
191
192 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
193 })
194
182 it('Should fail without a user role', async function () { 195 it('Should fail without a user role', async function () {
183 const fields = omit(baseCorrectParams, 'role') 196 const fields = omit(baseCorrectParams, 'role')
184 197
@@ -607,7 +620,7 @@ describe('Test users API validators', function () {
607 }) 620 })
608 621
609 describe('When having a video quota', function () { 622 describe('When having a video quota', function () {
610 it('Should fail with a user having too many video', async function () { 623 it('Should fail with a user having too many videos', async function () {
611 await updateUser({ 624 await updateUser({
612 url: server.url, 625 url: server.url,
613 userId: rootId, 626 userId: rootId,
@@ -618,7 +631,7 @@ describe('Test users API validators', function () {
618 await uploadVideo(server.url, server.accessToken, {}, 403) 631 await uploadVideo(server.url, server.accessToken, {}, 403)
619 }) 632 })
620 633
621 it('Should fail with a registered user having too many video', async function () { 634 it('Should fail with a registered user having too many videos', async function () {
622 this.timeout(30000) 635 this.timeout(30000)
623 636
624 const user = { 637 const user = {
@@ -663,6 +676,45 @@ describe('Test users API validators', function () {
663 }) 676 })
664 }) 677 })
665 678
679 describe('When having a daily video quota', function () {
680 it('Should fail with a user having too many videos', async function () {
681 await updateUser({
682 url: server.url,
683 userId: rootId,
684 accessToken: server.accessToken,
685 videoQuotaDaily: 42
686 })
687
688 await uploadVideo(server.url, server.accessToken, {}, 403)
689 })
690 })
691
692 describe('When having an absolute and daily video quota', function () {
693 it('Should fail if exceeding total quota', async function () {
694 await updateUser({
695 url: server.url,
696 userId: rootId,
697 accessToken: server.accessToken,
698 videoQuota: 42,
699 videoQuotaDaily: 1024 * 1024 * 1024
700 })
701
702 await uploadVideo(server.url, server.accessToken, {}, 403)
703 })
704
705 it('Should fail if exceeding daily quota', async function () {
706 await updateUser({
707 url: server.url,
708 userId: rootId,
709 accessToken: server.accessToken,
710 videoQuota: 1024 * 1024 * 1024,
711 videoQuotaDaily: 42
712 })
713
714 await uploadVideo(server.url, server.accessToken, {}, 403)
715 })
716 })
717
666 describe('When asking a password reset', function () { 718 describe('When asking a password reset', function () {
667 const path = '/api/v1/users/ask-reset-password' 719 const path = '/api/v1/users/ask-reset-password'
668 720