Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
merge with master
  • Loading branch information
abisalehalliprasan committed Oct 13, 2020
commit bf991206255cd497d87f2c48fdcf08e7d711dbd0
4 changes: 2 additions & 2 deletions sample/javascript/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const ngrok = process.env.NGROK_ENABLED === 'true' ? require('ngrok') : null;
/**
* Configure View and Handlebars
*/
app.use(bodyParser.urlencoded({extended: true}));
app.use(express.static(path.join(__dirname, '../public')));
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static(path.join(__dirname, '/public')));
app.engine('html', require('ejs').renderFile);

app.set('view engine', 'html');
Expand Down
85 changes: 13 additions & 72 deletions test/OAuthClientTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,21 @@ describe('Tests for OAuthClient', () => {
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',
return oauthClient
.makeApiCall({
url:
'https://sandbox-quickbooks.api.intuit.com/v3/company/' +
'12345' +
'/companyinfo/' +
'12345',
headers: {
Accept: "application/json",
}
Accept: 'application/json',
},
})
.then((authResponse) => {
expect(JSON.stringify(authResponse.getJson()))
.to.be.equal(JSON.stringify(expectedMakeAPICall));
expect(JSON.stringify(authResponse.getJson())).to.be.equal(
JSON.stringify(expectedMakeAPICall),
);
});
});
it('loadResponseFromJWKsURI', () => {
Expand Down Expand Up @@ -528,72 +534,7 @@ describe('Get Auth Header', () => {
});
});

// Generate OAuth1Sign

describe('Generate OAuth1Sign', () => {
it('Generate OAuth1Sign String', () => {
const params = {
method: 'POST',
uri: 'uri',
oauth_consumer_key: 'qyprdFsHNQtdRupMKmYnDt6MOjWBW9',
oauth_consumer_secret: 'TOI5I5dK94dkqDy9SlRD7s08uQUvtow6CK53SpJ1',
oauth_signature_method: 'HMAC-SHA1',
oauth_timestamp: 'timestamp',
oauth_nonce: 'nonce',
oauth_version: '1.0',
access_token: 'qyprdlGm45UFPPhwAM59Awaq4BAd6hNFwp1SSkZDn54Zrgv9',
access_secret: 'xPZ44ZvT17H56pkAAqhfyjuZlF5zZb2k9ej3ohko',
};

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');
});
});

// Migrate Tokens
describe('Migrate OAuth Tokens', () => {
describe('Sandbox', () => {
before(() => {
nock('https://developer.api.intuit.com').persist()
.post('/v2/oauth2/tokens/migrate')
.reply(200, expectedMigrationResponse, {
'content-type': 'application/json;charset=UTF-8',
'content-length': '264',
connection: 'close',
server: 'nginx',
'strict-transport-security': 'max-age=15552000',
intuit_tid: '1234-1234-1234-123',
'cache-control': 'no-cache, no-store',
pragma: 'no-cache',
});
});

it('Migrate OAuth Tokens - Sandbox', () => {
const timestamp = Math.round(new Date().getTime() / 1000);

const params = {
oauth_consumer_key: 'oauth_consumer_key',
oauth_consumer_secret: 'oauth_consumer_secret',
oauth_signature_method: 'HMAC-SHA1',
oauth_timestamp: timestamp,
oauth_nonce: 'nonce',
oauth_version: '1.0',
access_token: 'sample_access_token',
access_secret: 'sample_access_secret',
scope: ['com.intuit.quickbooks.accounting'],
};
oauthClient.migrate(params)
.then((response) => {
expect(response).to.be.equal(expectedMigrationResponse);
});
});
});
});

// Load Responses
describe('load responses', () => {
before(() => {
nock('https://sandbox-quickbooks.api.intuit.com')
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.