Skip to content

Commit 7b88309

Browse files
committed
Expand test coverage.
1 parent 47b10a0 commit 7b88309

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

test/oauth2.state.session.test.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,48 @@ describe('OAuth2Strategy', function() {
176176
});
177177
}); // that was approved
178178

179+
describe('that was approved with other data in the session', function() {
180+
var request
181+
, user
182+
, info;
183+
184+
before(function(done) {
185+
chai.passport.use(strategy)
186+
.success(function(u, i) {
187+
user = u;
188+
info = i;
189+
done();
190+
})
191+
.req(function(req) {
192+
request = req;
193+
194+
req.query = {};
195+
req.query.code = 'SplxlOBeZQQYbYS6WxSbIA';
196+
req.query.state = 'DkbychwKu8kBaJoLE5yeR5NK';
197+
req.session = {};
198+
req.session['oauth2:www.example.com'] = {};
199+
req.session['oauth2:www.example.com']['state'] = 'DkbychwKu8kBaJoLE5yeR5NK';
200+
req.session['oauth2:www.example.com'].foo = 'bar';
201+
})
202+
.authenticate();
203+
});
204+
205+
it('should supply user', function() {
206+
expect(user).to.be.an.object;
207+
expect(user.id).to.equal('1234');
208+
});
209+
210+
it('should supply info', function() {
211+
expect(info).to.be.an.object;
212+
expect(info.message).to.equal('Hello');
213+
});
214+
215+
it('should preserve other data from session', function() {
216+
expect(request.session['oauth2:www.example.com'].state).to.be.undefined;
217+
expect(request.session['oauth2:www.example.com'].foo).to.equal('bar');
218+
});
219+
}); // that was approved with other data in the session
220+
179221
describe('that fails due to state being invalid', function() {
180222
var request
181223
, info, status;

0 commit comments

Comments
 (0)