diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-09-07 21:46:44 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-09-07 21:46:44 +0200 |
commit | e95561cdf195d2926e1856ed285c2b86960bc86f (patch) | |
tree | 7f25c340e307fcbb13f77769b64e75603520ecc6 /server | |
parent | 0cee28c1b251b00067681286d136ca947cf34808 (diff) | |
download | PeerTube-e95561cdf195d2926e1856ed285c2b86960bc86f.tar.gz PeerTube-e95561cdf195d2926e1856ed285c2b86960bc86f.tar.zst PeerTube-e95561cdf195d2926e1856ed285c2b86960bc86f.zip |
Upload a video to /videos/upload
This is an action, not a REST endpoint
Diffstat (limited to 'server')
-rw-r--r-- | server/controllers/api/videos/index.ts | 2 | ||||
-rw-r--r-- | server/tests/api/check-params/videos.ts | 63 | ||||
-rw-r--r-- | server/tests/cli/reset-password.ts | 2 | ||||
-rw-r--r-- | server/tests/cli/update-host.ts | 2 | ||||
-rw-r--r-- | server/tests/utils/videos.ts | 2 |
5 files changed, 46 insertions, 25 deletions
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 3ec9d97bb..3a19fe989 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts | |||
@@ -92,7 +92,7 @@ videosRouter.put('/:id', | |||
92 | videosUpdateValidator, | 92 | videosUpdateValidator, |
93 | updateVideoRetryWrapper | 93 | updateVideoRetryWrapper |
94 | ) | 94 | ) |
95 | videosRouter.post('/', | 95 | videosRouter.post('/upload', |
96 | authenticate, | 96 | authenticate, |
97 | reqFiles, | 97 | reqFiles, |
98 | videosAddValidator, | 98 | videosAddValidator, |
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts index 8d30769d3..af75d33c1 100644 --- a/server/tests/api/check-params/videos.ts +++ b/server/tests/api/check-params/videos.ts | |||
@@ -96,7 +96,7 @@ describe('Test videos API validator', function () { | |||
96 | it('Should fail with nothing', async function () { | 96 | it('Should fail with nothing', async function () { |
97 | const fields = {} | 97 | const fields = {} |
98 | const attaches = {} | 98 | const attaches = {} |
99 | await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) | 99 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
100 | }) | 100 | }) |
101 | 101 | ||
102 | it('Should fail without name', async function () { | 102 | it('Should fail without name', async function () { |
@@ -111,7 +111,7 @@ describe('Test videos API validator', function () { | |||
111 | const attaches = { | 111 | const attaches = { |
112 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 112 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
113 | } | 113 | } |
114 | await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) | 114 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
115 | }) | 115 | }) |
116 | 116 | ||
117 | it('Should fail with a long name', async function () { | 117 | it('Should fail with a long name', async function () { |
@@ -127,7 +127,7 @@ describe('Test videos API validator', function () { | |||
127 | const attaches = { | 127 | const attaches = { |
128 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 128 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
129 | } | 129 | } |
130 | await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) | 130 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
131 | }) | 131 | }) |
132 | 132 | ||
133 | it('Should fail without a category', async function () { | 133 | it('Should fail without a category', async function () { |
@@ -142,7 +142,7 @@ describe('Test videos API validator', function () { | |||
142 | const attaches = { | 142 | const attaches = { |
143 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 143 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
144 | } | 144 | } |
145 | await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) | 145 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
146 | }) | 146 | }) |
147 | 147 | ||
148 | it('Should fail with a bad category', async function () { | 148 | it('Should fail with a bad category', async function () { |
@@ -158,7 +158,7 @@ describe('Test videos API validator', function () { | |||
158 | const attaches = { | 158 | const attaches = { |
159 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 159 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
160 | } | 160 | } |
161 | await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) | 161 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
162 | }) | 162 | }) |
163 | 163 | ||
164 | it('Should fail without a licence', async function () { | 164 | it('Should fail without a licence', async function () { |
@@ -173,7 +173,7 @@ describe('Test videos API validator', function () { | |||
173 | const attaches = { | 173 | const attaches = { |
174 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 174 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
175 | } | 175 | } |
176 | await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) | 176 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
177 | }) | 177 | }) |
178 | 178 | ||
179 | it('Should fail with a bad licence', async function () { | 179 | it('Should fail with a bad licence', async function () { |
@@ -189,7 +189,7 @@ describe('Test videos API validator', function () { | |||
189 | const attaches = { | 189 | const attaches = { |
190 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 190 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
191 | } | 191 | } |
192 | await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) | 192 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
193 | }) | 193 | }) |
194 | 194 | ||
195 | it('Should fail with a bad language', async function () { | 195 | it('Should fail with a bad language', async function () { |
@@ -205,7 +205,7 @@ describe('Test videos API validator', function () { | |||
205 | const attaches = { | 205 | const attaches = { |
206 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 206 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
207 | } | 207 | } |
208 | await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) | 208 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
209 | }) | 209 | }) |
210 | 210 | ||
211 | it('Should fail without nsfw attribute', async function () { | 211 | it('Should fail without nsfw attribute', async function () { |
@@ -220,7 +220,7 @@ describe('Test videos API validator', function () { | |||
220 | const attaches = { | 220 | const attaches = { |
221 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 221 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
222 | } | 222 | } |
223 | await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) | 223 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
224 | }) | 224 | }) |
225 | 225 | ||
226 | it('Should fail with a bad nsfw attribue', async function () { | 226 | it('Should fail with a bad nsfw attribue', async function () { |
@@ -236,7 +236,7 @@ describe('Test videos API validator', function () { | |||
236 | const attaches = { | 236 | const attaches = { |
237 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 237 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
238 | } | 238 | } |
239 | await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) | 239 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
240 | }) | 240 | }) |
241 | 241 | ||
242 | it('Should fail without description', async function () { | 242 | it('Should fail without description', async function () { |
@@ -251,7 +251,7 @@ describe('Test videos API validator', function () { | |||
251 | const attaches = { | 251 | const attaches = { |
252 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 252 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
253 | } | 253 | } |
254 | await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) | 254 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
255 | }) | 255 | }) |
256 | 256 | ||
257 | it('Should fail with a long description', async function () { | 257 | it('Should fail with a long description', async function () { |
@@ -269,7 +269,7 @@ describe('Test videos API validator', function () { | |||
269 | const attaches = { | 269 | const attaches = { |
270 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 270 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
271 | } | 271 | } |
272 | await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) | 272 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
273 | }) | 273 | }) |
274 | 274 | ||
275 | it('Should fail with too many tags', async function () { | 275 | it('Should fail with too many tags', async function () { |
@@ -285,7 +285,7 @@ describe('Test videos API validator', function () { | |||
285 | const attaches = { | 285 | const attaches = { |
286 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 286 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
287 | } | 287 | } |
288 | await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) | 288 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
289 | }) | 289 | }) |
290 | 290 | ||
291 | it('Should fail with a tag length too low', async function () { | 291 | it('Should fail with a tag length too low', async function () { |
@@ -301,7 +301,7 @@ describe('Test videos API validator', function () { | |||
301 | const attaches = { | 301 | const attaches = { |
302 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 302 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
303 | } | 303 | } |
304 | await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) | 304 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
305 | }) | 305 | }) |
306 | 306 | ||
307 | it('Should fail with a tag length too big', async function () { | 307 | it('Should fail with a tag length too big', async function () { |
@@ -317,7 +317,7 @@ describe('Test videos API validator', function () { | |||
317 | const attaches = { | 317 | const attaches = { |
318 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 318 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
319 | } | 319 | } |
320 | await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) | 320 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
321 | }) | 321 | }) |
322 | 322 | ||
323 | it('Should fail without an input file', async function () { | 323 | it('Should fail without an input file', async function () { |
@@ -331,7 +331,7 @@ describe('Test videos API validator', function () { | |||
331 | tags: [ 'tag1', 'tag2' ] | 331 | tags: [ 'tag1', 'tag2' ] |
332 | } | 332 | } |
333 | const attaches = {} | 333 | const attaches = {} |
334 | await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) | 334 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
335 | }) | 335 | }) |
336 | 336 | ||
337 | it('Should fail without an incorrect input file', async function () { | 337 | it('Should fail without an incorrect input file', async function () { |
@@ -347,7 +347,7 @@ describe('Test videos API validator', function () { | |||
347 | const attaches = { | 347 | const attaches = { |
348 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short_fake.webm') | 348 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short_fake.webm') |
349 | } | 349 | } |
350 | await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) | 350 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
351 | }) | 351 | }) |
352 | 352 | ||
353 | it('Should fail with a too big duration', async function () { | 353 | it('Should fail with a too big duration', async function () { |
@@ -363,7 +363,7 @@ describe('Test videos API validator', function () { | |||
363 | const attaches = { | 363 | const attaches = { |
364 | 'videofile': join(__dirname, '..', 'fixtures', 'video_too_long.webm') | 364 | 'videofile': join(__dirname, '..', 'fixtures', 'video_too_long.webm') |
365 | } | 365 | } |
366 | await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) | 366 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
367 | }) | 367 | }) |
368 | 368 | ||
369 | it('Should succeed with the correct parameters', async function () { | 369 | it('Should succeed with the correct parameters', async function () { |
@@ -382,13 +382,34 @@ describe('Test videos API validator', function () { | |||
382 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 382 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
383 | } | 383 | } |
384 | 384 | ||
385 | await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches, statusCodeExpected: 204 }) | 385 | await makePostUploadRequest({ |
386 | url: server.url, | ||
387 | path: path + '/upload', | ||
388 | token: server.accessToken, | ||
389 | fields, | ||
390 | attaches, | ||
391 | statusCodeExpected: 204 | ||
392 | }) | ||
386 | 393 | ||
387 | attaches.videofile = join(__dirname, '..', 'fixtures', 'video_short.mp4') | 394 | attaches.videofile = join(__dirname, '..', 'fixtures', 'video_short.mp4') |
388 | await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches, statusCodeExpected: 204 }) | 395 | await makePostUploadRequest({ |
396 | url: server.url, | ||
397 | path: path + '/upload', | ||
398 | token: server.accessToken, | ||
399 | fields, | ||
400 | attaches, | ||
401 | statusCodeExpected: 204 | ||
402 | }) | ||
389 | 403 | ||
390 | attaches.videofile = join(__dirname, '..', 'fixtures', 'video_short.ogv') | 404 | attaches.videofile = join(__dirname, '..', 'fixtures', 'video_short.ogv') |
391 | await makePostUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches, statusCodeExpected: 204 }) | 405 | await makePostUploadRequest({ |
406 | url: server.url, | ||
407 | path: path + '/upload', | ||
408 | token: server.accessToken, | ||
409 | fields, | ||
410 | attaches, | ||
411 | statusCodeExpected: 204 | ||
412 | }) | ||
392 | }) | 413 | }) |
393 | }) | 414 | }) |
394 | 415 | ||
diff --git a/server/tests/cli/reset-password.ts b/server/tests/cli/reset-password.ts index bbf0b3d11..c75a1611c 100644 --- a/server/tests/cli/reset-password.ts +++ b/server/tests/cli/reset-password.ts | |||
@@ -26,7 +26,7 @@ describe('Test reset password scripts', function () { | |||
26 | }) | 26 | }) |
27 | 27 | ||
28 | it('Should change the user password from CLI', async function () { | 28 | it('Should change the user password from CLI', async function () { |
29 | this.timeout(20000) | 29 | this.timeout(30000) |
30 | 30 | ||
31 | const env = getEnvCli(server) | 31 | const env = getEnvCli(server) |
32 | await execCLI(`echo coucou | ${env} npm run reset-password -- -u user_1`) | 32 | await execCLI(`echo coucou | ${env} npm run reset-password -- -u user_1`) |
diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts index af9703b32..644b3807e 100644 --- a/server/tests/cli/update-host.ts +++ b/server/tests/cli/update-host.ts | |||
@@ -38,7 +38,7 @@ describe('Test update host scripts', function () { | |||
38 | }) | 38 | }) |
39 | 39 | ||
40 | it('Should update torrent hosts', async function () { | 40 | it('Should update torrent hosts', async function () { |
41 | this.timeout(20000) | 41 | this.timeout(30000) |
42 | 42 | ||
43 | killallServers([ server ]) | 43 | killallServers([ server ]) |
44 | server = await runServer(1) | 44 | server = await runServer(1) |
diff --git a/server/tests/utils/videos.ts b/server/tests/utils/videos.ts index 83271beca..0de506cd9 100644 --- a/server/tests/utils/videos.ts +++ b/server/tests/utils/videos.ts | |||
@@ -163,7 +163,7 @@ async function testVideoImage (url: string, imageName: string, imagePath: string | |||
163 | } | 163 | } |
164 | 164 | ||
165 | function uploadVideo (url: string, accessToken: string, videoAttributesArg: VideoAttributes, specialStatus = 204) { | 165 | function uploadVideo (url: string, accessToken: string, videoAttributesArg: VideoAttributes, specialStatus = 204) { |
166 | const path = '/api/v1/videos' | 166 | const path = '/api/v1/videos/upload' |
167 | 167 | ||
168 | // Default attributes | 168 | // Default attributes |
169 | let attributes = { | 169 | let attributes = { |