diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-03 11:10:31 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-06 11:19:16 +0200 |
commit | 5d08a6a74e83f2e4dfe2f3ba7f5a39371e1bc89e (patch) | |
tree | dd992ea798c620b8bdb5bf5fd9b8f1b97d4410f2 /server/tests/api | |
parent | 7e5f9f001d5de22c54748f935edc0c069028bb0e (diff) | |
download | PeerTube-5d08a6a74e83f2e4dfe2f3ba7f5a39371e1bc89e.tar.gz PeerTube-5d08a6a74e83f2e4dfe2f3ba7f5a39371e1bc89e.tar.zst PeerTube-5d08a6a74e83f2e4dfe2f3ba7f5a39371e1bc89e.zip |
Add import http enabled configuration
Diffstat (limited to 'server/tests/api')
-rw-r--r-- | server/tests/api/check-params/config.ts | 7 | ||||
-rw-r--r-- | server/tests/api/check-params/index.ts | 1 | ||||
-rw-r--r-- | server/tests/api/check-params/video-imports.ts | 246 | ||||
-rw-r--r-- | server/tests/api/server/config.ts | 9 |
4 files changed, 263 insertions, 0 deletions
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts index 03855237f..2742e26de 100644 --- a/server/tests/api/check-params/config.ts +++ b/server/tests/api/check-params/config.ts | |||
@@ -60,6 +60,13 @@ describe('Test config API validators', function () { | |||
60 | '720p': false, | 60 | '720p': false, |
61 | '1080p': false | 61 | '1080p': false |
62 | } | 62 | } |
63 | }, | ||
64 | import: { | ||
65 | videos: { | ||
66 | http: { | ||
67 | enabled: false | ||
68 | } | ||
69 | } | ||
63 | } | 70 | } |
64 | } | 71 | } |
65 | 72 | ||
diff --git a/server/tests/api/check-params/index.ts b/server/tests/api/check-params/index.ts index 820dde889..03fdd5c4e 100644 --- a/server/tests/api/check-params/index.ts +++ b/server/tests/api/check-params/index.ts | |||
@@ -10,4 +10,5 @@ import './video-captions' | |||
10 | import './video-channels' | 10 | import './video-channels' |
11 | import './video-comments' | 11 | import './video-comments' |
12 | import './videos' | 12 | import './videos' |
13 | import './video-imports' | ||
13 | import './search' | 14 | import './search' |
diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts new file mode 100644 index 000000000..7f58efb74 --- /dev/null +++ b/server/tests/api/check-params/video-imports.ts | |||
@@ -0,0 +1,246 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | ||
2 | |||
3 | import { omit } from 'lodash' | ||
4 | import 'mocha' | ||
5 | import { join } from 'path' | ||
6 | import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' | ||
7 | import { | ||
8 | createUser, | ||
9 | flushTests, | ||
10 | getMyUserInformation, | ||
11 | immutableAssign, | ||
12 | killallServers, | ||
13 | makeGetRequest, | ||
14 | makePostBodyRequest, | ||
15 | makeUploadRequest, | ||
16 | runServer, | ||
17 | ServerInfo, | ||
18 | setAccessTokensToServers, | ||
19 | userLogin | ||
20 | } from '../../utils' | ||
21 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' | ||
22 | |||
23 | describe('Test video imports API validator', function () { | ||
24 | const path = '/api/v1/videos/imports' | ||
25 | let server: ServerInfo | ||
26 | let userAccessToken = '' | ||
27 | let accountName: string | ||
28 | let channelId: number | ||
29 | let channelUUID: string | ||
30 | |||
31 | // --------------------------------------------------------------- | ||
32 | |||
33 | before(async function () { | ||
34 | this.timeout(30000) | ||
35 | |||
36 | await flushTests() | ||
37 | |||
38 | server = await runServer(1) | ||
39 | |||
40 | await setAccessTokensToServers([ server ]) | ||
41 | |||
42 | const username = 'user1' | ||
43 | const password = 'my super password' | ||
44 | await createUser(server.url, server.accessToken, username, password) | ||
45 | userAccessToken = await userLogin(server, { username, password }) | ||
46 | |||
47 | { | ||
48 | const res = await getMyUserInformation(server.url, server.accessToken) | ||
49 | channelId = res.body.videoChannels[ 0 ].id | ||
50 | channelUUID = res.body.videoChannels[ 0 ].uuid | ||
51 | accountName = res.body.account.name + '@' + res.body.account.host | ||
52 | } | ||
53 | }) | ||
54 | |||
55 | describe('When listing my video imports', function () { | ||
56 | const myPath = '/api/v1/users/me/videos/imports' | ||
57 | |||
58 | it('Should fail with a bad start pagination', async function () { | ||
59 | await checkBadStartPagination(server.url, myPath, server.accessToken) | ||
60 | }) | ||
61 | |||
62 | it('Should fail with a bad count pagination', async function () { | ||
63 | await checkBadCountPagination(server.url, myPath, server.accessToken) | ||
64 | }) | ||
65 | |||
66 | it('Should fail with an incorrect sort', async function () { | ||
67 | await checkBadSortPagination(server.url, myPath, server.accessToken) | ||
68 | }) | ||
69 | |||
70 | it('Should success with the correct parameters', async function () { | ||
71 | await makeGetRequest({ url: server.url, path: myPath, statusCodeExpected: 200, token: server.accessToken }) | ||
72 | }) | ||
73 | }) | ||
74 | |||
75 | describe('When adding a video import', function () { | ||
76 | let baseCorrectParams | ||
77 | |||
78 | before(function () { | ||
79 | baseCorrectParams = { | ||
80 | targetUrl: 'https://youtu.be/msX3jv1XdvM', | ||
81 | name: 'my super name', | ||
82 | category: 5, | ||
83 | licence: 1, | ||
84 | language: 'pt', | ||
85 | nsfw: false, | ||
86 | commentsEnabled: true, | ||
87 | waitTranscoding: true, | ||
88 | description: 'my super description', | ||
89 | support: 'my super support text', | ||
90 | tags: [ 'tag1', 'tag2' ], | ||
91 | privacy: VideoPrivacy.PUBLIC, | ||
92 | channelId: channelId | ||
93 | } | ||
94 | }) | ||
95 | |||
96 | it('Should fail with nothing', async function () { | ||
97 | const fields = {} | ||
98 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
99 | }) | ||
100 | |||
101 | it('Should fail with a long name', async function () { | ||
102 | const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) }) | ||
103 | |||
104 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
105 | }) | ||
106 | |||
107 | it('Should fail with a bad category', async function () { | ||
108 | const fields = immutableAssign(baseCorrectParams, { category: 125 }) | ||
109 | |||
110 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
111 | }) | ||
112 | |||
113 | it('Should fail with a bad licence', async function () { | ||
114 | const fields = immutableAssign(baseCorrectParams, { licence: 125 }) | ||
115 | |||
116 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
117 | }) | ||
118 | |||
119 | it('Should fail with a bad language', async function () { | ||
120 | const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) }) | ||
121 | |||
122 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
123 | }) | ||
124 | |||
125 | it('Should fail with a long description', async function () { | ||
126 | const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) }) | ||
127 | |||
128 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
129 | }) | ||
130 | |||
131 | it('Should fail with a long support text', async function () { | ||
132 | const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(150) }) | ||
133 | |||
134 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
135 | }) | ||
136 | |||
137 | it('Should fail without a channel', async function () { | ||
138 | const fields = omit(baseCorrectParams, 'channelId') | ||
139 | |||
140 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
141 | }) | ||
142 | |||
143 | it('Should fail with a bad channel', async function () { | ||
144 | const fields = immutableAssign(baseCorrectParams, { channelId: 545454 }) | ||
145 | |||
146 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
147 | }) | ||
148 | |||
149 | it('Should fail with another user channel', async function () { | ||
150 | const user = { | ||
151 | username: 'fake', | ||
152 | password: 'fake_password' | ||
153 | } | ||
154 | await createUser(server.url, server.accessToken, user.username, user.password) | ||
155 | |||
156 | const accessTokenUser = await userLogin(server, user) | ||
157 | const res = await getMyUserInformation(server.url, accessTokenUser) | ||
158 | const customChannelId = res.body.videoChannels[0].id | ||
159 | |||
160 | const fields = immutableAssign(baseCorrectParams, { channelId: customChannelId }) | ||
161 | |||
162 | await makePostBodyRequest({ url: server.url, path, token: userAccessToken, fields }) | ||
163 | }) | ||
164 | |||
165 | it('Should fail with too many tags', async function () { | ||
166 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] }) | ||
167 | |||
168 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
169 | }) | ||
170 | |||
171 | it('Should fail with a tag length too low', async function () { | ||
172 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] }) | ||
173 | |||
174 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
175 | }) | ||
176 | |||
177 | it('Should fail with a tag length too big', async function () { | ||
178 | const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] }) | ||
179 | |||
180 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
181 | }) | ||
182 | |||
183 | it('Should fail with an incorrect thumbnail file', async function () { | ||
184 | const fields = baseCorrectParams | ||
185 | const attaches = { | ||
186 | 'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png') | ||
187 | } | ||
188 | |||
189 | await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) | ||
190 | }) | ||
191 | |||
192 | it('Should fail with a big thumbnail file', async function () { | ||
193 | const fields = baseCorrectParams | ||
194 | const attaches = { | ||
195 | 'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png') | ||
196 | } | ||
197 | |||
198 | await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) | ||
199 | }) | ||
200 | |||
201 | it('Should fail with an incorrect preview file', async function () { | ||
202 | const fields = baseCorrectParams | ||
203 | const attaches = { | ||
204 | 'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png') | ||
205 | } | ||
206 | |||
207 | await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) | ||
208 | }) | ||
209 | |||
210 | it('Should fail with a big preview file', async function () { | ||
211 | const fields = baseCorrectParams | ||
212 | const attaches = { | ||
213 | 'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png') | ||
214 | } | ||
215 | |||
216 | await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) | ||
217 | }) | ||
218 | |||
219 | it('Should succeed with the correct parameters', async function () { | ||
220 | this.timeout(10000) | ||
221 | |||
222 | const fields = baseCorrectParams | ||
223 | |||
224 | { | ||
225 | await makePostBodyRequest({ | ||
226 | url: server.url, | ||
227 | path, | ||
228 | token: server.accessToken, | ||
229 | fields, | ||
230 | statusCodeExpected: 200 | ||
231 | }) | ||
232 | } | ||
233 | }) | ||
234 | |||
235 | it('Should forbid importing') | ||
236 | }) | ||
237 | |||
238 | after(async function () { | ||
239 | killallServers([ server ]) | ||
240 | |||
241 | // Keep the logs if the test failed | ||
242 | if (this['ok']) { | ||
243 | await flushTests() | ||
244 | } | ||
245 | }) | ||
246 | }) | ||
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts index 1782a8623..b65061a5d 100644 --- a/server/tests/api/server/config.ts +++ b/server/tests/api/server/config.ts | |||
@@ -44,6 +44,7 @@ function checkInitialConfig (data: CustomConfig) { | |||
44 | expect(data.transcoding.resolutions['480p']).to.be.true | 44 | expect(data.transcoding.resolutions['480p']).to.be.true |
45 | expect(data.transcoding.resolutions['720p']).to.be.true | 45 | expect(data.transcoding.resolutions['720p']).to.be.true |
46 | expect(data.transcoding.resolutions['1080p']).to.be.true | 46 | expect(data.transcoding.resolutions['1080p']).to.be.true |
47 | expect(data.import.videos.http.enabled).to.be.true | ||
47 | } | 48 | } |
48 | 49 | ||
49 | function checkUpdatedConfig (data: CustomConfig) { | 50 | function checkUpdatedConfig (data: CustomConfig) { |
@@ -70,6 +71,7 @@ function checkUpdatedConfig (data: CustomConfig) { | |||
70 | expect(data.transcoding.resolutions['480p']).to.be.true | 71 | expect(data.transcoding.resolutions['480p']).to.be.true |
71 | expect(data.transcoding.resolutions['720p']).to.be.false | 72 | expect(data.transcoding.resolutions['720p']).to.be.false |
72 | expect(data.transcoding.resolutions['1080p']).to.be.false | 73 | expect(data.transcoding.resolutions['1080p']).to.be.false |
74 | expect(data.import.videos.http.enabled).to.be.false | ||
73 | } | 75 | } |
74 | 76 | ||
75 | describe('Test config', function () { | 77 | describe('Test config', function () { |
@@ -160,6 +162,13 @@ describe('Test config', function () { | |||
160 | '720p': false, | 162 | '720p': false, |
161 | '1080p': false | 163 | '1080p': false |
162 | } | 164 | } |
165 | }, | ||
166 | import: { | ||
167 | videos: { | ||
168 | http: { | ||
169 | enabled: false | ||
170 | } | ||
171 | } | ||
163 | } | 172 | } |
164 | } | 173 | } |
165 | await updateCustomConfig(server.url, server.accessToken, newCustomConfig) | 174 | await updateCustomConfig(server.url, server.accessToken, newCustomConfig) |