]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/check-params.js
Server: make friends urls come from the request instead of the
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params.js
index fc8b0a42a93e30130f774221c3e551cfe213fd92..ec666417c2a9c67bf29a59145d3dc4deb5b62945 100644 (file)
@@ -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)