From daeefc334f95c28a2b6992a3a5bb339b04d7ba55 Mon Sep 17 00:00:00 2001 From: Sam Machin Date: Fri, 24 Mar 2017 16:19:14 +0000 Subject: [PATCH 1/2] Update request.js make the API Key all lower case to work around bug on applications api --- src/request.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/request.js b/src/request.js index f20d9e2..fc05884 100644 --- a/src/request.js +++ b/src/request.js @@ -9,6 +9,7 @@ class Request { // Account accountSetup(key, secret, flags) { + key = key.toLowerCase(); this._verifyCredentials(key, secret, this.response.accountSetup(this.config, key, secret, flags).bind(this.response)); } From fef1e2d0b5ca364467fe647cc5471af6c2e0ba7f Mon Sep 17 00:00:00 2001 From: leggetter Date: Fri, 24 Mar 2017 19:37:03 +0000 Subject: [PATCH 2/2] Adding test for API key toLowerCase --- tests/request.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/request.js b/tests/request.js index c3b09df..50614e0 100644 --- a/tests/request.js +++ b/tests/request.js @@ -36,15 +36,24 @@ describe('Request', () => { }); describe('.accountSetup', () => { - it('should verifiy the credentials', sinon.test(function(){ + beforeEach(() => { nexmo = {}; nexmo.account = sinon.createStubInstance(Account); client.instanceWith.returns(nexmo); response.accountSetup.returns(()=>{}); + }); + + it('should verify the credentials', sinon.test(function(){ request.accountSetup('123', 'abc', false); expect(nexmo.account.checkBalance).to.have.been.called; expect(response.accountSetup).to.have.been.called; })); + + it('should convert API key to lower case', sinon.test(function(){ + request.accountSetup('ABC123', 'abc', false); + expect(nexmo.account.checkBalance).to.have.been.called; + expect(response.accountSetup).to.have.been.calledWith(config, 'abc123', 'abc', false); + })); }); describe('.accountInfo', () => {