From 67100f1f971dd10a466a321899b56c0813e08d31 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 16 May 2016 19:49:10 +0200 Subject: Add a check for the duration of videos --- server/tests/api/checkParams.js | 30 ++++++++++++++++++++------ server/tests/api/fixtures/video_too_long.webm | Bin 0 -> 881903 bytes 2 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 server/tests/api/fixtures/video_too_long.webm (limited to 'server/tests') diff --git a/server/tests/api/checkParams.js b/server/tests/api/checkParams.js index 1f47e5ef4..b63091910 100644 --- a/server/tests/api/checkParams.js +++ b/server/tests/api/checkParams.js @@ -11,9 +11,9 @@ const utils = require('./utils') describe('Test parameters validator', function () { let server = null - function makePostRequest (path, token, fields, attach, done, fail) { + function makePostRequest (path, token, fields, attaches, done, fail) { let statusCode = 400 - if (fail !== undefined && fail === false) statusCode = 200 + if (fail !== undefined && fail === false) statusCode = 204 const req = request(server.url) .post(path) @@ -26,6 +26,11 @@ describe('Test parameters validator', function () { req.field(field, value) }) + Object.keys(attaches).forEach(function (attach) { + const value = attaches[attach] + req.attach(attach, value) + }) + req.expect(statusCode, done) } @@ -200,7 +205,18 @@ describe('Test parameters validator', function () { description: 'my super description' } const attach = { - 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short_fake.webm') + 'videofile': pathUtils.join(__dirname, 'fixtures', 'video_short_fake.webm') + } + makePostRequest(path, server.accessToken, data, attach, done) + }) + + it('Should fail with a too big duration', function (done) { + const data = { + name: 'my super name', + description: 'my super description' + } + const attach = { + 'videofile': pathUtils.join(__dirname, 'fixtures', 'video_too_long.webm') } makePostRequest(path, server.accessToken, data, attach, done) }) @@ -217,9 +233,9 @@ describe('Test parameters validator', function () { attach.videofile = pathUtils.join(__dirname, 'fixtures', 'video_short.mp4') makePostRequest(path, server.accessToken, data, attach, function () { attach.videofile = pathUtils.join(__dirname, 'fixtures', 'video_short.ogv') - makePostRequest(path, server.accessToken, data, attach, done, true) - }, true) - }, true) + makePostRequest(path, server.accessToken, data, attach, done, false) + }, false) + }, false) }) }) @@ -234,7 +250,7 @@ describe('Test parameters validator', function () { if (err) throw err expect(res.body).to.be.an('array') - expect(res.body.length).to.equal(0) + expect(res.body.length).to.equal(3) done() }) diff --git a/server/tests/api/fixtures/video_too_long.webm b/server/tests/api/fixtures/video_too_long.webm new file mode 100644 index 000000000..8286f74b0 Binary files /dev/null and b/server/tests/api/fixtures/video_too_long.webm differ -- cgit v1.2.3