File tree 2 files changed +34
-0
lines changed
2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ var concat = require('concat-stream');
24
24
var createErrorClass = require ( 'create-error-class' ) ;
25
25
var crypto = require ( 'crypto' ) ;
26
26
var duplexify = require ( 'duplexify' ) ;
27
+ var extend = require ( 'extend' ) ;
27
28
var format = require ( 'string-format-obj' ) ;
28
29
var fs = require ( 'fs' ) ;
29
30
var hashStreamValidation = require ( 'hash-stream-validation' ) ;
@@ -979,6 +980,8 @@ File.prototype.getSignedPolicy = function(options, callback) {
979
980
throw new Error ( 'An expiration date cannot be in the past.' ) ;
980
981
}
981
982
983
+ options = extend ( { } , options ) ;
984
+
982
985
var conditions = [
983
986
[ 'eq' , '$key' , this . name ] ,
984
987
{
@@ -1159,6 +1162,8 @@ File.prototype.getSignedUrl = function(options, callback) {
1159
1162
throw new Error ( 'An expiration date cannot be in the past.' ) ;
1160
1163
}
1161
1164
1165
+ options = extend ( { } , options ) ;
1166
+
1162
1167
options . action = {
1163
1168
read : 'GET' ,
1164
1169
write : 'PUT' ,
Original file line number Diff line number Diff line change @@ -1353,6 +1353,20 @@ describe('File', function() {
1353
1353
} ) ;
1354
1354
} ) ;
1355
1355
1356
+ it ( 'should not modify the configuration object' , function ( done ) {
1357
+ var config = {
1358
+ expires : Date . now ( ) + 5
1359
+ } ;
1360
+
1361
+ var originalConfig = extend ( { } , config ) ;
1362
+
1363
+ file . getSignedPolicy ( config , function ( err ) {
1364
+ assert . ifError ( err ) ;
1365
+ assert . deepEqual ( config , originalConfig ) ;
1366
+ done ( ) ;
1367
+ } ) ;
1368
+ } ) ;
1369
+
1356
1370
it ( 'should return an error if getCredentials errors' , function ( done ) {
1357
1371
var error = new Error ( 'Error.' ) ;
1358
1372
@@ -1642,6 +1656,21 @@ describe('File', function() {
1642
1656
} ) ;
1643
1657
} ) ;
1644
1658
1659
+ it ( 'should not modify the configuration object' , function ( done ) {
1660
+ var config = {
1661
+ action : 'read' ,
1662
+ expires : Date . now ( ) + 5
1663
+ } ;
1664
+
1665
+ var originalConfig = extend ( { } , config ) ;
1666
+
1667
+ file . getSignedUrl ( config , function ( err ) {
1668
+ assert . ifError ( err ) ;
1669
+ assert . deepEqual ( config , originalConfig ) ;
1670
+ done ( ) ;
1671
+ } ) ;
1672
+ } ) ;
1673
+
1645
1674
it ( 'should return an error if getCredentials errors' , function ( done ) {
1646
1675
var error = new Error ( 'Error.' ) ;
1647
1676
You can’t perform that action at this time.
0 commit comments