@@ -132,6 +132,35 @@ describe('S3Adapter tests', () => {
132
132
expect ( s3 . _s3Client . config . params . Bucket ) . toEqual ( 'bucket-2' ) ;
133
133
expect ( s3 . _bucketPrefix ) . toEqual ( 'test/' ) ;
134
134
} ) ;
135
+ it ( 'should accept options and overrides as an option in args' , ( ) => {
136
+ var confObj = { bucketPrefix : 'test/' , bucket : 'bucket-1' , secretKey : 'secret-1' , accessKey : 'key-1' , s3overrides : { secretAccessKey : 'secret-2' , accessKeyId : 'key-2' , params : { Bucket : 'bucket-2' } } } ;
137
+ var s3 = new S3Adapter ( confObj ) ;
138
+ expect ( s3 . _s3Client . config . accessKeyId ) . toEqual ( 'key-2' ) ;
139
+ expect ( s3 . _s3Client . config . secretAccessKey ) . toEqual ( 'secret-2' ) ;
140
+ expect ( s3 . _s3Client . config . params . Bucket ) . toEqual ( 'bucket-2' ) ;
141
+ expect ( s3 . _bucketPrefix ) . toEqual ( 'test/' ) ;
142
+ } ) ;
143
+
144
+ it ( 'should accept options and overrides as an Enviromental Variable' , ( ) => {
145
+ var confObj = { bucketPrefix : 'test/' , bucket : 'bucket-1' , secretKey : 'secret-1' , accessKey : 'key-1' } ;
146
+ process . env . S3_OVERRIDES = { secretAccessKey : 'secret-2' , accessKeyId : 'key-2' , params : { Bucket : 'bucket-2' } } ;
147
+ var s3 = new S3Adapter ( confObj ) ;
148
+ expect ( s3 . _s3Client . config . accessKeyId ) . toEqual ( 'key-2' ) ;
149
+ expect ( s3 . _s3Client . config . secretAccessKey ) . toEqual ( 'secret-2' ) ;
150
+ expect ( s3 . _s3Client . config . params . Bucket ) . toEqual ( 'bucket-2' ) ;
151
+ expect ( s3 . _bucketPrefix ) . toEqual ( 'test/' ) ;
152
+ } ) ;
153
+
154
+ it ( 'should accept overrides without params' , ( ) => {
155
+ var confObj = { bucketPrefix : 'test/' , bucket : 'bucket-1' , secretKey : 'secret-1' , accessKey : 'key-1' } ;
156
+ var overridesObj = { secretAccessKey : 'secret-2' } ;
157
+ var s3 = new S3Adapter ( confObj , overridesObj ) ;
158
+ expect ( s3 . _s3Client . config . accessKeyId ) . toEqual ( 'key-1' ) ;
159
+ expect ( s3 . _s3Client . config . secretAccessKey ) . toEqual ( 'secret-2' ) ;
160
+ expect ( s3 . _s3Client . config . params . Bucket ) . toEqual ( 'bucket-1' ) ;
161
+ expect ( s3 . _bucketPrefix ) . toEqual ( 'test/' ) ;
162
+ } ) ;
163
+ } ) ;
135
164
} ) ;
136
165
137
166
describe ( 'getFileLocation' , ( ) => {
0 commit comments