From ca5bacefe6abada9fa49f2a3fc7a6467416b378a Mon Sep 17 00:00:00 2001 From: oscargrp Date: Fri, 18 Oct 2019 09:36:26 -0700 Subject: [PATCH 1/3] Add better code coverage in OAuthClient --- test/OAuthClientTest.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/OAuthClientTest.js b/test/OAuthClientTest.js index c89eaa53..4b908ae0 100644 --- a/test/OAuthClientTest.js +++ b/test/OAuthClientTest.js @@ -285,6 +285,20 @@ describe('Tests for OAuthClient', () => { .to.be.equal(JSON.stringify(expectedMakeAPICall)); }); }); + it('Make API Call in Sandbox Environment with headers as parameters', () => { + oauthClient.getToken().realmId = '12345'; + // eslint-disable-next-line no-useless-concat + return oauthClient.makeApiCall({ + url: 'https://sandbox-quickbooks.api.intuit.com/v3/company/' + '12345' + '/companyinfo/' + '12345', + headers: { + Accept: "application/json", + } + }) + .then((authResponse) => { + expect(JSON.stringify(authResponse.getJson())) + .to.be.equal(JSON.stringify(expectedMakeAPICall)); + }); + }); it('loadResponseFromJWKsURI', () => { const request = { url: 'https://sandbox-quickbooks.api.intuit.com/v3/company/12345/companyinfo/12345', @@ -474,6 +488,10 @@ describe('Generate OAuth1Sign', () => { const oauth1Sign = oauthClient.generateOauth1Sign(params); expect(oauth1Sign).to.be.a('String'); + expect(oauth1Sign).to.have.string('oauth_consumer_key="qyprdFsHNQtdRupMKmYnDt6MOjWBW9'); + expect(oauth1Sign).to.have.string('oauth_nonce="nonce'); + expect(oauth1Sign).to.have.string('oauth_version="1.0'); + expect(oauth1Sign).to.have.string('oauth_token', 'oauth_timestamp', 'oauth_signature'); }); }); From d5dd4f168f3fc74bfc7280c4d13bca8ca2f0a961 Mon Sep 17 00:00:00 2001 From: oscargrp Date: Fri, 18 Oct 2019 09:55:59 -0700 Subject: [PATCH 2/3] Add better code coverage in OAuthClient --- test/OAuthClientTest.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/OAuthClientTest.js b/test/OAuthClientTest.js index 4b908ae0..7a3032cb 100644 --- a/test/OAuthClientTest.js +++ b/test/OAuthClientTest.js @@ -407,6 +407,15 @@ describe('Validate Id Token ', () => { }); }); +describe('Get key from JWK URI', () => { + it('getKeyFromJWKsURI', () => { + oauthClient.getKeyFromJWKsURI() + .then((response) => { + expect(response).not.to.be.null; + }); + }); +}); + // Validate Refresh Token describe('Validate Refresh Token', () => { it('Validate should handle expired token', () => { From e4a1c2ff63dfb635746f0a2edb6a203650fd548a Mon Sep 17 00:00:00 2001 From: oscargrp Date: Fri, 18 Oct 2019 11:48:03 -0700 Subject: [PATCH 3/3] Add better code coverage in OAuthClient --- test/OAuthClientTest.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/test/OAuthClientTest.js b/test/OAuthClientTest.js index 7a3032cb..3b2ec659 100644 --- a/test/OAuthClientTest.js +++ b/test/OAuthClientTest.js @@ -262,7 +262,7 @@ describe('Tests for OAuthClient', () => { }); // make API Call - describe('Make API Call ', () => { + describe('Make API Call', () => { before(() => { nock('https://sandbox-quickbooks.api.intuit.com').persist() .get('/v3/company/12345/companyinfo/12345') @@ -407,15 +407,6 @@ describe('Validate Id Token ', () => { }); }); -describe('Get key from JWK URI', () => { - it('getKeyFromJWKsURI', () => { - oauthClient.getKeyFromJWKsURI() - .then((response) => { - expect(response).not.to.be.null; - }); - }); -}); - // Validate Refresh Token describe('Validate Refresh Token', () => { it('Validate should handle expired token', () => {