diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-10-31 15:20:35 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-10-31 15:32:10 +0100 |
commit | 11474c3cd904fa0fc07fc0a3a9a35496da17f300 (patch) | |
tree | 945bb2cdc11548c80706dbf7f0db4fa0edabbee0 /server/tests/api/check-params | |
parent | fd45e8f43c2638478599ca75632518054461da85 (diff) | |
download | PeerTube-11474c3cd904fa0fc07fc0a3a9a35496da17f300.tar.gz PeerTube-11474c3cd904fa0fc07fc0a3a9a35496da17f300.tar.zst PeerTube-11474c3cd904fa0fc07fc0a3a9a35496da17f300.zip |
Add tests and fix bugs for video privacy
Diffstat (limited to 'server/tests/api/check-params')
-rw-r--r-- | server/tests/api/check-params/videos.ts | 537 |
1 files changed, 177 insertions, 360 deletions
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts index c59f5da93..5860e9195 100644 --- a/server/tests/api/check-params/videos.ts +++ b/server/tests/api/check-params/videos.ts | |||
@@ -19,12 +19,46 @@ import { | |||
19 | createUser, | 19 | createUser, |
20 | getUserAccessToken | 20 | getUserAccessToken |
21 | } from '../../utils' | 21 | } from '../../utils' |
22 | import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' | ||
22 | 23 | ||
23 | describe('Test videos API validator', function () { | 24 | describe('Test videos API validator', function () { |
24 | const path = '/api/v1/videos/' | 25 | const path = '/api/v1/videos/' |
25 | let server: ServerInfo | 26 | let server: ServerInfo |
26 | let channelId: number | 27 | let channelId: number |
27 | 28 | ||
29 | function getCompleteVideoUploadAttributes () { | ||
30 | return { | ||
31 | name: 'my super name', | ||
32 | category: 5, | ||
33 | licence: 1, | ||
34 | language: 6, | ||
35 | nsfw: false, | ||
36 | description: 'my super description', | ||
37 | tags: [ 'tag1', 'tag2' ], | ||
38 | privacy: VideoPrivacy.PUBLIC, | ||
39 | channelId | ||
40 | } | ||
41 | } | ||
42 | |||
43 | function getCompleteVideoUpdateAttributes () { | ||
44 | return { | ||
45 | name: 'my super name', | ||
46 | category: 5, | ||
47 | licence: 2, | ||
48 | language: 6, | ||
49 | nsfw: false, | ||
50 | description: 'my super description', | ||
51 | privacy: VideoPrivacy.PUBLIC, | ||
52 | tags: [ 'tag1', 'tag2' ] | ||
53 | } | ||
54 | } | ||
55 | |||
56 | function getVideoUploadAttaches () { | ||
57 | return { | ||
58 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | ||
59 | } | ||
60 | } | ||
61 | |||
28 | // --------------------------------------------------------------- | 62 | // --------------------------------------------------------------- |
29 | 63 | ||
30 | before(async function () { | 64 | before(async function () { |
@@ -99,6 +133,37 @@ describe('Test videos API validator', function () { | |||
99 | }) | 133 | }) |
100 | }) | 134 | }) |
101 | 135 | ||
136 | describe('When listing my videos', function () { | ||
137 | const path = '/api/v1/users/me/videos' | ||
138 | |||
139 | it('Should fail with a bad start pagination', async function () { | ||
140 | await request(server.url) | ||
141 | .get(path) | ||
142 | .set('Authorization', 'Bearer ' + server.accessToken) | ||
143 | .query({ start: 'hello' }) | ||
144 | .set('Accept', 'application/json') | ||
145 | .expect(400) | ||
146 | }) | ||
147 | |||
148 | it('Should fail with a bad count pagination', async function () { | ||
149 | await request(server.url) | ||
150 | .get(path) | ||
151 | .set('Authorization', 'Bearer ' + server.accessToken) | ||
152 | .query({ count: 'hello' }) | ||
153 | .set('Accept', 'application/json') | ||
154 | .expect(400) | ||
155 | }) | ||
156 | |||
157 | it('Should fail with an incorrect sort', async function () { | ||
158 | await request(server.url) | ||
159 | .get(path) | ||
160 | .set('Authorization', 'Bearer ' + server.accessToken) | ||
161 | .query({ sort: 'hello' }) | ||
162 | .set('Accept', 'application/json') | ||
163 | .expect(400) | ||
164 | }) | ||
165 | }) | ||
166 | |||
102 | describe('When adding a video', function () { | 167 | describe('When adding a video', function () { |
103 | it('Should fail with nothing', async function () { | 168 | it('Should fail with nothing', async function () { |
104 | const fields = {} | 169 | const fields = {} |
@@ -107,219 +172,108 @@ describe('Test videos API validator', function () { | |||
107 | }) | 172 | }) |
108 | 173 | ||
109 | it('Should fail without name', async function () { | 174 | it('Should fail without name', async function () { |
110 | const fields = { | 175 | const fields = getCompleteVideoUploadAttributes() |
111 | category: 5, | 176 | delete fields.name |
112 | licence: 1, | 177 | |
113 | language: 6, | 178 | const attaches = getVideoUploadAttaches() |
114 | nsfw: false, | ||
115 | description: 'my super description', | ||
116 | tags: [ 'tag1', 'tag2' ], | ||
117 | channelId | ||
118 | } | ||
119 | const attaches = { | ||
120 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | ||
121 | } | ||
122 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 179 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
123 | }) | 180 | }) |
124 | 181 | ||
125 | it('Should fail with a long name', async function () { | 182 | it('Should fail with a long name', async function () { |
126 | const fields = { | 183 | const fields = getCompleteVideoUploadAttributes() |
127 | name: 'My very very very very very very very very very very very very very very very very very ' + | 184 | fields.name = 'My very very very very very very very very very very very very very very very very very ' + |
128 | 'very very very very very very very very very very very very very very very very long long' + | 185 | 'very very very very very very very very very very very very very very very very long long' + |
129 | 'very very very very very very very very very very very very very very very very long name', | 186 | 'very very very very very very very very very very very very very very very very long name' |
130 | category: 5, | 187 | |
131 | licence: 1, | 188 | const attaches = getVideoUploadAttaches |
132 | language: 6, | ||
133 | nsfw: false, | ||
134 | description: 'my super description', | ||
135 | tags: [ 'tag1', 'tag2' ], | ||
136 | channelId | ||
137 | } | ||
138 | const attaches = { | ||
139 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | ||
140 | } | ||
141 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 189 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
142 | }) | 190 | }) |
143 | 191 | ||
144 | it('Should fail without a category', async function () { | 192 | it('Should fail without a category', async function () { |
145 | const fields = { | 193 | const fields = getCompleteVideoUploadAttributes() |
146 | name: 'my super name', | 194 | delete fields.category |
147 | licence: 1, | 195 | |
148 | language: 6, | 196 | const attaches = getVideoUploadAttaches |
149 | nsfw: false, | ||
150 | description: 'my super description', | ||
151 | tags: [ 'tag1', 'tag2' ], | ||
152 | channelId | ||
153 | } | ||
154 | const attaches = { | ||
155 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | ||
156 | } | ||
157 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 197 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
158 | }) | 198 | }) |
159 | 199 | ||
160 | it('Should fail with a bad category', async function () { | 200 | it('Should fail with a bad category', async function () { |
161 | const fields = { | 201 | const fields = getCompleteVideoUploadAttributes() |
162 | name: 'my super name', | 202 | fields.category = 125 |
163 | category: 125, | 203 | |
164 | licence: 1, | 204 | const attaches = getVideoUploadAttaches |
165 | language: 6, | ||
166 | nsfw: false, | ||
167 | description: 'my super description', | ||
168 | tags: [ 'tag1', 'tag2' ], | ||
169 | channelId | ||
170 | } | ||
171 | const attaches = { | ||
172 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | ||
173 | } | ||
174 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 205 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
175 | }) | 206 | }) |
176 | 207 | ||
177 | it('Should fail without a licence', async function () { | 208 | it('Should fail without a licence', async function () { |
178 | const fields = { | 209 | const fields = getCompleteVideoUploadAttributes() |
179 | name: 'my super name', | 210 | delete fields.licence |
180 | category: 5, | 211 | |
181 | language: 6, | 212 | const attaches = getVideoUploadAttaches() |
182 | nsfw: false, | ||
183 | description: 'my super description', | ||
184 | tags: [ 'tag1', 'tag2' ], | ||
185 | channelId | ||
186 | } | ||
187 | const attaches = { | ||
188 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | ||
189 | } | ||
190 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 213 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
191 | }) | 214 | }) |
192 | 215 | ||
193 | it('Should fail with a bad licence', async function () { | 216 | it('Should fail with a bad licence', async function () { |
194 | const fields = { | 217 | const fields = getCompleteVideoUploadAttributes() |
195 | name: 'my super name', | 218 | fields.licence = 125 |
196 | category: 5, | 219 | |
197 | licence: 125, | 220 | const attaches = getVideoUploadAttaches() |
198 | language: 6, | ||
199 | nsfw: false, | ||
200 | description: 'my super description', | ||
201 | tags: [ 'tag1', 'tag2' ], | ||
202 | channelId | ||
203 | } | ||
204 | const attaches = { | ||
205 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | ||
206 | } | ||
207 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 221 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
208 | }) | 222 | }) |
209 | 223 | ||
210 | it('Should fail with a bad language', async function () { | 224 | it('Should fail with a bad language', async function () { |
211 | const fields = { | 225 | const fields = getCompleteVideoUploadAttributes() |
212 | name: 'my super name', | 226 | fields.language = 563 |
213 | category: 5, | 227 | |
214 | licence: 4, | 228 | const attaches = getVideoUploadAttaches() |
215 | language: 563, | ||
216 | nsfw: false, | ||
217 | description: 'my super description', | ||
218 | tags: [ 'tag1', 'tag2' ], | ||
219 | channelId | ||
220 | } | ||
221 | const attaches = { | ||
222 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | ||
223 | } | ||
224 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 229 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
225 | }) | 230 | }) |
226 | 231 | ||
227 | it('Should fail without nsfw attribute', async function () { | 232 | it('Should fail without nsfw attribute', async function () { |
228 | const fields = { | 233 | const fields = getCompleteVideoUploadAttributes() |
229 | name: 'my super name', | 234 | delete fields.nsfw |
230 | category: 5, | 235 | |
231 | licence: 4, | 236 | const attaches = getVideoUploadAttaches() |
232 | language: 6, | ||
233 | description: 'my super description', | ||
234 | tags: [ 'tag1', 'tag2' ], | ||
235 | channelId | ||
236 | } | ||
237 | const attaches = { | ||
238 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | ||
239 | } | ||
240 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 237 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
241 | }) | 238 | }) |
242 | 239 | ||
243 | it('Should fail with a bad nsfw attribute', async function () { | 240 | it('Should fail with a bad nsfw attribute', async function () { |
244 | const fields = { | 241 | const fields = getCompleteVideoUploadAttributes() |
245 | name: 'my super name', | 242 | fields.nsfw = 2 as any |
246 | category: 5, | 243 | |
247 | licence: 4, | 244 | const attaches = getVideoUploadAttaches() |
248 | language: 6, | ||
249 | nsfw: 2, | ||
250 | description: 'my super description', | ||
251 | tags: [ 'tag1', 'tag2' ], | ||
252 | channelId | ||
253 | } | ||
254 | const attaches = { | ||
255 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | ||
256 | } | ||
257 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 245 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
258 | }) | 246 | }) |
259 | 247 | ||
260 | it('Should fail without description', async function () { | 248 | it('Should fail without description', async function () { |
261 | const fields = { | 249 | const fields = getCompleteVideoUploadAttributes() |
262 | name: 'my super name', | 250 | delete fields.description |
263 | category: 5, | 251 | |
264 | licence: 1, | 252 | const attaches = getVideoUploadAttaches() |
265 | language: 6, | ||
266 | nsfw: false, | ||
267 | tags: [ 'tag1', 'tag2' ], | ||
268 | channelId | ||
269 | } | ||
270 | const attaches = { | ||
271 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | ||
272 | } | ||
273 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 253 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
274 | }) | 254 | }) |
275 | 255 | ||
276 | it('Should fail with a long description', async function () { | 256 | it('Should fail with a long description', async function () { |
277 | const fields = { | 257 | const fields = getCompleteVideoUploadAttributes() |
278 | name: 'my super name', | 258 | fields.description = 'my super description which is very very very very very very very very very very very very long'.repeat(35) |
279 | category: 5, | 259 | |
280 | licence: 1, | 260 | const attaches = getVideoUploadAttaches() |
281 | language: 6, | ||
282 | nsfw: false, | ||
283 | description: 'my super description which is very very very very very very very very very very very very very very long'.repeat(35), | ||
284 | tags: [ 'tag1', 'tag2' ], | ||
285 | channelId | ||
286 | } | ||
287 | const attaches = { | ||
288 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | ||
289 | } | ||
290 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 261 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
291 | }) | 262 | }) |
292 | 263 | ||
293 | it('Should fail without a channel', async function () { | 264 | it('Should fail without a channel', async function () { |
294 | const fields = { | 265 | const fields = getCompleteVideoUploadAttributes() |
295 | name: 'my super name', | 266 | delete fields.channelId |
296 | category: 5, | 267 | |
297 | licence: 1, | 268 | const attaches = getVideoUploadAttaches() |
298 | language: 6, | ||
299 | nsfw: false, | ||
300 | description: 'my super description', | ||
301 | tags: [ 'tag1', 'tag2' ] | ||
302 | } | ||
303 | const attaches = { | ||
304 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | ||
305 | } | ||
306 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 269 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
307 | }) | 270 | }) |
308 | 271 | ||
309 | it('Should fail with a bad channel', async function () { | 272 | it('Should fail with a bad channel', async function () { |
310 | const fields = { | 273 | const fields = getCompleteVideoUploadAttributes() |
311 | name: 'my super name', | 274 | fields.channelId = 545454 |
312 | category: 5, | 275 | |
313 | licence: 1, | 276 | const attaches = getVideoUploadAttaches() |
314 | language: 6, | ||
315 | nsfw: false, | ||
316 | description: 'my super description', | ||
317 | tags: [ 'tag1', 'tag2' ], | ||
318 | channelId: 545454 | ||
319 | } | ||
320 | const attaches = { | ||
321 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | ||
322 | } | ||
323 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 277 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
324 | }) | 278 | }) |
325 | 279 | ||
@@ -332,101 +286,47 @@ describe('Test videos API validator', function () { | |||
332 | 286 | ||
333 | const accessTokenUser = await getUserAccessToken(server, user) | 287 | const accessTokenUser = await getUserAccessToken(server, user) |
334 | const res = await getMyUserInformation(server.url, accessTokenUser) | 288 | const res = await getMyUserInformation(server.url, accessTokenUser) |
335 | const channelId = res.body.videoChannels[0].id | 289 | const customChannelId = res.body.videoChannels[0].id |
336 | 290 | ||
337 | const fields = { | 291 | const fields = getCompleteVideoUploadAttributes() |
338 | name: 'my super name', | 292 | fields.channelId = customChannelId |
339 | category: 5, | 293 | |
340 | licence: 1, | 294 | const attaches = getVideoUploadAttaches() |
341 | language: 6, | ||
342 | nsfw: false, | ||
343 | description: 'my super description', | ||
344 | tags: [ 'tag1', 'tag2' ], | ||
345 | channelId | ||
346 | } | ||
347 | const attaches = { | ||
348 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | ||
349 | } | ||
350 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 295 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
351 | }) | 296 | }) |
352 | 297 | ||
353 | it('Should fail with too many tags', async function () { | 298 | it('Should fail with too many tags', async function () { |
354 | const fields = { | 299 | const fields = getCompleteVideoUploadAttributes() |
355 | name: 'my super name', | 300 | fields.tags = [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] |
356 | category: 5, | 301 | |
357 | licence: 1, | 302 | const attaches = getVideoUploadAttaches() |
358 | language: 6, | ||
359 | nsfw: false, | ||
360 | description: 'my super description', | ||
361 | tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ], | ||
362 | channelId | ||
363 | } | ||
364 | const attaches = { | ||
365 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | ||
366 | } | ||
367 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 303 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
368 | }) | 304 | }) |
369 | 305 | ||
370 | it('Should fail with a tag length too low', async function () { | 306 | it('Should fail with a tag length too low', async function () { |
371 | const fields = { | 307 | const fields = getCompleteVideoUploadAttributes() |
372 | name: 'my super name', | 308 | fields.tags = [ 'tag1', 't' ] |
373 | category: 5, | 309 | |
374 | licence: 1, | 310 | const attaches = getVideoUploadAttaches() |
375 | language: 6, | ||
376 | nsfw: false, | ||
377 | description: 'my super description', | ||
378 | tags: [ 'tag1', 't' ], | ||
379 | channelId | ||
380 | } | ||
381 | const attaches = { | ||
382 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | ||
383 | } | ||
384 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 311 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
385 | }) | 312 | }) |
386 | 313 | ||
387 | it('Should fail with a tag length too big', async function () { | 314 | it('Should fail with a tag length too big', async function () { |
388 | const fields = { | 315 | const fields = getCompleteVideoUploadAttributes() |
389 | name: 'my super name', | 316 | fields.tags = [ 'my_super_tag_too_long_long_long_long_long_long', 'tag1' ] |
390 | category: 5, | 317 | |
391 | licence: 1, | 318 | const attaches = getVideoUploadAttaches() |
392 | language: 6, | ||
393 | nsfw: false, | ||
394 | description: 'my super description', | ||
395 | tags: [ 'my_super_tag_too_long_long_long_long_long_long', 'tag1' ], | ||
396 | channelId | ||
397 | } | ||
398 | const attaches = { | ||
399 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | ||
400 | } | ||
401 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 319 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
402 | }) | 320 | }) |
403 | 321 | ||
404 | it('Should fail without an input file', async function () { | 322 | it('Should fail without an input file', async function () { |
405 | const fields = { | 323 | const fields = getCompleteVideoUploadAttributes() |
406 | name: 'my super name', | ||
407 | category: 5, | ||
408 | licence: 1, | ||
409 | language: 6, | ||
410 | nsfw: false, | ||
411 | description: 'my super description', | ||
412 | tags: [ 'tag1', 'tag2' ], | ||
413 | channelId | ||
414 | } | ||
415 | const attaches = {} | 324 | const attaches = {} |
416 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 325 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
417 | }) | 326 | }) |
418 | 327 | ||
419 | it('Should fail without an incorrect input file', async function () { | 328 | it('Should fail without an incorrect input file', async function () { |
420 | const fields = { | 329 | const fields = getCompleteVideoUploadAttributes() |
421 | name: 'my super name', | ||
422 | category: 5, | ||
423 | licence: 1, | ||
424 | language: 6, | ||
425 | nsfw: false, | ||
426 | description: 'my super description', | ||
427 | tags: [ 'tag1', 'tag2' ], | ||
428 | channelId | ||
429 | } | ||
430 | const attaches = { | 330 | const attaches = { |
431 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short_fake.webm') | 331 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short_fake.webm') |
432 | } | 332 | } |
@@ -434,16 +334,7 @@ describe('Test videos API validator', function () { | |||
434 | }) | 334 | }) |
435 | 335 | ||
436 | it('Should fail with a too big duration', async function () { | 336 | it('Should fail with a too big duration', async function () { |
437 | const fields = { | 337 | const fields = getCompleteVideoUploadAttributes() |
438 | name: 'my super name', | ||
439 | category: 5, | ||
440 | licence: 1, | ||
441 | language: 6, | ||
442 | nsfw: false, | ||
443 | description: 'my super description', | ||
444 | tags: [ 'tag1', 'tag2' ], | ||
445 | channelId | ||
446 | } | ||
447 | const attaches = { | 338 | const attaches = { |
448 | 'videofile': join(__dirname, '..', 'fixtures', 'video_too_long.webm') | 339 | 'videofile': join(__dirname, '..', 'fixtures', 'video_too_long.webm') |
449 | } | 340 | } |
@@ -453,19 +344,8 @@ describe('Test videos API validator', function () { | |||
453 | it('Should succeed with the correct parameters', async function () { | 344 | it('Should succeed with the correct parameters', async function () { |
454 | this.timeout(10000) | 345 | this.timeout(10000) |
455 | 346 | ||
456 | const fields = { | 347 | const fields = getCompleteVideoUploadAttributes() |
457 | name: 'my super name', | 348 | const attaches = getVideoUploadAttaches() |
458 | category: 5, | ||
459 | licence: 1, | ||
460 | language: 6, | ||
461 | nsfw: false, | ||
462 | description: 'my super description', | ||
463 | tags: [ 'tag1', 'tag2' ], | ||
464 | channelId | ||
465 | } | ||
466 | const attaches = { | ||
467 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | ||
468 | } | ||
469 | 349 | ||
470 | await makePostUploadRequest({ | 350 | await makePostUploadRequest({ |
471 | url: server.url, | 351 | url: server.url, |
@@ -512,26 +392,13 @@ describe('Test videos API validator', function () { | |||
512 | }) | 392 | }) |
513 | 393 | ||
514 | it('Should fail without a valid uuid', async function () { | 394 | it('Should fail without a valid uuid', async function () { |
515 | const fields = { | 395 | const fields = getCompleteVideoUpdateAttributes() |
516 | category: 5, | ||
517 | licence: 2, | ||
518 | language: 6, | ||
519 | nsfw: false, | ||
520 | description: 'my super description', | ||
521 | tags: [ 'tag1', 'tag2' ] | ||
522 | } | ||
523 | await makePutBodyRequest({ url: server.url, path: path + 'blabla', token: server.accessToken, fields }) | 396 | await makePutBodyRequest({ url: server.url, path: path + 'blabla', token: server.accessToken, fields }) |
524 | }) | 397 | }) |
525 | 398 | ||
526 | it('Should fail with an unknown id', async function () { | 399 | it('Should fail with an unknown id', async function () { |
527 | const fields = { | 400 | const fields = getCompleteVideoUpdateAttributes() |
528 | category: 5, | 401 | |
529 | licence: 2, | ||
530 | language: 6, | ||
531 | nsfw: false, | ||
532 | description: 'my super description', | ||
533 | tags: [ 'tag1', 'tag2' ] | ||
534 | } | ||
535 | await makePutBodyRequest({ | 402 | await makePutBodyRequest({ |
536 | url: server.url, | 403 | url: server.url, |
537 | path: path + '4da6fde3-88f7-4d16-b119-108df5630b06', | 404 | path: path + '4da6fde3-88f7-4d16-b119-108df5630b06', |
@@ -542,127 +409,77 @@ describe('Test videos API validator', function () { | |||
542 | }) | 409 | }) |
543 | 410 | ||
544 | it('Should fail with a long name', async function () { | 411 | it('Should fail with a long name', async function () { |
545 | const fields = { | 412 | const fields = getCompleteVideoUpdateAttributes() |
546 | name: 'My very very very very very very very very very very very very very very very very very ' + | 413 | fields.name = 'My very very very very very very very very very very very very very very very very long'.repeat(3) |
547 | 'very very very very very very very very very very very very very very very very long long' + | 414 | |
548 | 'very very very very very very very very very very very very very very very very long name', | ||
549 | category: 5, | ||
550 | licence: 2, | ||
551 | language: 6, | ||
552 | nsfw: false, | ||
553 | description: 'my super description', | ||
554 | tags: [ 'tag1', 'tag2' ] | ||
555 | } | ||
556 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) | 415 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) |
557 | }) | 416 | }) |
558 | 417 | ||
559 | it('Should fail with a bad category', async function () { | 418 | it('Should fail with a bad category', async function () { |
560 | const fields = { | 419 | const fields = getCompleteVideoUpdateAttributes() |
561 | name: 'my super name', | 420 | fields.category = 128 |
562 | category: 128, | 421 | |
563 | licence: 2, | ||
564 | language: 6, | ||
565 | nsfw: false, | ||
566 | description: 'my super description', | ||
567 | tags: [ 'tag1', 'tag2' ] | ||
568 | } | ||
569 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) | 422 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) |
570 | }) | 423 | }) |
571 | 424 | ||
572 | it('Should fail with a bad licence', async function () { | 425 | it('Should fail with a bad licence', async function () { |
573 | const fields = { | 426 | const fields = getCompleteVideoUpdateAttributes() |
574 | name: 'my super name', | 427 | fields.licence = 128 |
575 | category: 5, | 428 | |
576 | licence: 128, | ||
577 | language: 6, | ||
578 | nsfw: false, | ||
579 | description: 'my super description', | ||
580 | tags: [ 'tag1', 'tag2' ] | ||
581 | } | ||
582 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) | 429 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) |
583 | }) | 430 | }) |
584 | 431 | ||
585 | it('Should fail with a bad language', async function () { | 432 | it('Should fail with a bad language', async function () { |
586 | const fields = { | 433 | const fields = getCompleteVideoUpdateAttributes() |
587 | name: 'my super name', | 434 | fields.language = 896 |
588 | category: 5, | 435 | |
589 | licence: 3, | ||
590 | language: 896, | ||
591 | nsfw: false, | ||
592 | description: 'my super description', | ||
593 | tags: [ 'tag1', 'tag2' ] | ||
594 | } | ||
595 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) | 436 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) |
596 | }) | 437 | }) |
597 | 438 | ||
598 | it('Should fail with a bad nsfw attribute', async function () { | 439 | it('Should fail with a bad nsfw attribute', async function () { |
599 | const fields = { | 440 | const fields = getCompleteVideoUpdateAttributes() |
600 | name: 'my super name', | 441 | fields.nsfw = (-4 as any) |
601 | category: 5, | 442 | |
602 | licence: 5, | ||
603 | language: 6, | ||
604 | nsfw: -4, | ||
605 | description: 'my super description', | ||
606 | tags: [ 'tag1', 'tag2' ] | ||
607 | } | ||
608 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) | 443 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) |
609 | }) | 444 | }) |
610 | 445 | ||
611 | it('Should fail with a long description', async function () { | 446 | it('Should fail with a long description', async function () { |
612 | const fields = { | 447 | const fields = getCompleteVideoUpdateAttributes() |
613 | name: 'my super name', | 448 | fields.description = 'my super description which is very very very very very very very very very very very very very long'.repeat(35) |
614 | category: 5, | 449 | |
615 | licence: 2, | ||
616 | language: 6, | ||
617 | nsfw: false, | ||
618 | description: 'my super description which is very very very very very very very very very very very very very long'.repeat(35), | ||
619 | tags: [ 'tag1', 'tag2' ] | ||
620 | } | ||
621 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) | 450 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) |
622 | }) | 451 | }) |
623 | 452 | ||
624 | it('Should fail with too many tags', async function () { | 453 | it('Should fail with too many tags', async function () { |
625 | const fields = { | 454 | const fields = getCompleteVideoUpdateAttributes() |
626 | name: 'my super name', | 455 | fields.tags = [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] |
627 | category: 5, | 456 | |
628 | licence: 2, | ||
629 | language: 6, | ||
630 | nsfw: false, | ||
631 | description: 'my super description', | ||
632 | tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] | ||
633 | } | ||
634 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) | 457 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) |
635 | }) | 458 | }) |
636 | 459 | ||
637 | it('Should fail with a tag length too low', async function () { | 460 | it('Should fail with a tag length too low', async function () { |
638 | const fields = { | 461 | const fields = getCompleteVideoUpdateAttributes() |
639 | name: 'my super name', | 462 | fields.tags = [ 'tag1', 't' ] |
640 | category: 5, | 463 | |
641 | licence: 2, | ||
642 | language: 6, | ||
643 | nsfw: false, | ||
644 | description: 'my super description', | ||
645 | tags: [ 'tag1', 't' ] | ||
646 | } | ||
647 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) | 464 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) |
648 | }) | 465 | }) |
649 | 466 | ||
650 | it('Should fail with a tag length too big', async function () { | 467 | it('Should fail with a tag length too big', async function () { |
651 | const fields = { | 468 | const fields = getCompleteVideoUpdateAttributes() |
652 | name: 'my super name', | 469 | fields.tags = [ 'my_super_tag_too_long_long_long_long', 'tag1' ] |
653 | category: 5, | 470 | |
654 | licence: 2, | ||
655 | language: 6, | ||
656 | nsfw: false, | ||
657 | description: 'my super description', | ||
658 | tags: [ 'my_super_tag_too_long_long_long_long', 'tag1' ] | ||
659 | } | ||
660 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) | 471 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields }) |
661 | }) | 472 | }) |
662 | 473 | ||
663 | it('Should fail with a video of another user') | 474 | it('Should fail with a video of another user') |
664 | 475 | ||
665 | it('Should fail with a video of another pod') | 476 | it('Should fail with a video of another pod') |
477 | |||
478 | it('Should succeed with the correct parameters', async function () { | ||
479 | const fields = getCompleteVideoUpdateAttributes() | ||
480 | |||
481 | await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields, statusCodeExpected: 204 }) | ||
482 | }) | ||
666 | }) | 483 | }) |
667 | 484 | ||
668 | describe('When getting a video', function () { | 485 | describe('When getting a video', function () { |