diff options
Diffstat (limited to 'server/tests/api/check-params/users.ts')
-rw-r--r-- | server/tests/api/check-params/users.ts | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index e1954c64f..e1655e85b 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts | |||
@@ -3,7 +3,7 @@ | |||
3 | import { omit } from 'lodash' | 3 | import { omit } from 'lodash' |
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import { UserRole } from '../../../../shared' | 6 | import { UserRole, VideoImport, VideoImportState } from '../../../../shared' |
7 | 7 | ||
8 | import { | 8 | import { |
9 | createUser, flushTests, getMyUserInformation, getMyUserVideoRating, getUsersList, immutableAssign, killallServers, makeGetRequest, | 9 | createUser, flushTests, getMyUserInformation, getMyUserVideoRating, getUsersList, immutableAssign, killallServers, makeGetRequest, |
@@ -11,6 +11,10 @@ import { | |||
11 | updateUser, uploadVideo, userLogin | 11 | updateUser, uploadVideo, userLogin |
12 | } from '../../utils' | 12 | } from '../../utils' |
13 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' | 13 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' |
14 | import { getMagnetURI, getMyVideoImports, getYoutubeVideoUrl, importVideo } from '../../utils/videos/video-imports' | ||
15 | import { VideoPrivacy } from '../../../../shared/models/videos' | ||
16 | import { waitJobs } from '../../utils/server/jobs' | ||
17 | import { expect } from 'chai' | ||
14 | 18 | ||
15 | describe('Test users API validators', function () { | 19 | describe('Test users API validators', function () { |
16 | const path = '/api/v1/users/' | 20 | const path = '/api/v1/users/' |
@@ -20,6 +24,7 @@ describe('Test users API validators', function () { | |||
20 | let server: ServerInfo | 24 | let server: ServerInfo |
21 | let serverWithRegistrationDisabled: ServerInfo | 25 | let serverWithRegistrationDisabled: ServerInfo |
22 | let userAccessToken = '' | 26 | let userAccessToken = '' |
27 | let channelId: number | ||
23 | const user = { | 28 | const user = { |
24 | username: 'user1', | 29 | username: 'user1', |
25 | password: 'my super password' | 30 | password: 'my super password' |
@@ -41,8 +46,15 @@ describe('Test users API validators', function () { | |||
41 | await createUser(server.url, server.accessToken, user.username, user.password, videoQuota) | 46 | await createUser(server.url, server.accessToken, user.username, user.password, videoQuota) |
42 | userAccessToken = await userLogin(server, user) | 47 | userAccessToken = await userLogin(server, user) |
43 | 48 | ||
44 | const res = await uploadVideo(server.url, server.accessToken, {}) | 49 | { |
45 | videoId = res.body.video.id | 50 | const res = await getMyUserInformation(server.url, server.accessToken) |
51 | channelId = res.body.videoChannels[ 0 ].id | ||
52 | } | ||
53 | |||
54 | { | ||
55 | const res = await uploadVideo(server.url, server.accessToken, {}) | ||
56 | videoId = res.body.video.id | ||
57 | } | ||
46 | }) | 58 | }) |
47 | 59 | ||
48 | describe('When listing users', function () { | 60 | describe('When listing users', function () { |
@@ -605,6 +617,32 @@ describe('Test users API validators', function () { | |||
605 | await uploadVideo(server.url, userAccessToken, videoAttributes) | 617 | await uploadVideo(server.url, userAccessToken, videoAttributes) |
606 | await uploadVideo(server.url, userAccessToken, videoAttributes, 403) | 618 | await uploadVideo(server.url, userAccessToken, videoAttributes, 403) |
607 | }) | 619 | }) |
620 | |||
621 | it('Should fail to import with HTTP/Torrent/magnet', async function () { | ||
622 | this.timeout(30000) | ||
623 | |||
624 | const baseAttributes = { | ||
625 | channelId: 1, | ||
626 | privacy: VideoPrivacy.PUBLIC | ||
627 | } | ||
628 | await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { targetUrl: getYoutubeVideoUrl() })) | ||
629 | await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { magnetUri: getMagnetURI() })) | ||
630 | await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { torrentfile: '60fps_small-240p.torrent' })) | ||
631 | |||
632 | await waitJobs([ server ]) | ||
633 | |||
634 | const res = await getMyVideoImports(server.url, server.accessToken) | ||
635 | |||
636 | expect(res.body.total).to.equal(3) | ||
637 | const videoImports: VideoImport[] = res.body.data | ||
638 | expect(videoImports).to.have.lengthOf(3) | ||
639 | |||
640 | for (const videoImport of videoImports) { | ||
641 | expect(videoImport.state.id).to.equal(VideoImportState.FAILED) | ||
642 | expect(videoImport.error).not.to.be.undefined | ||
643 | expect(videoImport.error).to.contain('user video quota is exceeded') | ||
644 | } | ||
645 | }) | ||
608 | }) | 646 | }) |
609 | 647 | ||
610 | describe('When asking a password reset', function () { | 648 | describe('When asking a password reset', function () { |