Merge remote-tracking branch 'jfromaniello/bug129'

This commit is contained in:
ciaranj
2013-03-05 17:43:51 +00:00
2 changed files with 13 additions and 2 deletions

View File

@ -1,7 +1,8 @@
var vows = require('vows'),
assert = require('assert'),
https = require('https'),
OAuth2= require('../lib/oauth2').OAuth2;
OAuth2= require('../lib/oauth2').OAuth2,
url = require('url');
vows.describe('OAuth2').addBatch({
'Given an OAuth2 instance with clientId and clientSecret, ': {
@ -16,6 +17,16 @@ vows.describe('OAuth2').addBatch({
assert.equal( refresh_token, "refresh");
});
},
'we should not include access token in both querystring and headers': function (oa) {
oa._request = new OAuth2("clientId", "clientSecret")._request.bind(oa);
oa._executeRequest= function( http_library, options, post_body, callback) {
callback(null, url.parse(options.path, true).query, options.headers);
};
oa.get("/userinfo", 'access', function(error, query, headers) {
assert.ok( !('access_token' in query), "access_token not in query");
assert.ok( 'Authorization' in headers, "Authorization in headers");
});
},
'we should correctly extract the token if received as a JSON literal': function (oa) {
oa._request= function(method, url, headers, post_body, access_token, callback) {
callback(null, '{"access_token":"access","refresh_token":"refresh"}');