From f532c2fd705fbbded51950b3fc79c522970fd7de Mon Sep 17 00:00:00 2001 From: Mike Stone Date: Thu, 5 Jan 2017 19:13:28 -0500 Subject: [PATCH] Fixes bug for undefined ID when revoking invites (#771) --- frontend/kolide/index.js | 4 ++-- frontend/kolide/index.tests.js | 6 +++--- frontend/test/mocks.js | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/frontend/kolide/index.js b/frontend/kolide/index.js index e1bcea33e1..015a312c4f 100644 --- a/frontend/kolide/index.js +++ b/frontend/kolide/index.js @@ -310,9 +310,9 @@ class Kolide extends Base { return Base.post(resetPasswordEndpoint, JSON.stringify(formData)); } - revokeInvite = ({ entityID }) => { + revokeInvite = ({ id }) => { const { INVITES } = endpoints; - const endpoint = `${this.endpoint(INVITES)}/${entityID}`; + const endpoint = `${this.endpoint(INVITES)}/${id}`; return this.authenticatedDelete(endpoint); } diff --git a/frontend/kolide/index.tests.js b/frontend/kolide/index.tests.js index 7ae40602f5..8eea91ff77 100644 --- a/frontend/kolide/index.tests.js +++ b/frontend/kolide/index.tests.js @@ -4,6 +4,7 @@ import nock from 'nock'; import Kolide from 'kolide'; import helpers from 'kolide/helpers'; import mocks from 'test/mocks'; +import { userStub } from 'test/stubs'; const { invalidForgotPasswordRequest, @@ -443,11 +444,10 @@ describe('Kolide - API client', () => { describe('#revokeInvite', () => { it('calls the appropriate endpoint with the correct parameters', (done) => { const bearerToken = 'valid-bearer-token'; - const entityID = 1; - const request = validRevokeInviteRequest(bearerToken, entityID); + const request = validRevokeInviteRequest(bearerToken, userStub); Kolide.setBearerToken(bearerToken); - Kolide.revokeInvite({ entityID }) + Kolide.revokeInvite(userStub) .then(() => { expect(request.isDone()).toEqual(true); done(); diff --git a/frontend/test/mocks.js b/frontend/test/mocks.js index 51304a7077..8a23b622ac 100644 --- a/frontend/test/mocks.js +++ b/frontend/test/mocks.js @@ -276,13 +276,13 @@ export const validResetPasswordRequest = (password, token) => { .reply(200, validUser); }; -export const validRevokeInviteRequest = (bearerToken, inviteID) => { +export const validRevokeInviteRequest = (bearerToken, invite) => { return nock('http://localhost:8080', { reqheaders: { Authorization: `Bearer ${bearerToken}`, }, }) - .delete(`/api/v1/kolide/invites/${inviteID}`) + .delete(`/api/v1/kolide/invites/${invite.id}`) .reply(200, {}); };