Adding a test for the refresh_token grant type support
This commit is contained in:
parent
64b2487199
commit
c631a31503
@ -3,8 +3,9 @@ var vows = require('vows'),
|
|||||||
OAuth2= require('../lib/oauth2').OAuth2;
|
OAuth2= require('../lib/oauth2').OAuth2;
|
||||||
|
|
||||||
vows.describe('OAuth2').addBatch({
|
vows.describe('OAuth2').addBatch({
|
||||||
'When handling the access token response': {
|
'Given an OAuth2 instance, ': {
|
||||||
topic: new OAuth2(),
|
topic: new OAuth2(),
|
||||||
|
'When handling the access token response': {
|
||||||
'we should correctly extract the token if received as form-data': function (oa) {
|
'we should correctly extract the token if received as form-data': function (oa) {
|
||||||
oa._request= function( method, url, fo, bar, bleh, callback) {
|
oa._request= function( method, url, fo, bar, bleh, callback) {
|
||||||
callback(null, "access_token=access&refresh_token=refresh");
|
callback(null, "access_token=access&refresh_token=refresh");
|
||||||
@ -35,5 +36,32 @@ vows.describe('OAuth2').addBatch({
|
|||||||
assert.equal( results.extra_2, "foo");
|
assert.equal( results.extra_2, "foo");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
'When no grant_type parameter is specified': {
|
||||||
|
'we should pass the value of the code argument as the code parameter': function(oa) {
|
||||||
|
oa._request= function(method, url, headers, post_body, access_token, callback) {
|
||||||
|
assert.isTrue( post_body.indexOf("code=xsds23") != -1 )
|
||||||
|
}
|
||||||
|
oa.getOAuthAccessToken("xsds23", {} );
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'When an invalid grant_type parameter is specified': {
|
||||||
|
'we should pass the value of the code argument as the code parameter': function(oa) {
|
||||||
|
oa._request= function(method, url, headers, post_body, access_token, callback) {
|
||||||
|
assert.isTrue( post_body.indexOf("code=xsds23") != -1 )
|
||||||
|
}
|
||||||
|
oa.getOAuthAccessToken("xsds23", {grant_type:"refresh_toucan"} );
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'When a grant_type parameter of value "refresh_token" is specified': {
|
||||||
|
'we should pass the value of the code argument as the refresh_token parameter, should pass a grant_type parameter, but shouldn\'t pass a code parameter' : function(oa) {
|
||||||
|
oa._request= function(method, url, headers, post_body, access_token, callback) {
|
||||||
|
assert.isTrue( post_body.indexOf("refresh_token=sdsds2") != -1 )
|
||||||
|
assert.isTrue( post_body.indexOf("grant_type=refresh_token") != -1 )
|
||||||
|
assert.isTrue( post_body.indexOf("code=") == -1 )
|
||||||
|
}
|
||||||
|
oa.getOAuthAccessToken("sdsds2", {grant_type:"refresh_token"} );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}).export(module);
|
}).export(module);
|
Loading…
x
Reference in New Issue
Block a user