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)
const result = res.body
expect(result.length).to.equal(3)
for (const pod of result) {
- expect(pod.url).not.equal(servers[3].url)
+ expect(pod.host).not.equal(servers[3].host)
}
done()
const friends = []
for (let i = 0; i < servers.length; i++) {
if (servers[i].url === serverToTest.url) continue
- friends.push(servers[i].url)
+ friends.push(servers[i].host)
}
podsUtils.getFriendsList(serverToTest.url, function (err, res) {
expect(result).to.be.an('array')
expect(result.length).to.equal(2)
- const resultUrls = [ result[0].url, result[1].url ]
- expect(resultUrls[0]).to.not.equal(resultUrls[1])
+ const resultHosts = [ result[0].host, result[1].host ]
+ expect(resultHosts[0]).to.not.equal(resultHosts[1])
- const errorString = 'Friends url do not correspond for ' + serverToTest.url
- expect(friends).to.contain(resultUrls[0], errorString)
- expect(friends).to.contain(resultUrls[1], errorString)
+ const errorString = 'Friends host do not correspond for ' + serverToTest.host
+ expect(friends).to.contain(resultHosts[0], errorString)
+ expect(friends).to.contain(resultHosts[1], errorString)
callback()
})
}
expect(result.length).to.equal(1)
const pod = result[0]
- expect(pod.url).to.equal(servers[2].url)
+ expect(pod.host).to.equal(servers[2].host)
expect(pod.score).to.equal(20)
expect(miscsUtils.dateIsValid(pod.createdDate)).to.be.true
expect(result.length).to.equal(1)
const pod = result[0]
- expect(pod.url).to.equal(servers[1].url)
+ expect(pod.host).to.equal(servers[1].host)
expect(pod.score).to.equal(20)
expect(miscsUtils.dateIsValid(pod.createdDate)).to.be.true
const result = res.body
expect(result).to.be.an('array')
expect(result.length).to.equal(1)
- expect(result[0].url).not.to.be.equal(servers[1].url)
+ expect(result[0].host).not.to.be.equal(servers[1].host)
callback()
})
}, next)
const video = videos[0]
expect(video.name).to.equal('my super name for pod 1')
expect(video.description).to.equal('my super description for pod 1')
- expect(video.podUrl).to.equal('localhost:9001')
+ expect(video.podHost).to.equal('localhost:9001')
expect(video.magnetUri).to.exist
expect(video.duration).to.equal(10)
expect(video.tags).to.deep.equal([ 'tag1p1', 'tag2p1' ])
const video = videos[1]
expect(video.name).to.equal('my super name for pod 2')
expect(video.description).to.equal('my super description for pod 2')
- expect(video.podUrl).to.equal('localhost:9002')
+ expect(video.podHost).to.equal('localhost:9002')
expect(video.magnetUri).to.exist
expect(video.duration).to.equal(5)
expect(video.tags).to.deep.equal([ 'tag1p2', 'tag2p2', 'tag3p2' ])
expect(video1.name).to.equal('my super name for pod 3')
expect(video1.description).to.equal('my super description for pod 3')
- expect(video1.podUrl).to.equal('localhost:9003')
+ expect(video1.podHost).to.equal('localhost:9003')
expect(video1.magnetUri).to.exist
expect(video1.duration).to.equal(5)
expect(video1.tags).to.deep.equal([ 'tag1p3' ])
expect(video2.name).to.equal('my super name for pod 3-2')
expect(video2.description).to.equal('my super description for pod 3-2')
- expect(video2.podUrl).to.equal('localhost:9003')
+ expect(video2.podHost).to.equal('localhost:9003')
expect(video2.magnetUri).to.exist
expect(video2.duration).to.equal(5)
expect(video2.tags).to.deep.equal([ 'tag2p3', 'tag3p3', 'tag4p3' ])
const video = res.body.data[0]
expect(video.name).to.equal('my super name')
expect(video.description).to.equal('my super description')
- expect(video.podUrl).to.equal('localhost:9001')
+ expect(video.podHost).to.equal('localhost:9001')
expect(video.magnetUri).to.exist
expect(video.author).to.equal('root')
expect(video.isLocal).to.be.true
const video = res.body
expect(video.name).to.equal('my super name')
expect(video.description).to.equal('my super description')
- expect(video.podUrl).to.equal('localhost:9001')
+ expect(video.podHost).to.equal('localhost:9001')
expect(video.magnetUri).to.exist
expect(video.author).to.equal('root')
expect(video.isLocal).to.be.true
const video = res.body.data[0]
expect(video.name).to.equal('my super name')
expect(video.description).to.equal('my super description')
- expect(video.podUrl).to.equal('localhost:9001')
+ expect(video.podHost).to.equal('localhost:9001')
expect(video.author).to.equal('root')
expect(video.isLocal).to.be.true
expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
})
})
- it('Should search the video by podUrl', function (done) {
- videosUtils.searchVideo(server.url, '9001', 'podUrl', function (err, res) {
+ it('Should search the video by podHost', function (done) {
+ videosUtils.searchVideo(server.url, '9001', 'podHost', function (err, res) {
if (err) throw err
expect(res.body.total).to.equal(1)
const video = res.body.data[0]
expect(video.name).to.equal('my super name')
expect(video.description).to.equal('my super description')
- expect(video.podUrl).to.equal('localhost:9001')
+ expect(video.podHost).to.equal('localhost:9001')
expect(video.author).to.equal('root')
expect(video.isLocal).to.be.true
expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
const video = res.body.data[0]
expect(video.name).to.equal('my super name')
expect(video.description).to.equal('my super description')
- expect(video.podUrl).to.equal('localhost:9001')
+ expect(video.podHost).to.equal('localhost:9001')
expect(video.author).to.equal('root')
expect(video.isLocal).to.be.true
expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
})
it('Should search all the 9001 port videos', function (done) {
- videosUtils.searchVideoWithPagination(server.url, '9001', 'podUrl', 0, 15, function (err, res) {
+ videosUtils.searchVideoWithPagination(server.url, '9001', 'podHost', 0, 15, function (err, res) {
if (err) throw err
const videos = res.body.data
})
it('Should search all the localhost videos', function (done) {
- videosUtils.searchVideoWithPagination(server.url, 'localhost', 'podUrl', 0, 15, function (err, res) {
+ videosUtils.searchVideoWithPagination(server.url, 'localhost', 'podHost', 0, 15, function (err, res) {
if (err) throw err
const videos = res.body.data
// Which pod makes friends with which pod
const friendsMatrix = {
'http://localhost:9001': [
- 'http://localhost:9002'
+ 'localhost:9002'
],
'http://localhost:9002': [
- 'http://localhost:9003'
+ 'localhost:9003'
],
'http://localhost:9003': [
- 'http://localhost:9001'
+ 'localhost:9001'
],
'http://localhost:9004': [
- 'http://localhost:9002'
+ 'localhost:9002'
],
'http://localhost:9005': [
- 'http://localhost:9001',
- 'http://localhost:9004'
+ 'localhost:9001',
+ 'localhost:9004'
],
'http://localhost:9006': [
- 'http://localhost:9001',
- 'http://localhost:9002',
- 'http://localhost:9003'
+ 'localhost:9001',
+ 'localhost:9002',
+ 'localhost:9003'
]
}
const path = '/api/v1/pods/makefriends'
.post(path)
.set('Accept', 'application/json')
.set('Authorization', 'Bearer ' + accessToken)
- .send({ 'urls': friendsMatrix[url] })
+ .send({ 'hosts': friendsMatrix[url] })
.expect(expectedStatus)
.end(function (err, res) {
if (err) throw err
const server = {
app: null,
url: `http://localhost:${9000 + number}`,
+ host: `localhost:${9000 + number}`,
client: {
id: null,
secret: null