From d5f5a670fcf6258d0facf9a2fd3aabd550fbc78f Mon Sep 17 00:00:00 2001 From: Green-Star Date: Wed, 2 Aug 2017 21:50:42 +0200 Subject: Remove one pod (#76) * Client: Fix typo * Client: Add removeFriend feature * Server: Add removeFriend feature * Server: Update method name * Fix rebase onto develop issues * Server: Fix error message * Server: Remove useless methods in removeFriend method * Server: Finish remove on pod feature after rebase * Server: Type pod parameter * Fix Travis build * Add friend-basic test for the remove one pod feature * Add check-params tests for the remove one pod feature * Fix typos * Add friend-advanced test for the remove one pod feature * Client: Trailing new line * Move to promises * Add undefined id test * Use find method instead of a for loop to find the friend to remove * Remove setTimeout method * Server: Remove requestScheduler operations * Server: Fix logging messages * Server: Remove sign request parameter --- server/tests/api/check-params/pods.js | 52 ++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 4 deletions(-) (limited to 'server/tests/api/check-params') diff --git a/server/tests/api/check-params/pods.js b/server/tests/api/check-params/pods.js index 2567fff5f..35ea59093 100644 --- a/server/tests/api/check-params/pods.js +++ b/server/tests/api/check-params/pods.js @@ -17,7 +17,7 @@ describe('Test pods API validators', function () { // --------------------------------------------------------------- before(function (done) { - this.timeout(20000) + this.timeout(45000) series([ function (next) { @@ -110,7 +110,7 @@ describe('Test pods API validators', function () { .expect(400, done) }) - it('Should fail with a invalid token', function (done) { + it('Should fail with an invalid token', function (done) { request(server.url) .post(path + '/makefriends') .send(body) @@ -130,7 +130,7 @@ describe('Test pods API validators', function () { }) describe('When quitting friends', function () { - it('Should fail with a invalid token', function (done) { + it('Should fail with an invalid token', function (done) { request(server.url) .get(path + '/quitfriends') .query({ start: 'hello' }) @@ -148,6 +148,50 @@ describe('Test pods API validators', function () { .expect(403, done) }) }) + + describe('When removing one friend', function () { + it('Should fail with an invalid token', function (done) { + request(server.url) + .delete(path + '/1') + .set('Authorization', 'Bearer faketoken') + .set('Accept', 'application/json') + .expect(401, done) + }) + + it('Should fail if the user is not an administrator', function (done) { + request(server.url) + .delete(path + '/1') + .set('Authorization', 'Bearer ' + userAccessToken) + .set('Accept', 'application/json') + .expect(403, done) + }) + + it('Should fail with an undefined id', function (done) { + request(server.url) + .delete(path + '/' + undefined) + .set('Authorization', 'Bearer ' + server.accessToken) + .set('Accept', 'application/json') + .expect(400, done) + }) + + it('Should fail with an invalid id', function (done) { + request(server.url) + .delete(path + '/foobar') + .set('Authorization', 'Bearer ' + server.accessToken) + .set('Accept', 'application/json') + .expect(400, done) + }) + + it('Should fail if the pod is not a friend', function (done) { + request(server.url) + .delete(path + '/-1') + .set('Authorization', 'Bearer ' + server.accessToken) + .set('Accept', 'application/json') + .expect(404, done) + }) + + it('Should succeed with the correct parameters') + }) }) describe('When adding a pod', function () { @@ -181,7 +225,7 @@ describe('Test pods API validators', function () { requestsUtils.makePostBodyRequest(server.url, path, null, data, done) }) - it('Should fail without an host', function (done) { + it('Should fail without a host', function (done) { const data = { email: 'testexample.com', publicKey: 'mysuperpublickey' -- cgit v1.2.3