Skip to content

Commit

Permalink
Additional test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhanson committed Feb 10, 2016
1 parent aa32ec0 commit 2a7c4df
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/strategy.js
Expand Up @@ -100,7 +100,7 @@ function OAuthStrategy(options, verify) {
this._userAuthorizationURL = options.userAuthorizationURL;
this._callbackURL = options.callbackURL;
this._key = options.sessionKey || 'oauth';
this._requestTokenStore = new SessionRequestTokenStore({ key: this._key });
this._requestTokenStore = options.requestTokenStore || new SessionRequestTokenStore({ key: this._key });
this._trustProxy = options.proxy;
this._passReqToCallback = options.passReqToCallback;
this._skipUserProfile = (options.skipUserProfile === undefined) ? false : options.skipUserProfile;
Expand Down
38 changes: 38 additions & 0 deletions test/oauth.test.js
Expand Up @@ -603,6 +603,44 @@ describe('OAuthStrategy', function() {
});
}); // that errors due to request token request error

describe('that errors due to lack of session support in app', function() {
var strategy = new OAuthStrategy({
requestTokenURL: 'https://www.example.com/oauth/request_token',
accessTokenURL: 'https://www.example.com/oauth/access_token',
userAuthorizationURL: 'https://www.example.com/oauth/authorize',
consumerKey: 'ABC123',
consumerSecret: 'secret'
}, function() {});

strategy._oauth.getOAuthRequestToken = function(extraParams, callback) {
if (Object.keys(extraParams).length !== 1) { return callback(new Error('incorrect extraParams argument')); }
if (extraParams.oauth_callback !== undefined) { return callback(new Error('incorrect oauth_callback argument')); }

callback(null, 'hh5s93j4hdidpola', 'hdhd0244k9j7ao03', {});
}


var request
, err;

before(function(done) {
chai.passport.use(strategy)
.error(function(e) {
err = e;
done();
})
.req(function(req) {
request = req;
})
.authenticate();
});

it('should error', function() {
expect(err).to.be.an.instanceof(Error);
expect(err.message).to.equal('OAuthStrategy requires session support. Did you forget app.use(express.session(...))?');
});
}); // that errors due to lack of session support in app

describe('from behind a secure proxy', function() {

describe('that is trusted by app and sets x-forwarded-proto', function() {
Expand Down

0 comments on commit 2a7c4df

Please sign in to comment.