Set default User-Agent if not otherwise specified in customHeaders

This commit is contained in:
Andrew Martens
2013-05-07 14:38:04 -07:00
parent 3fc9c63a06
commit a742d838f5
2 changed files with 28 additions and 0 deletions

View File

@ -133,5 +133,29 @@ vows.describe('OAuth2').addBatch({
oa.get("", {});
}
}
},
'When the user passes in the User-Agent in customHeaders': {
topic: new OAuth2("clientId", "clientSecret", undefined, undefined, undefined,
{ 'User-Agent': '123Agent' }),
'When calling get': {
'we should see the User-Agent mixed into headers property in options passed to http-library' : function(oa) {
oa._executeRequest= function( http_library, options, callback ) {
assert.equal(options.headers["User-Agent"], "123Agent");
};
oa.get("", {});
}
}
},
'When the user does not pass in a User-Agent in customHeaders': {
topic: new OAuth2("clientId", "clientSecret", undefined, undefined, undefined,
undefined),
'When calling get': {
'we should see the default User-Agent mixed into headers property in options passed to http-library' : function(oa) {
oa._executeRequest= function( http_library, options, callback ) {
assert.equal(options.headers["User-Agent"], "Node-oauth");
};
oa.get("", {});
}
}
}
}).export(module);