Skip to content

Commit 019a968

Browse files
author
Michael Salinger
committed
Fixed integration tests
1 parent f5063ed commit 019a968

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

test/integration/index_test.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ describe('ExpressOAuthServer', function() {
5959
});
6060

6161
it('should authenticate the request', function(done) {
62-
var token = { user: {} };
62+
var tokenExpires = new Date();
63+
tokenExpires = new Date(tokenExpires.setDate(tokenExpires.getDate() + 1));
64+
65+
var token = { user: {}, accessTokenExpiresAt: tokenExpires };
6366
var model = {
6467
getAccessToken: function() {
6568
return token;
@@ -83,7 +86,10 @@ describe('ExpressOAuthServer', function() {
8386
});
8487

8588
it('should cache the authorization token', function(done) {
86-
var token = { user: {} };
89+
var tokenExpires = new Date();
90+
tokenExpires = new Date(tokenExpires.setDate(tokenExpires.getDate() + 1));
91+
92+
var token = { user: {}, accessTokenExpiresAt: tokenExpires };
8793
var model = {
8894
getAccessToken: function() {
8995
return token;
@@ -144,10 +150,10 @@ describe('ExpressOAuthServer', function() {
144150
});
145151
});
146152

147-
it('should return a `location` header with the error', function(done) {
153+
it('should return an error', function(done) {
148154
var model = {
149155
getAccessToken: function() {
150-
return { user: {} };
156+
return { user: {}, accessTokenExpiresAt: new Date() };
151157
},
152158
getClient: function() {
153159
return { grants: ['authorization_code'], redirectUris: ['http://example.com'] };
@@ -164,14 +170,17 @@ describe('ExpressOAuthServer', function() {
164170
.post('/?state=foobiz')
165171
.set('Authorization', 'Bearer foobar')
166172
.send({ client_id: 12345 })
167-
.expect('Location', 'http://example.com/?error=invalid_request&error_description=Missing%20parameter%3A%20%60response_type%60&state=foobiz')
168-
.end(done);
173+
.expect(400, function(err, res) {
174+
res.body.error.should.eql('invalid_request');
175+
res.body.error_description.should.eql('Missing parameter: `response_type`');
176+
done();
177+
});
169178
});
170179

171180
it('should return a `location` header with the code', function(done) {
172181
var model = {
173182
getAccessToken: function() {
174-
return { user: {} };
183+
return { user: {}, accessTokenExpiresAt: new Date() };
175184
},
176185
getClient: function() {
177186
return { grants: ['authorization_code'], redirectUris: ['http://example.com'] };

0 commit comments

Comments
 (0)