@@ -152,6 +152,22 @@ describe('with default config files', () => {
152
152
expect ( sdkConfig ( sdk ) . region ) . toEqual ( 'eu-bla-5' ) ;
153
153
} ) ;
154
154
155
+ test ( 'passing profile does not use EnvironmentCredentials' , async ( ) => {
156
+ // GIVEN
157
+ const provider = await SdkProvider . withAwsCliCompatibleDefaults ( { ...defaultCredOptions , profile : 'foo' } ) ;
158
+
159
+ const environmentCredentialsPrototype = ( new AWS . EnvironmentCredentials ( 'AWS' ) ) . constructor . prototype ;
160
+
161
+ await withMocked ( environmentCredentialsPrototype , 'refresh' , async ( refresh ) => {
162
+ refresh . mockImplementation ( ( callback : ( err ?: Error ) => void ) => callback ( new Error ( 'This function should not have been called' ) ) ) ;
163
+
164
+ // WHEN
165
+ await provider . defaultAccount ( ) ;
166
+
167
+ expect ( refresh ) . not . toHaveBeenCalled ( ) ;
168
+ } ) ;
169
+ } ) ;
170
+
155
171
test ( 'mixed profile credentials' , async ( ) => {
156
172
// WHEN
157
173
const provider = await SdkProvider . withAwsCliCompatibleDefaults ( { ...defaultCredOptions , profile : 'foo' } ) ;
@@ -309,9 +325,6 @@ test('can assume role without a [default] profile', async () => {
309
325
const provider = await SdkProvider . withAwsCliCompatibleDefaults ( {
310
326
...defaultCredOptions ,
311
327
profile : 'assumable' ,
312
- httpOptions : {
313
- proxyAddress : 'http://DOESNTMATTER/' ,
314
- } ,
315
328
} ) ;
316
329
317
330
const account = await provider . defaultAccount ( ) ;
@@ -326,8 +339,7 @@ test('can assume role with ecs credentials', async () => {
326
339
327
340
// GIVEN
328
341
bockfs ( {
329
- '/home/me/.bxt/credentials' : dedent ( `
330
- ` ) ,
342
+ '/home/me/.bxt/credentials' : '' ,
331
343
'/home/me/.bxt/config' : dedent ( `
332
344
[profile ecs]
333
345
role_arn=arn:aws:iam::12356789012:role/Assumable
@@ -343,9 +355,6 @@ test('can assume role with ecs credentials', async () => {
343
355
const provider = await SdkProvider . withAwsCliCompatibleDefaults ( {
344
356
...defaultCredOptions ,
345
357
profile : 'ecs' ,
346
- httpOptions : {
347
- proxyAddress : 'http://DOESNTMATTER/' ,
348
- } ,
349
358
} ) ;
350
359
351
360
await provider . defaultAccount ( ) ;
@@ -364,8 +373,7 @@ test('can assume role with ec2 credentials', async () => {
364
373
365
374
// GIVEN
366
375
bockfs ( {
367
- '/home/me/.bxt/credentials' : dedent ( `
368
- ` ) ,
376
+ '/home/me/.bxt/credentials' : '' ,
369
377
'/home/me/.bxt/config' : dedent ( `
370
378
[profile ecs]
371
379
role_arn=arn:aws:iam::12356789012:role/Assumable
@@ -381,9 +389,6 @@ test('can assume role with ec2 credentials', async () => {
381
389
const provider = await SdkProvider . withAwsCliCompatibleDefaults ( {
382
390
...defaultCredOptions ,
383
391
profile : 'ecs' ,
384
- httpOptions : {
385
- proxyAddress : 'http://DOESNTMATTER/' ,
386
- } ,
387
392
} ) ;
388
393
389
394
await provider . defaultAccount ( ) ;
@@ -402,8 +407,7 @@ test('can assume role with env credentials', async () => {
402
407
403
408
// GIVEN
404
409
bockfs ( {
405
- '/home/me/.bxt/credentials' : dedent ( `
406
- ` ) ,
410
+ '/home/me/.bxt/credentials' : '' ,
407
411
'/home/me/.bxt/config' : dedent ( `
408
412
[profile ecs]
409
413
role_arn=arn:aws:iam::12356789012:role/Assumable
@@ -419,9 +423,6 @@ test('can assume role with env credentials', async () => {
419
423
const provider = await SdkProvider . withAwsCliCompatibleDefaults ( {
420
424
...defaultCredOptions ,
421
425
profile : 'ecs' ,
422
- httpOptions : {
423
- proxyAddress : 'http://DOESNTMATTER/' ,
424
- } ,
425
426
} ) ;
426
427
427
428
await provider . defaultAccount ( ) ;
@@ -437,6 +438,7 @@ test('can assume role with env credentials', async () => {
437
438
test ( 'assume fails with unsupported credential_source' , async ( ) => {
438
439
// GIVEN
439
440
bockfs ( {
441
+ '/home/me/.bxt/credentials' : '' ,
440
442
'/home/me/.bxt/config' : dedent ( `
441
443
[profile assumable]
442
444
role_arn=arn:aws:iam::12356789012:role/Assumable
@@ -463,9 +465,6 @@ test('assume fails with unsupported credential_source', async () => {
463
465
const provider = await SdkProvider . withAwsCliCompatibleDefaults ( {
464
466
...defaultCredOptions ,
465
467
profile : 'assumable' ,
466
- httpOptions : {
467
- proxyAddress : 'http://DOESNTMATTER/' ,
468
- } ,
469
468
} ) ;
470
469
471
470
const account = await provider . defaultAccount ( ) ;
0 commit comments