Skip to content

Commit b5d9470

Browse files
authored
Merge pull request #57 from mjsalinger/v2.0.0-release
V2.0.0 release
2 parents f1055a7 + 3881159 commit b5d9470

File tree

5 files changed

+40
-21
lines changed

5 files changed

+40
-21
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@ node_js:
77
- 6.0
88
- 7
99
- 7.0
10+
- 8
11+
- 8.0
1012

1113
sudo: false

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Changelog
2+
3+
## 2.0.0
4+
* Refactor for v3.0.0 of node-oauth2-server
5+
6+
## 1.0.0
7+
* Initial Release

index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ ExpressOAuthServer.prototype.authenticate = function(options) {
4545
return function(req, res, next) {
4646
var request = new Request(req);
4747
var response = new Response(res);
48-
4948
return Promise.bind(that)
5049
.then(function() {
5150
return this.server.authenticate(request, response, options);

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "express-oauth-server",
3-
"version": "2.0.0-b3",
3+
"version": "2.0.0",
44
"description": "OAuth provider for express",
55
"main": "index.js",
66
"scripts": {
@@ -24,7 +24,7 @@
2424
"dependencies": {
2525
"bluebird": "^3.0.5",
2626
"express": "^4.13.3",
27-
"oauth2-server": "next"
27+
"oauth2-server": "3.0.0"
2828
},
2929
"devDependencies": {
3030
"body-parser": "^1.14.1",

test/integration/index_test.js

Lines changed: 29 additions & 18 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.setDate(tokenExpires.getDate() + 1);
64+
65+
var token = { user: {}, accessTokenExpiresAt: tokenExpires };
6366
var model = {
6467
getAccessToken: function() {
6568
return token;
@@ -83,7 +86,9 @@ 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.setDate(tokenExpires.getDate() + 1);
91+
var token = { user: {}, accessTokenExpiresAt: tokenExpires };
8792
var model = {
8893
getAccessToken: function() {
8994
return token;
@@ -95,27 +100,30 @@ describe('ExpressOAuthServer', function() {
95100

96101
var spy = sinon.spy(function(req, res, next) {
97102
res.locals.oauth.token.should.equal(token);
98-
103+
res.send(token);
99104
next();
100105
});
101106
app.use(spy);
102107

103108
request(app.listen())
104109
.get('/')
105110
.set('Authorization', 'Bearer foobar')
106-
.expect(200, function(){
107-
spy.called.should.be.true;
108-
done();
111+
.expect(200, function(err, res){
112+
spy.called.should.be.True();
113+
done(err);
109114
});
110115
});
111116
});
112117

113118
describe('authorize()', function() {
114119
it('should cache the authorization code', function(done) {
120+
var tokenExpires = new Date();
121+
tokenExpires.setDate(tokenExpires.getDate() + 1);
122+
115123
var code = { authorizationCode: 123 };
116124
var model = {
117125
getAccessToken: function() {
118-
return { user: {} };
126+
return { user: {}, accessTokenExpiresAt: tokenExpires };
119127
},
120128
getClient: function() {
121129
return { grants: ['authorization_code'], redirectUris: ['http://example.com'] };
@@ -138,16 +146,16 @@ describe('ExpressOAuthServer', function() {
138146
.post('/?state=foobiz')
139147
.set('Authorization', 'Bearer foobar')
140148
.send({ client_id: 12345, response_type: 'code' })
141-
.expect(200, function(){
142-
spy.called.should.be.true;
143-
done();
149+
.expect(302, function(err, res){
150+
spy.called.should.be.True();
151+
done(err);
144152
});
145153
});
146154

147-
it('should return a `location` header with the error', function(done) {
155+
it('should return an error', function(done) {
148156
var model = {
149157
getAccessToken: function() {
150-
return { user: {} };
158+
return { user: {}, accessTokenExpiresAt: new Date() };
151159
},
152160
getClient: function() {
153161
return { grants: ['authorization_code'], redirectUris: ['http://example.com'] };
@@ -164,14 +172,17 @@ describe('ExpressOAuthServer', function() {
164172
.post('/?state=foobiz')
165173
.set('Authorization', 'Bearer foobar')
166174
.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);
175+
.expect(400, function(err, res) {
176+
res.body.error.should.eql('invalid_request');
177+
res.body.error_description.should.eql('Missing parameter: `response_type`');
178+
done(err);
179+
});
169180
});
170181

171182
it('should return a `location` header with the code', function(done) {
172183
var model = {
173184
getAccessToken: function() {
174-
return { user: {} };
185+
return { user: {}, accessTokenExpiresAt: new Date() };
175186
},
176187
getClient: function() {
177188
return { grants: ['authorization_code'], redirectUris: ['http://example.com'] };
@@ -232,9 +243,9 @@ describe('ExpressOAuthServer', function() {
232243
.post('/')
233244
.send('client_id=foo&client_secret=bar&grant_type=password&username=qux&password=biz')
234245
.expect({ access_token: 'foobar', token_type: 'Bearer' })
235-
.expect(200, function(){
236-
spy.called.should.be.true;
237-
done();
246+
.expect(200, function(err, res){
247+
spy.called.should.be.True();
248+
done(err);
238249
});
239250
});
240251

0 commit comments

Comments
 (0)