Adding ability to specify an agent for OAuth2 requests

This commit is contained in:
Philip Skinner
2017-01-04 09:51:18 +00:00
committed by Philip Skinner
parent ec6a1b2eaf
commit 6baf574f87
3 changed files with 30 additions and 2 deletions

View File

@ -286,5 +286,19 @@ vows.describe('OAuth2').addBatch({
oa.get("", {});
}
}
},
'When specifying an agent, that agent is passed to the HTTP request method' : {
topic : new OAuth2('clientId', 'clientSecret', undefined, undefined, undefined, undefined),
'When calling _executeRequest': {
'we whould see the agent being put into the options' : function(oa) {
oa.setAgent('awesome agent');
oa._executeRequest({
request : function(options, cb) {
assert.equal(options.agent, 'awesome agent');
return new DummyRequest(new DummyResponse(200));
}
}, {}, null, function() {});
}
}
}
}).export(module);