+ await uploadVideo(server.url, userAccessToken, videoAttributes, HttpStatusCode.PAYLOAD_TOO_LARGE_413)
+ })
+
+ it('Should fail to import with HTTP/Torrent/magnet', async function () {
+ this.timeout(120000)
+
+ const baseAttributes = {
+ channelId: 1,
+ privacy: VideoPrivacy.PUBLIC
+ }
+ await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { targetUrl: getGoodVideoUrl() }))
+ await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { magnetUri: getMagnetURI() }))
+ await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { torrentfile: 'video-720p.torrent' as any }))
+
+ await waitJobs([ server ])
+
+ const res = await getMyVideoImports(server.url, server.accessToken)
+
+ expect(res.body.total).to.equal(3)
+ const videoImports: VideoImport[] = res.body.data
+ expect(videoImports).to.have.lengthOf(3)
+
+ for (const videoImport of videoImports) {
+ expect(videoImport.state.id).to.equal(VideoImportState.FAILED)
+ expect(videoImport.error).not.to.be.undefined
+ expect(videoImport.error).to.contain('user video quota is exceeded')
+ }
+ })
+ })
+
+ describe('When having a daily video quota', function () {
+ it('Should fail with a user having too many videos daily', async function () {
+ await updateUser({
+ url: server.url,
+ userId: rootId,
+ accessToken: server.accessToken,
+ videoQuotaDaily: 42
+ })
+
+ await uploadVideo(server.url, server.accessToken, {}, HttpStatusCode.PAYLOAD_TOO_LARGE_413)
+ })
+ })
+
+ describe('When having an absolute and daily video quota', function () {
+ it('Should fail if exceeding total quota', async function () {
+ await updateUser({
+ url: server.url,
+ userId: rootId,
+ accessToken: server.accessToken,
+ videoQuota: 42,
+ videoQuotaDaily: 1024 * 1024 * 1024
+ })
+
+ await uploadVideo(server.url, server.accessToken, {}, HttpStatusCode.PAYLOAD_TOO_LARGE_413)
+ })
+
+ it('Should fail if exceeding daily quota', async function () {
+ await updateUser({
+ url: server.url,
+ userId: rootId,
+ accessToken: server.accessToken,
+ videoQuota: 1024 * 1024 * 1024,
+ videoQuotaDaily: 42
+ })
+
+ await uploadVideo(server.url, server.accessToken, {}, HttpStatusCode.PAYLOAD_TOO_LARGE_413)
+ })
+ })
+
+ describe('When asking a password reset', function () {
+ const path = '/api/v1/users/ask-reset-password'
+
+ it('Should fail with a missing email', async function () {
+ const fields = {}
+
+ await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
+ })
+
+ it('Should fail with an invalid email', async function () {
+ const fields = { email: 'hello' }
+
+ await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
+ })
+
+ it('Should success with the correct params', async function () {
+ const fields = { email: 'admin@example.com' }
+
+ await makePostBodyRequest({
+ url: server.url,
+ path,
+ token: server.accessToken,
+ fields,
+ statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ })
+ })
+ })
+
+ describe('When asking for an account verification email', function () {
+ const path = '/api/v1/users/ask-send-verify-email'
+
+ it('Should fail with a missing email', async function () {
+ const fields = {}
+
+ await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
+ })
+
+ it('Should fail with an invalid email', async function () {
+ const fields = { email: 'hello' }
+
+ await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
+ })
+
+ it('Should succeed with the correct params', async function () {
+ const fields = { email: 'admin@example.com' }
+
+ await makePostBodyRequest({
+ url: server.url,
+ path,
+ token: server.accessToken,
+ fields,
+ statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ })