diff options
Diffstat (limited to 'server/tests/api/check-params/upload-quota.ts')
-rw-r--r-- | server/tests/api/check-params/upload-quota.ts | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/server/tests/api/check-params/upload-quota.ts b/server/tests/api/check-params/upload-quota.ts index 3dc6cf2b4..d94dec624 100644 --- a/server/tests/api/check-params/upload-quota.ts +++ b/server/tests/api/check-params/upload-quota.ts | |||
@@ -3,17 +3,14 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { HttpStatusCode, randomInt } from '@shared/core-utils' | 5 | import { HttpStatusCode, randomInt } from '@shared/core-utils' |
6 | import { MyUser, VideoImportState, VideoPrivacy } from '@shared/models' | 6 | import { VideoImportState, VideoPrivacy } from '@shared/models' |
7 | import { | 7 | import { |
8 | cleanupTests, | 8 | cleanupTests, |
9 | flushAndRunServer, | 9 | flushAndRunServer, |
10 | getMyUserInformation, | ||
11 | ImportsCommand, | 10 | ImportsCommand, |
12 | registerUser, | ||
13 | ServerInfo, | 11 | ServerInfo, |
14 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
15 | setDefaultVideoChannel, | 13 | setDefaultVideoChannel, |
16 | updateUser, | ||
17 | uploadVideo, | 14 | uploadVideo, |
18 | waitJobs | 15 | waitJobs |
19 | } from '../../../../shared/extra-utils' | 16 | } from '../../../../shared/extra-utils' |
@@ -31,15 +28,10 @@ describe('Test upload quota', function () { | |||
31 | await setAccessTokensToServers([ server ]) | 28 | await setAccessTokensToServers([ server ]) |
32 | await setDefaultVideoChannel([ server ]) | 29 | await setDefaultVideoChannel([ server ]) |
33 | 30 | ||
34 | const res = await getMyUserInformation(server.url, server.accessToken) | 31 | const user = await server.usersCommand.getMyInfo() |
35 | rootId = (res.body as MyUser).id | 32 | rootId = user.id |
36 | 33 | ||
37 | await updateUser({ | 34 | await server.usersCommand.update({ userId: rootId, videoQuota: 42 }) |
38 | url: server.url, | ||
39 | userId: rootId, | ||
40 | accessToken: server.accessToken, | ||
41 | videoQuota: 42 | ||
42 | }) | ||
43 | }) | 35 | }) |
44 | 36 | ||
45 | describe('When having a video quota', function () { | 37 | describe('When having a video quota', function () { |
@@ -48,7 +40,7 @@ describe('Test upload quota', function () { | |||
48 | this.timeout(30000) | 40 | this.timeout(30000) |
49 | 41 | ||
50 | const user = { username: 'registered' + randomInt(1, 1500), password: 'password' } | 42 | const user = { username: 'registered' + randomInt(1, 1500), password: 'password' } |
51 | await registerUser(server.url, user.username, user.password) | 43 | await server.usersCommand.register(user) |
52 | const userAccessToken = await server.loginCommand.getAccessToken(user) | 44 | const userAccessToken = await server.loginCommand.getAccessToken(user) |
53 | 45 | ||
54 | const videoAttributes = { fixture: 'video_short2.webm' } | 46 | const videoAttributes = { fixture: 'video_short2.webm' } |
@@ -63,7 +55,7 @@ describe('Test upload quota', function () { | |||
63 | this.timeout(30000) | 55 | this.timeout(30000) |
64 | 56 | ||
65 | const user = { username: 'registered' + randomInt(1, 1500), password: 'password' } | 57 | const user = { username: 'registered' + randomInt(1, 1500), password: 'password' } |
66 | await registerUser(server.url, user.username, user.password) | 58 | await server.usersCommand.register(user) |
67 | const userAccessToken = await server.loginCommand.getAccessToken(user) | 59 | const userAccessToken = await server.loginCommand.getAccessToken(user) |
68 | 60 | ||
69 | const videoAttributes = { fixture: 'video_short2.webm' } | 61 | const videoAttributes = { fixture: 'video_short2.webm' } |
@@ -103,12 +95,7 @@ describe('Test upload quota', function () { | |||
103 | describe('When having a daily video quota', function () { | 95 | describe('When having a daily video quota', function () { |
104 | 96 | ||
105 | it('Should fail with a user having too many videos daily', async function () { | 97 | it('Should fail with a user having too many videos daily', async function () { |
106 | await updateUser({ | 98 | await server.usersCommand.update({ userId: rootId, videoQuotaDaily: 42 }) |
107 | url: server.url, | ||
108 | userId: rootId, | ||
109 | accessToken: server.accessToken, | ||
110 | videoQuotaDaily: 42 | ||
111 | }) | ||
112 | 99 | ||
113 | await uploadVideo(server.url, server.accessToken, {}, HttpStatusCode.PAYLOAD_TOO_LARGE_413, 'legacy') | 100 | await uploadVideo(server.url, server.accessToken, {}, HttpStatusCode.PAYLOAD_TOO_LARGE_413, 'legacy') |
114 | await uploadVideo(server.url, server.accessToken, {}, HttpStatusCode.PAYLOAD_TOO_LARGE_413, 'resumable') | 101 | await uploadVideo(server.url, server.accessToken, {}, HttpStatusCode.PAYLOAD_TOO_LARGE_413, 'resumable') |
@@ -117,10 +104,8 @@ describe('Test upload quota', function () { | |||
117 | 104 | ||
118 | describe('When having an absolute and daily video quota', function () { | 105 | describe('When having an absolute and daily video quota', function () { |
119 | it('Should fail if exceeding total quota', async function () { | 106 | it('Should fail if exceeding total quota', async function () { |
120 | await updateUser({ | 107 | await server.usersCommand.update({ |
121 | url: server.url, | ||
122 | userId: rootId, | 108 | userId: rootId, |
123 | accessToken: server.accessToken, | ||
124 | videoQuota: 42, | 109 | videoQuota: 42, |
125 | videoQuotaDaily: 1024 * 1024 * 1024 | 110 | videoQuotaDaily: 1024 * 1024 * 1024 |
126 | }) | 111 | }) |
@@ -130,10 +115,8 @@ describe('Test upload quota', function () { | |||
130 | }) | 115 | }) |
131 | 116 | ||
132 | it('Should fail if exceeding daily quota', async function () { | 117 | it('Should fail if exceeding daily quota', async function () { |
133 | await updateUser({ | 118 | await server.usersCommand.update({ |
134 | url: server.url, | ||
135 | userId: rootId, | 119 | userId: rootId, |
136 | accessToken: server.accessToken, | ||
137 | videoQuota: 1024 * 1024 * 1024, | 120 | videoQuota: 1024 * 1024 * 1024, |
138 | videoQuotaDaily: 42 | 121 | videoQuotaDaily: 42 |
139 | }) | 122 | }) |