diff options
Diffstat (limited to 'server/tests/api/check-params/upload-quota.ts')
-rw-r--r-- | server/tests/api/check-params/upload-quota.ts | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/server/tests/api/check-params/upload-quota.ts b/server/tests/api/check-params/upload-quota.ts index d94dec624..164c581e3 100644 --- a/server/tests/api/check-params/upload-quota.ts +++ b/server/tests/api/check-params/upload-quota.ts | |||
@@ -3,7 +3,6 @@ | |||
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 { VideoImportState, VideoPrivacy } from '@shared/models' | ||
7 | import { | 6 | import { |
8 | cleanupTests, | 7 | cleanupTests, |
9 | flushAndRunServer, | 8 | flushAndRunServer, |
@@ -11,13 +10,15 @@ import { | |||
11 | ServerInfo, | 10 | ServerInfo, |
12 | setAccessTokensToServers, | 11 | setAccessTokensToServers, |
13 | setDefaultVideoChannel, | 12 | setDefaultVideoChannel, |
14 | uploadVideo, | 13 | VideosCommand, |
15 | waitJobs | 14 | waitJobs |
16 | } from '../../../../shared/extra-utils' | 15 | } from '@shared/extra-utils' |
16 | import { VideoImportState, VideoPrivacy } from '@shared/models' | ||
17 | 17 | ||
18 | describe('Test upload quota', function () { | 18 | describe('Test upload quota', function () { |
19 | let server: ServerInfo | 19 | let server: ServerInfo |
20 | let rootId: number | 20 | let rootId: number |
21 | let command: VideosCommand | ||
21 | 22 | ||
22 | // --------------------------------------------------------------- | 23 | // --------------------------------------------------------------- |
23 | 24 | ||
@@ -32,6 +33,8 @@ describe('Test upload quota', function () { | |||
32 | rootId = user.id | 33 | rootId = user.id |
33 | 34 | ||
34 | await server.usersCommand.update({ userId: rootId, videoQuota: 42 }) | 35 | await server.usersCommand.update({ userId: rootId, videoQuota: 42 }) |
36 | |||
37 | command = server.videosCommand | ||
35 | }) | 38 | }) |
36 | 39 | ||
37 | describe('When having a video quota', function () { | 40 | describe('When having a video quota', function () { |
@@ -41,14 +44,14 @@ describe('Test upload quota', function () { | |||
41 | 44 | ||
42 | const user = { username: 'registered' + randomInt(1, 1500), password: 'password' } | 45 | const user = { username: 'registered' + randomInt(1, 1500), password: 'password' } |
43 | await server.usersCommand.register(user) | 46 | await server.usersCommand.register(user) |
44 | const userAccessToken = await server.loginCommand.getAccessToken(user) | 47 | const userToken = await server.loginCommand.getAccessToken(user) |
45 | 48 | ||
46 | const videoAttributes = { fixture: 'video_short2.webm' } | 49 | const attributes = { fixture: 'video_short2.webm' } |
47 | for (let i = 0; i < 5; i++) { | 50 | for (let i = 0; i < 5; i++) { |
48 | await uploadVideo(server.url, userAccessToken, videoAttributes) | 51 | await command.upload({ token: userToken, attributes }) |
49 | } | 52 | } |
50 | 53 | ||
51 | await uploadVideo(server.url, userAccessToken, videoAttributes, HttpStatusCode.PAYLOAD_TOO_LARGE_413, 'legacy') | 54 | await command.upload({ token: userToken, attributes, expectedStatus: HttpStatusCode.PAYLOAD_TOO_LARGE_413, mode: 'legacy' }) |
52 | }) | 55 | }) |
53 | 56 | ||
54 | it('Should fail with a registered user having too many videos with resumable upload', async function () { | 57 | it('Should fail with a registered user having too many videos with resumable upload', async function () { |
@@ -56,14 +59,14 @@ describe('Test upload quota', function () { | |||
56 | 59 | ||
57 | const user = { username: 'registered' + randomInt(1, 1500), password: 'password' } | 60 | const user = { username: 'registered' + randomInt(1, 1500), password: 'password' } |
58 | await server.usersCommand.register(user) | 61 | await server.usersCommand.register(user) |
59 | const userAccessToken = await server.loginCommand.getAccessToken(user) | 62 | const userToken = await server.loginCommand.getAccessToken(user) |
60 | 63 | ||
61 | const videoAttributes = { fixture: 'video_short2.webm' } | 64 | const attributes = { fixture: 'video_short2.webm' } |
62 | for (let i = 0; i < 5; i++) { | 65 | for (let i = 0; i < 5; i++) { |
63 | await uploadVideo(server.url, userAccessToken, videoAttributes) | 66 | await command.upload({ token: userToken, attributes }) |
64 | } | 67 | } |
65 | 68 | ||
66 | await uploadVideo(server.url, userAccessToken, videoAttributes, HttpStatusCode.PAYLOAD_TOO_LARGE_413, 'resumable') | 69 | await command.upload({ token: userToken, attributes, expectedStatus: HttpStatusCode.PAYLOAD_TOO_LARGE_413, mode: 'resumable' }) |
67 | }) | 70 | }) |
68 | 71 | ||
69 | it('Should fail to import with HTTP/Torrent/magnet', async function () { | 72 | it('Should fail to import with HTTP/Torrent/magnet', async function () { |
@@ -97,8 +100,8 @@ describe('Test upload quota', function () { | |||
97 | it('Should fail with a user having too many videos daily', async function () { | 100 | it('Should fail with a user having too many videos daily', async function () { |
98 | await server.usersCommand.update({ userId: rootId, videoQuotaDaily: 42 }) | 101 | await server.usersCommand.update({ userId: rootId, videoQuotaDaily: 42 }) |
99 | 102 | ||
100 | await uploadVideo(server.url, server.accessToken, {}, HttpStatusCode.PAYLOAD_TOO_LARGE_413, 'legacy') | 103 | await command.upload({ expectedStatus: HttpStatusCode.PAYLOAD_TOO_LARGE_413, mode: 'legacy' }) |
101 | await uploadVideo(server.url, server.accessToken, {}, HttpStatusCode.PAYLOAD_TOO_LARGE_413, 'resumable') | 104 | await command.upload({ expectedStatus: HttpStatusCode.PAYLOAD_TOO_LARGE_413, mode: 'resumable' }) |
102 | }) | 105 | }) |
103 | }) | 106 | }) |
104 | 107 | ||
@@ -110,8 +113,8 @@ describe('Test upload quota', function () { | |||
110 | videoQuotaDaily: 1024 * 1024 * 1024 | 113 | videoQuotaDaily: 1024 * 1024 * 1024 |
111 | }) | 114 | }) |
112 | 115 | ||
113 | await uploadVideo(server.url, server.accessToken, {}, HttpStatusCode.PAYLOAD_TOO_LARGE_413, 'legacy') | 116 | await command.upload({ expectedStatus: HttpStatusCode.PAYLOAD_TOO_LARGE_413, mode: 'legacy' }) |
114 | await uploadVideo(server.url, server.accessToken, {}, HttpStatusCode.PAYLOAD_TOO_LARGE_413, 'resumable') | 117 | await command.upload({ expectedStatus: HttpStatusCode.PAYLOAD_TOO_LARGE_413, mode: 'resumable' }) |
115 | }) | 118 | }) |
116 | 119 | ||
117 | it('Should fail if exceeding daily quota', async function () { | 120 | it('Should fail if exceeding daily quota', async function () { |
@@ -121,8 +124,8 @@ describe('Test upload quota', function () { | |||
121 | videoQuotaDaily: 42 | 124 | videoQuotaDaily: 42 |
122 | }) | 125 | }) |
123 | 126 | ||
124 | await uploadVideo(server.url, server.accessToken, {}, HttpStatusCode.PAYLOAD_TOO_LARGE_413, 'legacy') | 127 | await command.upload({ expectedStatus: HttpStatusCode.PAYLOAD_TOO_LARGE_413, mode: 'legacy' }) |
125 | await uploadVideo(server.url, server.accessToken, {}, HttpStatusCode.PAYLOAD_TOO_LARGE_413, 'resumable') | 128 | await command.upload({ expectedStatus: HttpStatusCode.PAYLOAD_TOO_LARGE_413, mode: 'resumable' }) |
126 | }) | 129 | }) |
127 | }) | 130 | }) |
128 | 131 | ||