diff --git a/lib/storage/file.js b/lib/storage/file.js index e3bc507e986..bd288e29df4 100644 --- a/lib/storage/file.js +++ b/lib/storage/file.js @@ -24,6 +24,7 @@ var concat = require('concat-stream'); var createErrorClass = require('create-error-class'); var crypto = require('crypto'); var duplexify = require('duplexify'); +var extend = require('extend'); var format = require('string-format-obj'); var fs = require('fs'); var hashStreamValidation = require('hash-stream-validation'); @@ -979,6 +980,8 @@ File.prototype.getSignedPolicy = function(options, callback) { throw new Error('An expiration date cannot be in the past.'); } + options = extend({}, options); + var conditions = [ ['eq', '$key', this.name], { @@ -1159,6 +1162,8 @@ File.prototype.getSignedUrl = function(options, callback) { throw new Error('An expiration date cannot be in the past.'); } + options = extend({}, options); + options.action = { read: 'GET', write: 'PUT', diff --git a/test/storage/file.js b/test/storage/file.js index 0e8229a7d85..10d1f91a7ba 100644 --- a/test/storage/file.js +++ b/test/storage/file.js @@ -1353,6 +1353,20 @@ describe('File', function() { }); }); + it('should not modify the configuration object', function(done) { + var config = { + expires: Date.now() + 5 + }; + + var originalConfig = extend({}, config); + + file.getSignedPolicy(config, function(err) { + assert.ifError(err); + assert.deepEqual(config, originalConfig); + done(); + }); + }); + it('should return an error if getCredentials errors', function(done) { var error = new Error('Error.'); @@ -1642,6 +1656,21 @@ describe('File', function() { }); }); + it('should not modify the configuration object', function(done) { + var config = { + action: 'read', + expires: Date.now() + 5 + }; + + var originalConfig = extend({}, config); + + file.getSignedUrl(config, function(err) { + assert.ifError(err); + assert.deepEqual(config, originalConfig); + done(); + }); + }); + it('should return an error if getCredentials errors', function(done) { var error = new Error('Error.');