Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #25 from kainosnoema/fix/setAuth-error

setAuth() should fail with error on non-204 response
  • Loading branch information...
commit f5654ea7f029ec27825bc1a168c21ffc904b0110 2 parents a7062ea + c0da740
@bmeck bmeck authored
Showing with 8 additions and 1 deletion.
  1. +6 −0 lib/cloudfiles/core.js
  2. +2 −1  test/authentication-test.js
View
6 lib/cloudfiles/core.js
@@ -64,6 +64,12 @@ Cloudfiles.prototype.setAuth = function (callback) {
return callback(err);
}
+ var statusCode = res.statusCode.toString();
+ if (Object.keys(common.failCodes).indexOf(statusCode) !== -1) {
+ err = new Error('Rackspace Error (' + statusCode + '): ' + common.failCodes[statusCode]);
+ return callback(err, res);
+ }
+
self.authorized = true;
self.config.serverUrl = res.headers['x-server-management-url'];
self.config.setStorageUrl(res.headers['x-storage-url']);
View
3  test/authentication-test.js
@@ -46,7 +46,8 @@ vows.describe('node-cloudfiles/authentication').addBatch({
invalidClient.setAuth(this.callback);
},
- "should respond with 401": function (err, res) {
+ "should respond with 401 and return an error": function (err, res) {
+ assert.ok(err instanceof Error);
assert.equal(res.statusCode, 401);
}
},
Please sign in to comment.
Something went wrong with that request. Please try again.