-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cli): failure to get credentials when session token is not set
- Loading branch information
1 parent
fb97684
commit 43fa4ad
Showing
2 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/aws-cdk/test/api/aws-auth/awscli-compatible.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { AwsCliCompatible } from '../../../lib/api/aws-auth/awscli-compatible'; | ||
|
||
test('does not mess up with session token env variables if they are undefined', async () => { | ||
process.env.AWS_ACCESS_KEY_ID = 'foo'; | ||
process.env.SECRET_ACCESS_KEY = 'bar'; | ||
|
||
// Making sure these variables are not defined | ||
delete process.env.AWS_SESSION_TOKEN; | ||
delete process.env.AMAZON_SESSION_TOKEN; | ||
|
||
await AwsCliCompatible.credentialChainBuilder(); | ||
|
||
expect(process.env.AWS_SESSION_TOKEN).toBeUndefined(); | ||
}); | ||
|
||
test('preserves session token env variables if they are defined', async () => { | ||
process.env.AWS_ACCESS_KEY_ID = 'foo'; | ||
process.env.SECRET_ACCESS_KEY = 'bar'; | ||
|
||
process.env.AWS_SESSION_TOKEN = 'aaa'; | ||
process.env.AMAZON_SESSION_TOKEN = 'bbb'; | ||
|
||
await AwsCliCompatible.credentialChainBuilder(); | ||
|
||
expect(process.env.AWS_SESSION_TOKEN).toEqual('aaa'); | ||
}); |