Skip to content

Commit

Permalink
fix(getAuthUrl): Revert getAuthUrl testMode change.
Browse files Browse the repository at this point in the history
This reverts commit 9ca100d.
  • Loading branch information
Emre Sonmez authored and gurpreetatwal committed Oct 5, 2018
1 parent 9ca100d commit 9d3648c
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 70 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ Session.vim
[._]s[a-w][a-z]
[._]*.]s[a-w][a-z]]

## Webstorm
.idea

## Sublime
*.tmlanguage.cache
*.tmPreferences.cache
Expand Down
10 changes: 1 addition & 9 deletions lib/auth-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ function AuthClient(options) {
* `true` will show the permissions approval screen on every authentication
* attempt, even if the user has previously consented to the exact scope of
* permissions.
* @param {Boolean} [options.testMode=false] - Launch the Smartcar auth flow in
* test mode.
* @return {String} OAuth authorization URL to direct user to.
* @example
* https://connect.smartcar.com/oauth/authorize?
Expand Down Expand Up @@ -148,17 +146,11 @@ AuthClient.prototype.getAuthUrl = function(options) {
}

let mode;
if (options.testMode !== undefined) {
// Override mode with testMode option.
mode = options.testMode;
} else if (this.development !== undefined) {
// Use deprecated 'development' flag.
if (this.development !== undefined) {
mode = this.development;
} else {
// Use 'testMode' flag.
mode = this.testMode;
}

parameters.mode = mode ? 'test' : 'live';

const query = qs.stringify(parameters);
Expand Down
58 changes: 0 additions & 58 deletions test/unit/lib/auth-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,64 +212,6 @@ test('getAuthUrl - test mode false', function(t) {

});

test('getAuthUrl - test mode overrides constructor testMode value - true', function(t) {

const client = new AuthClient({
clientId: CLIENT_ID,
clientSecret: CLIENT_SECRET,
redirectUri: 'https://insurance.co/callback',
scope: ['read_odometer', 'read_vehicle_info'],
testMode: true,
});

const actual = client.getAuthUrl({
scope: 'this should be ignored',
state: 'fakestate',
forcePrompt: true,
testMode: false,
});

let expected = 'https://connect.smartcar.com/oauth/authorize?';
expected += `response_type=code&client_id=${CLIENT_ID}`;
expected += '&redirect_uri=https%3A%2F%2Finsurance.co%2Fcallback';
expected += '&approval_prompt=force';
expected += '&scope=read_odometer%20read_vehicle_info';
expected += '&state=fakestate';
expected += '&mode=live';

t.is(actual, expected);

});

test('getAuthUrl - test mode overrides constructor testMode value - false', function(t) {

const client = new AuthClient({
clientId: CLIENT_ID,
clientSecret: CLIENT_SECRET,
redirectUri: 'https://insurance.co/callback',
scope: ['read_odometer', 'read_vehicle_info'],
testMode: false,
});

const actual = client.getAuthUrl({
scope: 'this should be ignored',
state: 'fakestate',
forcePrompt: true,
testMode: true,
});

let expected = 'https://connect.smartcar.com/oauth/authorize?';
expected += `response_type=code&client_id=${CLIENT_ID}`;
expected += '&redirect_uri=https%3A%2F%2Finsurance.co%2Fcallback';
expected += '&approval_prompt=force';
expected += '&scope=read_odometer%20read_vehicle_info';
expected += '&state=fakestate';
expected += '&mode=test';

t.is(actual, expected);

});

test('getAuthUrl - deprecated development mode', function(t) {

const client = new AuthClient({
Expand Down

0 comments on commit 9d3648c

Please sign in to comment.