X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fcheck-params.js;h=ec666417c2a9c67bf29a59145d3dc4deb5b62945;hb=1e2564d3927ce4ca4ca9a09930da6da7ebb4e9a1;hp=fc8b0a42a93e30130f774221c3e551cfe213fd92;hpb=e861452fb26553177ad4e32bfb18b4fd8a5b1816;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/check-params.js b/server/tests/api/check-params.js index fc8b0a42a..ec666417c 100644 --- a/server/tests/api/check-params.js +++ b/server/tests/api/check-params.js @@ -108,10 +108,40 @@ describe('Test parameters validator', function () { }) describe('When making friends', function () { + const body = { + urls: [ 'http://localhost:9002' ] + } + + it('Should fail without urls', function (done) { + request(server.url) + .post(path + '/makefriends') + .set('Authorization', 'Bearer faketoken') + .set('Accept', 'application/json') + .expect(401, done) + }) + + it('Should fail with urls is not an array', function (done) { + request(server.url) + .post(path + '/makefriends') + .send({ urls: 'http://localhost:9002' }) + .set('Authorization', 'Bearer faketoken') + .set('Accept', 'application/json') + .expect(401, done) + }) + + it('Should fail if the array is not composed by urls', function (done) { + request(server.url) + .post(path + '/makefriends') + .send({ urls: [ 'http://localhost:9002', 'localhost:coucou' ] }) + .set('Authorization', 'Bearer faketoken') + .set('Accept', 'application/json') + .expect(401, done) + }) + it('Should fail with a invalid token', function (done) { request(server.url) - .get(path + '/makefriends') - .query({ start: 'hello' }) + .post(path + '/makefriends') + .send(body) .set('Authorization', 'Bearer faketoken') .set('Accept', 'application/json') .expect(401, done) @@ -119,8 +149,8 @@ describe('Test parameters validator', function () { it('Should fail if the user is not an administrator', function (done) { request(server.url) - .get(path + '/makefriends') - .query({ start: 'hello' }) + .post(path + '/makefriends') + .send(body) .set('Authorization', 'Bearer ' + userAccessToken) .set('Accept', 'application/json') .expect(403, done)