Adding test for passing back the extra data to the OAuth2 getOAuthAccessToken caller

This commit is contained in:
ciaranj 2012-04-24 20:44:58 +01:00
parent e4cc471160
commit 6fa0288805
2 changed files with 33 additions and 19 deletions

View File

@ -10,6 +10,7 @@ Also provides rudimentary OAuth2 support, tested against facebook connect and gi
Change History Change History
============== ==============
* 0.10.0 - OAuth2: Pass back any extra response data for calls to getOAuthAccessToken (Thanks to Tang Bo Hao)
* 0.9.6 - Support for 302 redirects on OAuth2 (Thanks Patrick Negri). Some code tidying. ( Thanks to Raoul Millais ) * 0.9.6 - Support for 302 redirects on OAuth2 (Thanks Patrick Negri). Some code tidying. ( Thanks to Raoul Millais )
* 0.9.5 - Allow usage of HTTP verbs other than GET for retrieving the access and request tokens (OAuth1) (Thanks to Raoul Millais) * 0.9.5 - Allow usage of HTTP verbs other than GET for retrieving the access and request tokens (OAuth1) (Thanks to Raoul Millais)
* 0.9.4 - Support for OAuth providers that drop connections (don't send response lengths? [Google]) And change OAuth2 getOAuthAccessToken to POST rather than GET ( Possible Breaking change!!! ... re-tested against Google, Github, Facebook, FourSquare and Janrain and seems ok .. is closer to the spec (v20) ) * 0.9.4 - Support for OAuth providers that drop connections (don't send response lengths? [Google]) And change OAuth2 getOAuthAccessToken to POST rather than GET ( Possible Breaking change!!! ... re-tested against Google, Github, Facebook, FourSquare and Janrain and seems ok .. is closer to the spec (v20) )
@ -39,3 +40,4 @@ Contributors
* Ryan LeFevre - http://meltingice.net * Ryan LeFevre - http://meltingice.net
* Raoul Millais * Raoul Millais
* Patrick Negri - http://github.com/pnegri * Patrick Negri - http://github.com/pnegri
* Tang Bo Hao - http://github.com/btspoony

View File

@ -22,6 +22,18 @@ vows.describe('OAuth2').addBatch({
assert.equal( access_token, "access"); assert.equal( access_token, "access");
assert.equal( refresh_token, "refresh"); assert.equal( refresh_token, "refresh");
}); });
},
'we should return the received data to the calling method': function (oa) {
oa._request= function(method, url, headers, post_body, access_token, callback) {
callback(null, '{"access_token":"access","refresh_token":"refresh","extra_1":1, "extra_2":"foo"}');
};
oa.getOAuthAccessToken("", {}, function(error, access_token, refresh_token, results) {
assert.equal( access_token, "access");
assert.equal( refresh_token, "refresh");
assert.isNotNull( results );
assert.equal( results.extra_1, 1);
assert.equal( results.extra_2, "foo");
});
} }
} }
}).export(module); }).export(module);