aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/users.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-07 11:56:18 +0200
committerChocobozzz <me@florianbigard.com>2018-08-08 09:30:31 +0200
commit187501f8b8e334f043ae1e9af3c9d4f45ea0e6c1 (patch)
treeea895cb9dd743e400b64ab1b3b1bbee4d2521a2b /server/tests/api/check-params/users.ts
parenta84b8fa5cf6e4cafb841af3db9bdfcc9531c09a4 (diff)
downloadPeerTube-187501f8b8e334f043ae1e9af3c9d4f45ea0e6c1.tar.gz
PeerTube-187501f8b8e334f043ae1e9af3c9d4f45ea0e6c1.tar.zst
PeerTube-187501f8b8e334f043ae1e9af3c9d4f45ea0e6c1.zip
Add check param tests regarding video imports
Diffstat (limited to 'server/tests/api/check-params/users.ts')
-rw-r--r--server/tests/api/check-params/users.ts44
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 @@
3import { omit } from 'lodash' 3import { omit } from 'lodash'
4import 'mocha' 4import 'mocha'
5import { join } from 'path' 5import { join } from 'path'
6import { UserRole } from '../../../../shared' 6import { UserRole, VideoImport, VideoImportState } from '../../../../shared'
7 7
8import { 8import {
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'
13import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' 13import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params'
14import { getMagnetURI, getMyVideoImports, getYoutubeVideoUrl, importVideo } from '../../utils/videos/video-imports'
15import { VideoPrivacy } from '../../../../shared/models/videos'
16import { waitJobs } from '../../utils/server/jobs'
17import { expect } from 'chai'
14 18
15describe('Test users API validators', function () { 19describe('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 () {