Skip to content

Commit

Permalink
Merge pull request #248 from ryanseys/gce-token
Browse files Browse the repository at this point in the history
fix(test): GCE token date comparison sanity check
  • Loading branch information
stephenplusplus committed Sep 30, 2014
2 parents a525e86 + aac907c commit 1f995f8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test/common/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ describe('Connection', function() {
});

it('should build token from the metadata server response', function() {
var startDate = new Date();
gceConn.requester = function(opts, callback) {
callback(null, metadataResponse, metadataResponse.body);
};
Expand All @@ -129,7 +130,8 @@ describe('Connection', function() {
assert.equal(token.accessToken, metadataResponse.body.access_token);
var addedMs = metadataResponse.body.expires_in * 1000;
var tokenDate = new Date(Date.now() + addedMs);
assert.equal(token.expiry.getTime(), tokenDate.getTime());
assert(token.expiry.getTime() >= startDate.getTime());
assert(token.expiry.getTime() <= tokenDate.getTime());
});
});
});
Expand Down

0 comments on commit 1f995f8

Please sign in to comment.