]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/check-params/pods.ts
Add pod list endpoint with pagination, sort...
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params / pods.ts
index 27c080931b958d4cb10412f9be5ec5ba2296f959..9f9c2e4f0eca1da10f1d06a09e10e41c1c41f6f5 100644 (file)
@@ -15,7 +15,6 @@ import {
 } from '../../utils'
 
 describe('Test pods API validators', function () {
-  const path = '/api/v1/pods/'
   let server: ServerInfo
 
   // ---------------------------------------------------------------
@@ -30,6 +29,7 @@ describe('Test pods API validators', function () {
   })
 
   describe('When managing friends', function () {
+    const path = '/api/v1/pods/'
     let userAccessToken = null
 
     before(async function () {
@@ -49,7 +49,7 @@ describe('Test pods API validators', function () {
 
       it('Should fail without hosts', async function () {
         await request(server.url)
-                .post(path + '/makefriends')
+                .post(path + '/make-friends')
                 .set('Authorization', 'Bearer ' + server.accessToken)
                 .set('Accept', 'application/json')
                 .expect(400)
@@ -57,7 +57,7 @@ describe('Test pods API validators', function () {
 
       it('Should fail if hosts is not an array', async function () {
         await request(server.url)
-                .post(path + '/makefriends')
+                .post(path + '/make-friends')
                 .send({ hosts: 'localhost:9002' })
                 .set('Authorization', 'Bearer ' + server.accessToken)
                 .set('Accept', 'application/json')
@@ -66,7 +66,7 @@ describe('Test pods API validators', function () {
 
       it('Should fail if the array is not composed by hosts', async function () {
         await request(server.url)
-                .post(path + '/makefriends')
+                .post(path + '/make-friends')
                 .send({ hosts: [ 'localhost:9002', 'localhost:coucou' ] })
                 .set('Authorization', 'Bearer ' + server.accessToken)
                 .set('Accept', 'application/json')
@@ -75,7 +75,7 @@ describe('Test pods API validators', function () {
 
       it('Should fail if the array is composed with http schemes', async function () {
         await request(server.url)
-                .post(path + '/makefriends')
+                .post(path + '/make-friends')
                 .send({ hosts: [ 'localhost:9002', 'http://localhost:9003' ] })
                 .set('Authorization', 'Bearer ' + server.accessToken)
                 .set('Accept', 'application/json')
@@ -84,7 +84,7 @@ describe('Test pods API validators', function () {
 
       it('Should fail if hosts are not unique', async function () {
         await request(server.url)
-                .post(path + '/makefriends')
+                .post(path + '/make-friends')
                 .send({ urls: [ 'localhost:9002', 'localhost:9002' ] })
                 .set('Authorization', 'Bearer ' + server.accessToken)
                 .set('Accept', 'application/json')
@@ -93,16 +93,16 @@ describe('Test pods API validators', function () {
 
       it('Should fail with an invalid token', async function () {
         await request(server.url)
-                .post(path + '/makefriends')
+                .post(path + '/make-friends')
                 .send(body)
-                .set('Authorization', 'Bearer faketoken')
+                .set('Authorization', 'Bearer fake_token')
                 .set('Accept', 'application/json')
                 .expect(401)
       })
 
       it('Should fail if the user is not an administrator', async function () {
         await request(server.url)
-                .post(path + '/makefriends')
+                .post(path + '/make-friends')
                 .send(body)
                 .set('Authorization', 'Bearer ' + userAccessToken)
                 .set('Accept', 'application/json')
@@ -110,10 +110,36 @@ describe('Test pods API validators', function () {
       })
     })
 
+    describe('When listing friends', function () {
+      it('Should fail with a bad start pagination', async function () {
+        await request(server.url)
+          .get(path)
+          .query({ start: 'hello' })
+          .set('Accept', 'application/json')
+          .expect(400)
+      })
+
+      it('Should fail with a bad count pagination', async function () {
+        await request(server.url)
+          .get(path)
+          .query({ count: 'hello' })
+          .set('Accept', 'application/json')
+          .expect(400)
+      })
+
+      it('Should fail with an incorrect sort', async function () {
+        await request(server.url)
+          .get(path)
+          .query({ sort: 'hello' })
+          .set('Accept', 'application/json')
+          .expect(400)
+      })
+    })
+
     describe('When quitting friends', function () {
       it('Should fail with an invalid token', async function () {
         await request(server.url)
-                .get(path + '/quitfriends')
+                .get(path + '/quit-friends')
                 .query({ start: 'hello' })
                 .set('Authorization', 'Bearer faketoken')
                 .set('Accept', 'application/json')
@@ -122,7 +148,7 @@ describe('Test pods API validators', function () {
 
       it('Should fail if the user is not an administrator', async function () {
         await request(server.url)
-                .get(path + '/quitfriends')
+                .get(path + '/quit-friends')
                 .query({ start: 'hello' })
                 .set('Authorization', 'Bearer ' + userAccessToken)
                 .set('Accept', 'application/json')
@@ -175,7 +201,9 @@ describe('Test pods API validators', function () {
     })
   })
 
-  describe('When adding a pod', function () {
+  describe('When adding a pod from remote', function () {
+    const path = '/api/v1/remote/pods/add'
+
     it('Should fail with nothing', async function () {
       const fields = {}
       await makePostBodyRequest({ url: server.url, path, fields })