const podsUtils = {
getFriendsList,
makeFriends,
- quitFriends
+ quitFriends,
+ quitOneFriend
}
// ---------------------- Export functions --------------------
// 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
})
}
+function quitOneFriend (url, accessToken, friendId, expectedStatus, end) {
+ if (!end) {
+ end = expectedStatus
+ expectedStatus = 204
+ }
+
+ const path = '/api/v1/pods/' + friendId
+
+ request(url)
+ .delete(path)
+ .set('Accept', 'application/json')
+ .set('Authorization', 'Bearer ' + accessToken)
+ .expect(expectedStatus)
+ .end(function (err, res) {
+ if (err) throw err
+
+ end()
+ })
+}
+
// ---------------------------------------------------------------------------
module.exports = podsUtils