This repository has been archived by the owner on Jan 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refresh token & public web app auth support (#82)
* support for refresh token in oauth2 * fix for failing unit test * add tests for oauth2 public web apps * Fix failing tests and linting issues * fix code review concerns in test * fix failing tests * address code review concerns * address code review concerns * address code review concerns * address build failure issues * Removed optional assert message Removed optional assert message since it is not very clear in the context of the test description * Fixed GitHub vulnerabilities Fixed GitHub vulnerabilities using a yarn upgrade. Added package-lock.json to .gitignore in order to not push on remote a yarn.lock file and a package-lock.json * updated version
- Loading branch information
1 parent
972bfe1
commit 9dc8c4f
Showing
6 changed files
with
777 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ testing.js | |
coverage/ | ||
*.tgz | ||
npm-debug.log | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* Copyright (c) 2018, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
|
||
'use strict'; | ||
const assert = require('assert'); | ||
const FuelAuth = require('../lib/fuel-auth'); | ||
|
||
describe('Oauth2 Payload Tests', () => { | ||
it('auth payload should have public app attributes', () => { | ||
|
||
var options = { | ||
clientId:'client_id', | ||
authUrl:'test', | ||
authOptions:{ | ||
authVersion: 2, | ||
applicationType: 'public', | ||
redirectURI: 'test', | ||
authorizationCode: 'test' | ||
} | ||
}; | ||
|
||
var client = new FuelAuth(options); | ||
var payload = client.createPayloadForOauth2(); | ||
|
||
assert.equal(payload.client_id, options.clientId); | ||
assert.equal(payload.redirect_uri, options.authOptions.redirectURI); | ||
assert.equal(payload.code, options.authOptions.authorizationCode); | ||
assert.equal(payload.grant_type, 'authorization_code'); | ||
}); | ||
|
||
it('auth payload should have web app attributes', () => { | ||
|
||
var options = { | ||
clientId:'client_id', | ||
clientSecret: 'client_secret', | ||
authUrl:'test', | ||
authOptions:{ | ||
authVersion: 2, | ||
applicationType: 'web', | ||
redirectURI: 'test', | ||
authorizationCode: 'test' | ||
} | ||
}; | ||
|
||
var client = new FuelAuth(options); | ||
var payload = client.createPayloadForOauth2(); | ||
|
||
assert.equal(payload.client_id, options.clientId); | ||
assert.equal(payload.client_secret, options.clientSecret); | ||
assert.equal(payload.redirect_uri, options.authOptions.redirectURI); | ||
assert.equal(payload.code, options.authOptions.authorizationCode); | ||
assert.equal(payload.grant_type, 'authorization_code'); | ||
}); | ||
|
||
it('auth payload should have server app attributes', () => { | ||
|
||
var options = { | ||
clientId:'client_id', | ||
clientSecret: 'client_secret', | ||
authUrl:'test', | ||
authOptions:{ | ||
authVersion: 2 | ||
} | ||
}; | ||
|
||
var client = new FuelAuth(options); | ||
var payload = client.createPayloadForOauth2(); | ||
|
||
assert.equal(payload.client_id, options.clientId); | ||
assert.equal(payload.client_secret, options.clientSecret); | ||
assert.equal(payload.grant_type, 'client_credentials'); | ||
}); | ||
|
||
it('auth payload should have refresh token attributes', () => { | ||
|
||
var options = { | ||
clientId:'client_id', | ||
clientSecret: 'client_secret', | ||
authUrl:'test', | ||
authOptions:{ | ||
authVersion: 2 | ||
} | ||
}; | ||
|
||
var client = new FuelAuth(options); | ||
client.refreshToken = "test"; | ||
|
||
var payload = client.createPayloadForOauth2(); | ||
|
||
assert.equal(payload.client_id, options.clientId); | ||
assert.equal(payload.client_secret, options.clientSecret); | ||
assert.equal(payload.refresh_token, client.refreshToken); | ||
assert.equal(payload.grant_type, 'refresh_token'); | ||
}); | ||
|
||
}); |
Oops, something went wrong.