Reimplemented configurable http method for token requests using setClientOptions

This commit is contained in:
Raoul Millais
2011-08-17 08:42:58 +01:00
parent 49c83f1824
commit aca047eaeb
2 changed files with 48 additions and 35 deletions

View File

@ -141,15 +141,36 @@ vows.describe('OAuth').addBatch({
oa._performSecureRequest= function(){ return this.requestArguments = arguments; }
return oa;
},
'Use the provided HTTP method': function(oa) {
oa.getOAuthRequestToken("GET", function() {});
'Use the HTTP method in the client options': function(oa) {
oa.setClientOptions({ requestTokenHttpMethod: "GET" });
oa.getOAuthRequestToken(function() {});
assert.equal(oa.requestArguments[2], "GET");
},
'Use a POST by default': function(oa) {
oa.setClientOptions({});
oa.getOAuthRequestToken(function() {});
assert.equal(oa.requestArguments[2], "POST");
}
},
'When getting an access token': {
topic: function() {
var oa= new OAuth(null, null, "consumerkey", "consumersecret", "1.0", null, "HMAC-SHA1");
oa._getTimestamp= function(){ return "1272399856"; }
oa._getNonce= function(){ return "ybHPeOEkAUJ3k2wJT9Xb43MjtSgTvKqp"; }
oa._performSecureRequest= function(){ return this.requestArguments = arguments; }
return oa;
},
'Use the HTTP method in the client options': function(oa) {
oa.setClientOptions({ accessTokenHttpMethod: "GET" });
oa.getOAuthAccessToken(function() {});
assert.equal(oa.requestArguments[2], "GET");
},
'Use a POST by default': function(oa) {
oa.setClientOptions({});
oa.getOAuthAccessToken(function() {});
assert.equal(oa.requestArguments[2], "POST");
}
},
'When get authorization header' : {
topic: function() {
var oa= new OAuth(null, null, "consumerkey", "consumersecret", "1.0", null, "HMAC-SHA1");