diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-10-24 19:41:30 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-10-26 09:11:38 +0200 |
commit | 5f04dd2f743961e0a06c29531cc3ccc9e4928d56 (patch) | |
tree | a73085d0d83affc2377b78a2c7c25bda08d26388 /server/tests/api/check-params/videos.ts | |
parent | 72c7248b6fdcdb2175e726ff51b42e7555f2bd84 (diff) | |
download | PeerTube-5f04dd2f743961e0a06c29531cc3ccc9e4928d56.tar.gz PeerTube-5f04dd2f743961e0a06c29531cc3ccc9e4928d56.tar.zst PeerTube-5f04dd2f743961e0a06c29531cc3ccc9e4928d56.zip |
Add video channel tests
Diffstat (limited to 'server/tests/api/check-params/videos.ts')
-rw-r--r-- | server/tests/api/check-params/videos.ts | 123 |
1 files changed, 104 insertions, 19 deletions
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts index af75d33c1..167b45b61 100644 --- a/server/tests/api/check-params/videos.ts +++ b/server/tests/api/check-params/videos.ts | |||
@@ -14,12 +14,16 @@ import { | |||
14 | makePutBodyRequest, | 14 | makePutBodyRequest, |
15 | setAccessTokensToServers, | 15 | setAccessTokensToServers, |
16 | killallServers, | 16 | killallServers, |
17 | makePostUploadRequest | 17 | makePostUploadRequest, |
18 | getMyUserInformation, | ||
19 | createUser, | ||
20 | getUserAccessToken | ||
18 | } from '../../utils' | 21 | } from '../../utils' |
19 | 22 | ||
20 | describe('Test videos API validator', function () { | 23 | describe('Test videos API validator', function () { |
21 | const path = '/api/v1/videos/' | 24 | const path = '/api/v1/videos/' |
22 | let server: ServerInfo | 25 | let server: ServerInfo |
26 | let channelId: number | ||
23 | 27 | ||
24 | // --------------------------------------------------------------- | 28 | // --------------------------------------------------------------- |
25 | 29 | ||
@@ -31,6 +35,9 @@ describe('Test videos API validator', function () { | |||
31 | server = await runServer(1) | 35 | server = await runServer(1) |
32 | 36 | ||
33 | await setAccessTokensToServers([ server ]) | 37 | await setAccessTokensToServers([ server ]) |
38 | |||
39 | const res = await getMyUserInformation(server.url, server.accessToken) | ||
40 | channelId = res.body.videoChannels[0].id | ||
34 | }) | 41 | }) |
35 | 42 | ||
36 | describe('When listing a video', function () { | 43 | describe('When listing a video', function () { |
@@ -106,7 +113,8 @@ describe('Test videos API validator', function () { | |||
106 | language: 6, | 113 | language: 6, |
107 | nsfw: false, | 114 | nsfw: false, |
108 | description: 'my super description', | 115 | description: 'my super description', |
109 | tags: [ 'tag1', 'tag2' ] | 116 | tags: [ 'tag1', 'tag2' ], |
117 | channelId | ||
110 | } | 118 | } |
111 | const attaches = { | 119 | const attaches = { |
112 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 120 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
@@ -122,7 +130,8 @@ describe('Test videos API validator', function () { | |||
122 | language: 6, | 130 | language: 6, |
123 | nsfw: false, | 131 | nsfw: false, |
124 | description: 'my super description', | 132 | description: 'my super description', |
125 | tags: [ 'tag1', 'tag2' ] | 133 | tags: [ 'tag1', 'tag2' ], |
134 | channelId | ||
126 | } | 135 | } |
127 | const attaches = { | 136 | const attaches = { |
128 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 137 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
@@ -137,7 +146,8 @@ describe('Test videos API validator', function () { | |||
137 | language: 6, | 146 | language: 6, |
138 | nsfw: false, | 147 | nsfw: false, |
139 | description: 'my super description', | 148 | description: 'my super description', |
140 | tags: [ 'tag1', 'tag2' ] | 149 | tags: [ 'tag1', 'tag2' ], |
150 | channelId | ||
141 | } | 151 | } |
142 | const attaches = { | 152 | const attaches = { |
143 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 153 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
@@ -153,7 +163,8 @@ describe('Test videos API validator', function () { | |||
153 | language: 6, | 163 | language: 6, |
154 | nsfw: false, | 164 | nsfw: false, |
155 | description: 'my super description', | 165 | description: 'my super description', |
156 | tags: [ 'tag1', 'tag2' ] | 166 | tags: [ 'tag1', 'tag2' ], |
167 | channelId | ||
157 | } | 168 | } |
158 | const attaches = { | 169 | const attaches = { |
159 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 170 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
@@ -168,7 +179,8 @@ describe('Test videos API validator', function () { | |||
168 | language: 6, | 179 | language: 6, |
169 | nsfw: false, | 180 | nsfw: false, |
170 | description: 'my super description', | 181 | description: 'my super description', |
171 | tags: [ 'tag1', 'tag2' ] | 182 | tags: [ 'tag1', 'tag2' ], |
183 | channelId | ||
172 | } | 184 | } |
173 | const attaches = { | 185 | const attaches = { |
174 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 186 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
@@ -184,7 +196,8 @@ describe('Test videos API validator', function () { | |||
184 | language: 6, | 196 | language: 6, |
185 | nsfw: false, | 197 | nsfw: false, |
186 | description: 'my super description', | 198 | description: 'my super description', |
187 | tags: [ 'tag1', 'tag2' ] | 199 | tags: [ 'tag1', 'tag2' ], |
200 | channelId | ||
188 | } | 201 | } |
189 | const attaches = { | 202 | const attaches = { |
190 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 203 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
@@ -200,7 +213,8 @@ describe('Test videos API validator', function () { | |||
200 | language: 563, | 213 | language: 563, |
201 | nsfw: false, | 214 | nsfw: false, |
202 | description: 'my super description', | 215 | description: 'my super description', |
203 | tags: [ 'tag1', 'tag2' ] | 216 | tags: [ 'tag1', 'tag2' ], |
217 | channelId | ||
204 | } | 218 | } |
205 | const attaches = { | 219 | const attaches = { |
206 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 220 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
@@ -215,7 +229,8 @@ describe('Test videos API validator', function () { | |||
215 | licence: 4, | 229 | licence: 4, |
216 | language: 6, | 230 | language: 6, |
217 | description: 'my super description', | 231 | description: 'my super description', |
218 | tags: [ 'tag1', 'tag2' ] | 232 | tags: [ 'tag1', 'tag2' ], |
233 | channelId | ||
219 | } | 234 | } |
220 | const attaches = { | 235 | const attaches = { |
221 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 236 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
@@ -223,7 +238,7 @@ describe('Test videos API validator', function () { | |||
223 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 238 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
224 | }) | 239 | }) |
225 | 240 | ||
226 | it('Should fail with a bad nsfw attribue', async function () { | 241 | it('Should fail with a bad nsfw attribute', async function () { |
227 | const fields = { | 242 | const fields = { |
228 | name: 'my super name', | 243 | name: 'my super name', |
229 | category: 5, | 244 | category: 5, |
@@ -231,7 +246,8 @@ describe('Test videos API validator', function () { | |||
231 | language: 6, | 246 | language: 6, |
232 | nsfw: 2, | 247 | nsfw: 2, |
233 | description: 'my super description', | 248 | description: 'my super description', |
234 | tags: [ 'tag1', 'tag2' ] | 249 | tags: [ 'tag1', 'tag2' ], |
250 | channelId | ||
235 | } | 251 | } |
236 | const attaches = { | 252 | const attaches = { |
237 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 253 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
@@ -246,7 +262,8 @@ describe('Test videos API validator', function () { | |||
246 | licence: 1, | 262 | licence: 1, |
247 | language: 6, | 263 | language: 6, |
248 | nsfw: false, | 264 | nsfw: false, |
249 | tags: [ 'tag1', 'tag2' ] | 265 | tags: [ 'tag1', 'tag2' ], |
266 | channelId | ||
250 | } | 267 | } |
251 | const attaches = { | 268 | const attaches = { |
252 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 269 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
@@ -264,6 +281,23 @@ describe('Test videos API validator', function () { | |||
264 | description: 'my super description which is very very very very very very very very very very very very very very' + | 281 | description: 'my super description which is very very very very very very very very very very very very very very' + |
265 | 'very very very very very very very very very very very very very very very very very very very very very' + | 282 | 'very very very very very very very very very very very very very very very very very very very very very' + |
266 | 'very very very very very very very very very very very very very very very long', | 283 | 'very very very very very very very very very very very very very very very long', |
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 }) | ||
291 | }) | ||
292 | |||
293 | it('Should fail without a channel', async function () { | ||
294 | const fields = { | ||
295 | name: 'my super name', | ||
296 | category: 5, | ||
297 | licence: 1, | ||
298 | language: 6, | ||
299 | nsfw: false, | ||
300 | description: 'my super description', | ||
267 | tags: [ 'tag1', 'tag2' ] | 301 | tags: [ 'tag1', 'tag2' ] |
268 | } | 302 | } |
269 | const attaches = { | 303 | const attaches = { |
@@ -272,6 +306,50 @@ describe('Test videos API validator', function () { | |||
272 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 306 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
273 | }) | 307 | }) |
274 | 308 | ||
309 | it('Should fail with a bad channel', async function () { | ||
310 | const fields = { | ||
311 | name: 'my super name', | ||
312 | category: 5, | ||
313 | licence: 1, | ||
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 }) | ||
324 | }) | ||
325 | |||
326 | it('Should fail with another user channel', async function () { | ||
327 | const user = { | ||
328 | username: 'fake', | ||
329 | password: 'fake_password' | ||
330 | } | ||
331 | await createUser(server.url, server.accessToken, user.username, user.password) | ||
332 | |||
333 | const accessTokenUser = await getUserAccessToken(server, user) | ||
334 | const res = await getMyUserInformation(server.url, accessTokenUser) | ||
335 | const channelId = res.body.videoChannels[0].id | ||
336 | |||
337 | const fields = { | ||
338 | name: 'my super name', | ||
339 | category: 5, | ||
340 | licence: 1, | ||
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 }) | ||
351 | }) | ||
352 | |||
275 | it('Should fail with too many tags', async function () { | 353 | it('Should fail with too many tags', async function () { |
276 | const fields = { | 354 | const fields = { |
277 | name: 'my super name', | 355 | name: 'my super name', |
@@ -280,7 +358,8 @@ describe('Test videos API validator', function () { | |||
280 | language: 6, | 358 | language: 6, |
281 | nsfw: false, | 359 | nsfw: false, |
282 | description: 'my super description', | 360 | description: 'my super description', |
283 | tags: [ 'tag1', 'tag2', 'tag3', 'tag4' ] | 361 | tags: [ 'tag1', 'tag2', 'tag3', 'tag4' ], |
362 | channelId | ||
284 | } | 363 | } |
285 | const attaches = { | 364 | const attaches = { |
286 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 365 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
@@ -296,7 +375,8 @@ describe('Test videos API validator', function () { | |||
296 | language: 6, | 375 | language: 6, |
297 | nsfw: false, | 376 | nsfw: false, |
298 | description: 'my super description', | 377 | description: 'my super description', |
299 | tags: [ 'tag1', 't' ] | 378 | tags: [ 'tag1', 't' ], |
379 | channelId | ||
300 | } | 380 | } |
301 | const attaches = { | 381 | const attaches = { |
302 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 382 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
@@ -312,7 +392,8 @@ describe('Test videos API validator', function () { | |||
312 | language: 6, | 392 | language: 6, |
313 | nsfw: false, | 393 | nsfw: false, |
314 | description: 'my super description', | 394 | description: 'my super description', |
315 | tags: [ 'my_super_tag_too_long', 'tag1' ] | 395 | tags: [ 'my_super_tag_too_long', 'tag1' ], |
396 | channelId | ||
316 | } | 397 | } |
317 | const attaches = { | 398 | const attaches = { |
318 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 399 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
@@ -328,7 +409,8 @@ describe('Test videos API validator', function () { | |||
328 | language: 6, | 409 | language: 6, |
329 | nsfw: false, | 410 | nsfw: false, |
330 | description: 'my super description', | 411 | description: 'my super description', |
331 | tags: [ 'tag1', 'tag2' ] | 412 | tags: [ 'tag1', 'tag2' ], |
413 | channelId | ||
332 | } | 414 | } |
333 | const attaches = {} | 415 | const attaches = {} |
334 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 416 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
@@ -342,7 +424,8 @@ describe('Test videos API validator', function () { | |||
342 | language: 6, | 424 | language: 6, |
343 | nsfw: false, | 425 | nsfw: false, |
344 | description: 'my super description', | 426 | description: 'my super description', |
345 | tags: [ 'tag1', 'tag2' ] | 427 | tags: [ 'tag1', 'tag2' ], |
428 | channelId | ||
346 | } | 429 | } |
347 | const attaches = { | 430 | const attaches = { |
348 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short_fake.webm') | 431 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short_fake.webm') |
@@ -358,7 +441,8 @@ describe('Test videos API validator', function () { | |||
358 | language: 6, | 441 | language: 6, |
359 | nsfw: false, | 442 | nsfw: false, |
360 | description: 'my super description', | 443 | description: 'my super description', |
361 | tags: [ 'tag1', 'tag2' ] | 444 | tags: [ 'tag1', 'tag2' ], |
445 | channelId | ||
362 | } | 446 | } |
363 | const attaches = { | 447 | const attaches = { |
364 | 'videofile': join(__dirname, '..', 'fixtures', 'video_too_long.webm') | 448 | 'videofile': join(__dirname, '..', 'fixtures', 'video_too_long.webm') |
@@ -376,7 +460,8 @@ describe('Test videos API validator', function () { | |||
376 | language: 6, | 460 | language: 6, |
377 | nsfw: false, | 461 | nsfw: false, |
378 | description: 'my super description', | 462 | description: 'my super description', |
379 | tags: [ 'tag1', 'tag2' ] | 463 | tags: [ 'tag1', 'tag2' ], |
464 | channelId | ||
380 | } | 465 | } |
381 | const attaches = { | 466 | const attaches = { |
382 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 467 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |