Skip to content

Commit

Permalink
Catch errors while building authorization url (#43)
Browse files Browse the repository at this point in the history
Resolves: OKTA-99859
  • Loading branch information
lboyette-okta authored Sep 26, 2016
1 parent a4147b3 commit 1dc62f8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
7 changes: 6 additions & 1 deletion lib/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,12 @@ function getToken(sdk, oauthOptions, options) {
}

// Use the query params to build the authorize url
var requestUrl = buildAuthorizeUrl(sdk, oauthParams);
var requestUrl;
try {
requestUrl = buildAuthorizeUrl(sdk, oauthParams);
} catch (e) {
return Q.reject(e);
}

// Determine the flow type
var flowType;
Expand Down
4 changes: 2 additions & 2 deletions test/spec/oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ define(function(require) {
});

describe('errors', function() {
oauthUtil.itErrorsCorrectly('throws an error when openid scope isn\'t specified',
oauthUtil.itpErrorsCorrectly('throws an error when openid scope isn\'t specified',
{
authorizeArgs: {
clientId: 'NPSfOkH5eZrTy8PMDlvx',
Expand All @@ -251,7 +251,7 @@ define(function(require) {
errorCauses: []
}
);
oauthUtil.itErrorsCorrectly('throws an error when clientId isn\'t specified',
oauthUtil.itpErrorsCorrectly('throws an error when clientId isn\'t specified',
{
authorizeArgs: {
redirectUri: 'https://auth-js-test.okta.com/redirect',
Expand Down
2 changes: 1 addition & 1 deletion test/spec/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ define(function(require) {
});
});

oauthUtil.itErrorsCorrectly('throws an error if multiple responseTypes are sent as a string',
oauthUtil.itpErrorsCorrectly('throws an error if multiple responseTypes are sent as a string',
{
oktaAuthArgs: {
url: 'https://auth-js-test.okta.com',
Expand Down
13 changes: 0 additions & 13 deletions test/util/oauthUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,19 +289,6 @@ define(function(require) {
});
};

oauthUtil.itErrorsCorrectly = function(title, options, error) {
it(title, function () {
var thrown = false;
try {
oauthUtil.setupFrame(options);
} catch (e) {
util.expectErrorToEqual(e, error);
thrown = true;
}
expect(thrown).toEqual(true);
});
};

oauthUtil.itpErrorsCorrectly = function(title, options, error) {
it(title, function (done) {
options.willFail = true;
Expand Down

0 comments on commit 1dc62f8

Please sign in to comment.