urls: makefriends/quitfriends -> make-friends/quit-friends
This commit is contained in:
parent
337c258e77
commit
aa2e7f1501
|
@ -26,13 +26,13 @@ export class FriendService {
|
||||||
hosts: notEmptyHosts
|
hosts: notEmptyHosts
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.authHttp.post(FriendService.BASE_FRIEND_URL + 'makefriends', body)
|
return this.authHttp.post(FriendService.BASE_FRIEND_URL + 'make-friends', body)
|
||||||
.map(this.restExtractor.extractDataBool)
|
.map(this.restExtractor.extractDataBool)
|
||||||
.catch((res) => this.restExtractor.handleError(res))
|
.catch((res) => this.restExtractor.handleError(res))
|
||||||
}
|
}
|
||||||
|
|
||||||
quitFriends () {
|
quitFriends () {
|
||||||
return this.authHttp.get(FriendService.BASE_FRIEND_URL + 'quitfriends')
|
return this.authHttp.get(FriendService.BASE_FRIEND_URL + 'quit-friends')
|
||||||
.map(res => res.status)
|
.map(res => res.status)
|
||||||
.catch((res) => this.restExtractor.handleError(res))
|
.catch((res) => this.restExtractor.handleError(res))
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,14 +35,14 @@ podsRouter.post('/',
|
||||||
podsAddValidator,
|
podsAddValidator,
|
||||||
addPods
|
addPods
|
||||||
)
|
)
|
||||||
podsRouter.post('/makefriends',
|
podsRouter.post('/make-friends',
|
||||||
authenticate,
|
authenticate,
|
||||||
ensureIsAdmin,
|
ensureIsAdmin,
|
||||||
makeFriendsValidator,
|
makeFriendsValidator,
|
||||||
setBodyHostsPort,
|
setBodyHostsPort,
|
||||||
makeFriendsController
|
makeFriendsController
|
||||||
)
|
)
|
||||||
podsRouter.get('/quitfriends',
|
podsRouter.get('/quit-friends',
|
||||||
authenticate,
|
authenticate,
|
||||||
ensureIsAdmin,
|
ensureIsAdmin,
|
||||||
quitFriendsController
|
quitFriendsController
|
||||||
|
|
|
@ -49,7 +49,7 @@ describe('Test pods API validators', function () {
|
||||||
|
|
||||||
it('Should fail without hosts', async function () {
|
it('Should fail without hosts', async function () {
|
||||||
await request(server.url)
|
await request(server.url)
|
||||||
.post(path + '/makefriends')
|
.post(path + '/make-friends')
|
||||||
.set('Authorization', 'Bearer ' + server.accessToken)
|
.set('Authorization', 'Bearer ' + server.accessToken)
|
||||||
.set('Accept', 'application/json')
|
.set('Accept', 'application/json')
|
||||||
.expect(400)
|
.expect(400)
|
||||||
|
@ -57,7 +57,7 @@ describe('Test pods API validators', function () {
|
||||||
|
|
||||||
it('Should fail if hosts is not an array', async function () {
|
it('Should fail if hosts is not an array', async function () {
|
||||||
await request(server.url)
|
await request(server.url)
|
||||||
.post(path + '/makefriends')
|
.post(path + '/make-friends')
|
||||||
.send({ hosts: 'localhost:9002' })
|
.send({ hosts: 'localhost:9002' })
|
||||||
.set('Authorization', 'Bearer ' + server.accessToken)
|
.set('Authorization', 'Bearer ' + server.accessToken)
|
||||||
.set('Accept', 'application/json')
|
.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 () {
|
it('Should fail if the array is not composed by hosts', async function () {
|
||||||
await request(server.url)
|
await request(server.url)
|
||||||
.post(path + '/makefriends')
|
.post(path + '/make-friends')
|
||||||
.send({ hosts: [ 'localhost:9002', 'localhost:coucou' ] })
|
.send({ hosts: [ 'localhost:9002', 'localhost:coucou' ] })
|
||||||
.set('Authorization', 'Bearer ' + server.accessToken)
|
.set('Authorization', 'Bearer ' + server.accessToken)
|
||||||
.set('Accept', 'application/json')
|
.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 () {
|
it('Should fail if the array is composed with http schemes', async function () {
|
||||||
await request(server.url)
|
await request(server.url)
|
||||||
.post(path + '/makefriends')
|
.post(path + '/make-friends')
|
||||||
.send({ hosts: [ 'localhost:9002', 'http://localhost:9003' ] })
|
.send({ hosts: [ 'localhost:9002', 'http://localhost:9003' ] })
|
||||||
.set('Authorization', 'Bearer ' + server.accessToken)
|
.set('Authorization', 'Bearer ' + server.accessToken)
|
||||||
.set('Accept', 'application/json')
|
.set('Accept', 'application/json')
|
||||||
|
@ -84,7 +84,7 @@ describe('Test pods API validators', function () {
|
||||||
|
|
||||||
it('Should fail if hosts are not unique', async function () {
|
it('Should fail if hosts are not unique', async function () {
|
||||||
await request(server.url)
|
await request(server.url)
|
||||||
.post(path + '/makefriends')
|
.post(path + '/make-friends')
|
||||||
.send({ urls: [ 'localhost:9002', 'localhost:9002' ] })
|
.send({ urls: [ 'localhost:9002', 'localhost:9002' ] })
|
||||||
.set('Authorization', 'Bearer ' + server.accessToken)
|
.set('Authorization', 'Bearer ' + server.accessToken)
|
||||||
.set('Accept', 'application/json')
|
.set('Accept', 'application/json')
|
||||||
|
@ -93,16 +93,16 @@ describe('Test pods API validators', function () {
|
||||||
|
|
||||||
it('Should fail with an invalid token', async function () {
|
it('Should fail with an invalid token', async function () {
|
||||||
await request(server.url)
|
await request(server.url)
|
||||||
.post(path + '/makefriends')
|
.post(path + '/make-friends')
|
||||||
.send(body)
|
.send(body)
|
||||||
.set('Authorization', 'Bearer faketoken')
|
.set('Authorization', 'Bearer fake_token')
|
||||||
.set('Accept', 'application/json')
|
.set('Accept', 'application/json')
|
||||||
.expect(401)
|
.expect(401)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should fail if the user is not an administrator', async function () {
|
it('Should fail if the user is not an administrator', async function () {
|
||||||
await request(server.url)
|
await request(server.url)
|
||||||
.post(path + '/makefriends')
|
.post(path + '/make-friends')
|
||||||
.send(body)
|
.send(body)
|
||||||
.set('Authorization', 'Bearer ' + userAccessToken)
|
.set('Authorization', 'Bearer ' + userAccessToken)
|
||||||
.set('Accept', 'application/json')
|
.set('Accept', 'application/json')
|
||||||
|
@ -113,7 +113,7 @@ describe('Test pods API validators', function () {
|
||||||
describe('When quitting friends', function () {
|
describe('When quitting friends', function () {
|
||||||
it('Should fail with an invalid token', async function () {
|
it('Should fail with an invalid token', async function () {
|
||||||
await request(server.url)
|
await request(server.url)
|
||||||
.get(path + '/quitfriends')
|
.get(path + '/quit-friends')
|
||||||
.query({ start: 'hello' })
|
.query({ start: 'hello' })
|
||||||
.set('Authorization', 'Bearer faketoken')
|
.set('Authorization', 'Bearer faketoken')
|
||||||
.set('Accept', 'application/json')
|
.set('Accept', 'application/json')
|
||||||
|
@ -122,7 +122,7 @@ describe('Test pods API validators', function () {
|
||||||
|
|
||||||
it('Should fail if the user is not an administrator', async function () {
|
it('Should fail if the user is not an administrator', async function () {
|
||||||
await request(server.url)
|
await request(server.url)
|
||||||
.get(path + '/quitfriends')
|
.get(path + '/quit-friends')
|
||||||
.query({ start: 'hello' })
|
.query({ start: 'hello' })
|
||||||
.set('Authorization', 'Bearer ' + userAccessToken)
|
.set('Authorization', 'Bearer ' + userAccessToken)
|
||||||
.set('Accept', 'application/json')
|
.set('Accept', 'application/json')
|
||||||
|
|
|
@ -37,7 +37,7 @@ async function makeFriends (url: string, accessToken: string, expectedStatus = 2
|
||||||
'localhost:9003'
|
'localhost:9003'
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
const path = '/api/v1/pods/makefriends'
|
const path = '/api/v1/pods/make-friends'
|
||||||
|
|
||||||
// The first pod make friend with the third
|
// The first pod make friend with the third
|
||||||
const res = await request(url)
|
const res = await request(url)
|
||||||
|
@ -54,7 +54,7 @@ async function makeFriends (url: string, accessToken: string, expectedStatus = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
async function quitFriends (url: string, accessToken: string, expectedStatus = 204) {
|
async function quitFriends (url: string, accessToken: string, expectedStatus = 204) {
|
||||||
const path = '/api/v1/pods/quitfriends'
|
const path = '/api/v1/pods/quit-friends'
|
||||||
|
|
||||||
// The first pod make friend with the third
|
// The first pod make friend with the third
|
||||||
const res = await request(url)
|
const res = await request(url)
|
||||||
|
|
Loading…
Reference in New Issue