Comparing version 2.0.7 to 2.0.8
{ | ||
"name": "edgegrid", | ||
"version": "2.0.7", | ||
"version": "2.0.8", | ||
"description": "Authentication handler for the Akamai OPEN EdgeGrid Authentication scheme in Node.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -35,6 +35,6 @@ // Copyright 2014 Akamai Technologies, Inc. All Rights Reserved | ||
* Builds the request using the properties of the local config Object. | ||
* | ||
* | ||
* @param {Object} req The request Object. Can optionally contain a | ||
* 'headersToSign' property: An ordered list header names | ||
* that will be included in the signature. This will be | ||
* 'headersToSign' property: An ordered list header names | ||
* that will be included in the signature. This will be | ||
* provided by specific APIs. | ||
@@ -67,10 +67,11 @@ */ | ||
); | ||
return this; | ||
}; | ||
EdgeGrid.prototype.send = function(callback) { | ||
request(this.request, function(error, response, body) { | ||
request(this.request, function(error, response, body) { | ||
if (error) { | ||
throw new Error(error); | ||
callback(error) | ||
return | ||
} | ||
if (helpers.isRedirect(response.statusCode)) { | ||
@@ -83,2 +84,4 @@ this._handleRedirect(response, callback); | ||
}.bind(this)); | ||
return this; | ||
}; | ||
@@ -99,7 +102,7 @@ | ||
* Creates a config object from a set of parameters. | ||
* | ||
* | ||
* @param {String} client_token The client token | ||
* @param {String} client_secret The client secret | ||
* @param {String} access_token The access token | ||
* @param {String} host The host | ||
* @param {String} host The host | ||
*/ | ||
@@ -140,3 +143,3 @@ EdgeGrid.prototype._setConfigFromStrings = function(client_token, client_secret, access_token, host) { | ||
* Creates a config Object from the section of a defined .edgerc file. | ||
* | ||
* | ||
* @param {Object} obj An Object containing a path and section property that | ||
@@ -143,0 +146,0 @@ * define the .edgerc section to use to create the Object. |
@@ -29,4 +29,2 @@ // Copyright 2014 Akamai Technologies, Inc. All Rights Reserved | ||
console.log("Preparedbody: ", preparedBody); | ||
if (typeof preparedBody === 'object') { | ||
@@ -33,0 +31,0 @@ var postDataNew = '', |
@@ -146,2 +146,6 @@ // Copyright 2014 Akamai Technologies, Inc. All Rights Reserved | ||
describe('#auth', function() { | ||
it('should be chainable', function(){ | ||
assert.deepEqual(this.api, this.api.auth({ path: '/foo' })); | ||
}); | ||
describe('when minimal request options are passed', function() { | ||
@@ -211,2 +215,7 @@ beforeEach(function() { | ||
describe('#send', function() { | ||
it('should be chainable', function(){ | ||
assert.deepEqual(this.api, this.api.auth({ path: '/foo' }).send()); | ||
}); | ||
describe('when authentication is done with a simple options object specifying only a path', function() { | ||
@@ -277,3 +286,19 @@ beforeEach(function() { | ||
}); | ||
describe('when the initial request fails', function() { | ||
it('correctly handles the error in the callback', function(done) { | ||
nock('https://base.com') | ||
.get('/foo') | ||
.replyWithError('something awful happened'); | ||
this.api.auth({ | ||
path: '/foo', | ||
}); | ||
this.api.send(function (data) { | ||
assert.equal(data.message, 'something awful happened'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
275600
1181