Skip to content

Commit

Permalink
Ensure that expiry_date is being set properly
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanseys committed Jul 29, 2014
1 parent 0447b20 commit ac91269
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion test/test.oauth2.js
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ describe('OAuth2 client', function() {
});

describe('revokeCredentials()', function() {
it('should revoke credentials if access token present', function(done) {
it('should revoke credentials if access token present', function(done) {
var scope = nock('https://accounts.google.com')
.get('/o/oauth2/revoke?token=abc')
.reply(200, { success: true });
Expand Down Expand Up @@ -913,4 +913,20 @@ describe('OAuth2 client', function() {
});
});
});

describe('getToken()', function() {
it('should return expiry_date object with expires_in', function(done) {
var now = (new Date()).getTime();
var scope = nock('https://accounts.google.com')
.post('/o/oauth2/token')
.reply(200, { access_token: 'abc', refresh_token: '123', expires_in: 10 });
var oauth2client = new googleapis.auth.OAuth2(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI);
oauth2client.getToken('code here', function(err, tokens) {
assert(tokens.expiry_date > now + (10 * 1000));
assert(tokens.expiry_date < now + (15 * 1000));
scope.done();
done();
});
});
});
});

0 comments on commit ac91269

Please sign in to comment.