} from '../../utils'
describe('Test pods API validators', function () {
- const path = '/api/v1/pods/'
let server: ServerInfo
// ---------------------------------------------------------------
})
describe('When managing friends', function () {
+ const path = '/api/v1/pods/'
let userAccessToken = null
before(async 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)
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')
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')
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')
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')
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')
})
})
+ 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')
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')
})
})
- 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 })