describe('When making friends', function () {
const body = {
- urls: [ 'http://localhost:9002' ]
+ hosts: [ 'localhost:9002' ]
}
- it('Should fail without urls', function (done) {
+ it('Should fail without hosts', function (done) {
request(server.url)
.post(path + '/makefriends')
.set('Authorization', 'Bearer ' + server.accessToken)
.expect(400, done)
})
- it('Should fail with urls is not an array', function (done) {
+ it('Should fail if hosts is not an array', function (done) {
request(server.url)
.post(path + '/makefriends')
- .send({ urls: 'http://localhost:9002' })
+ .send({ hosts: 'localhost:9002' })
.set('Authorization', 'Bearer ' + server.accessToken)
.set('Accept', 'application/json')
.expect(400, done)
})
- it('Should fail if the array is not composed by urls', function (done) {
+ it('Should fail if the array is not composed by hosts', function (done) {
request(server.url)
.post(path + '/makefriends')
- .send({ urls: [ 'http://localhost:9002', 'localhost:coucou' ] })
+ .send({ hosts: [ 'localhost:9002', 'localhost:coucou' ] })
.set('Authorization', 'Bearer ' + server.accessToken)
.set('Accept', 'application/json')
.expect(400, done)
})
- it('Should fail if urls are not unique', function (done) {
+ it('Should fail if the array is composed with http schemes', function (done) {
request(server.url)
.post(path + '/makefriends')
- .send({ urls: [ 'http://localhost:9002', 'http://localhost:9002' ] })
+ .send({ hosts: [ 'localhost:9002', 'http://localhost:9003' ] })
+ .set('Authorization', 'Bearer ' + server.accessToken)
+ .set('Accept', 'application/json')
+ .expect(400, done)
+ })
+
+ it('Should fail if hosts are not unique', function (done) {
+ request(server.url)
+ .post(path + '/makefriends')
+ .send({ urls: [ 'localhost:9002', 'localhost:9002' ] })
.set('Authorization', 'Bearer ' + server.accessToken)
.set('Accept', 'application/json')
.expect(400, done)
it('Should fail without public key', function (done) {
const data = {
- url: 'http://coucou.com'
+ host: 'coucou.com'
}
requestsUtils.makePostBodyRequest(server.url, path, null, data, done)
})
- it('Should fail without an url', function (done) {
+ it('Should fail without an host', function (done) {
const data = {
publicKey: 'mysuperpublickey'
}
requestsUtils.makePostBodyRequest(server.url, path, null, data, done)
})
- it('Should fail with an incorrect url', function (done) {
+ it('Should fail with an incorrect host', function (done) {
const data = {
- url: 'coucou.com',
+ host: 'http://coucou.com',
publicKey: 'mysuperpublickey'
}
requestsUtils.makePostBodyRequest(server.url, path, null, data, function () {
- data.url = 'http://coucou'
+ data.host = 'http://coucou'
requestsUtils.makePostBodyRequest(server.url, path, null, data, function () {
- data.url = 'coucou'
+ data.host = 'coucou'
requestsUtils.makePostBodyRequest(server.url, path, null, data, done)
})
})
it('Should succeed with the correct parameters', function (done) {
const data = {
- url: 'http://coucou.com',
+ host: 'coucou.com',
publicKey: 'mysuperpublickey'
}
requestsUtils.makePostBodyRequest(server.url, path, null, data, done, 200)
it('Should return 404 with an incorrect video', function (done) {
request(server.url)
- .get(path + '123456789012345678901234')
+ .get(path + '4da6fde3-88f7-4d16-b119-108df5630b06')
.set('Accept', 'application/json')
.expect(404, done)
})
it('Should fail with a video which does not exist', function (done) {
request(server.url)
- .delete(path + '123456789012345678901234')
+ .delete(path + '4da6fde3-88f7-4d16-b119-108df5630b06')
.set('Authorization', 'Bearer ' + server.accessToken)
.expect(404, done)
})
describe('Of the users API', function () {
const path = '/api/v1/users/'
let userId = null
+ let rootId = null
describe('When listing users', function () {
it('Should fail with a bad start pagination', function (done) {
if (err) throw err
userId = res.body.data[1].id
+ rootId = res.body.data[2].id
done()
})
})
.expect(400, done)
})
+ it('Should fail with the root user', function (done) {
+ request(server.url)
+ .delete(path + rootId)
+ .set('Authorization', 'Bearer ' + server.accessToken)
+ .expect(400, done)
+ })
+
it('Should return 404 with a non existing id', function (done) {
request(server.url)
- .delete(path + '579f982228c99c221d8092b8')
+ .delete(path + '45')
.set('Authorization', 'Bearer ' + server.accessToken)
.expect(404, done)
})