Fixes issue 17 - Handles rev07 and above of the OAuth spec

This commit is contained in:
ciaranj
2010-12-12 22:38:56 +00:00
parent b3175f8b21
commit 2c0b8c3b79
2 changed files with 40 additions and 1 deletions

27
tests/oauth2.js Normal file
View File

@ -0,0 +1,27 @@
var vows = require('vows'),
assert = require('assert'),
OAuth2= require('../lib/oauth2').OAuth2;
vows.describe('OAuth2').addBatch({
'When handling the access token response': {
topic: new OAuth2(),
'we should correctly extract the token if received as form-data': function (oa) {
oa._request= function( method, url, fo, bar, callback) {
callback(null, "access_token=access&refresh_token=refresh");
};
oa.getOAuthAccessToken("", {}, function(error, access_token, refresh_token) {
assert.equal( access_token, "access");
assert.equal( refresh_token, "refresh");
});
},
'we should correctly extract the token if received as a JSON literal': function (oa) {
oa._request= function( method, url, fo, bar, callback) {
callback(null, '{"access_token":"access","refresh_token":"refresh"}');
};
oa.getOAuthAccessToken("", {}, function(error, access_token, refresh_token) {
assert.equal( access_token, "access");
assert.equal( refresh_token, "refresh");
});
}
}
}).export(module);