-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(cli): profile AssumeRole credentials don't work via proxy #7292
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,10 @@ beforeEach(() => { | |
[foo] | ||
aws_access_key_id=${uid}fooccess | ||
aws_secret_access_key=secret | ||
|
||
[assumer] | ||
aws_access_key_id=${uid}assumer | ||
aws_secret_access_key=secret | ||
`), | ||
'/home/me/.bxt/config': dedent(` | ||
[default] | ||
|
@@ -46,6 +50,13 @@ beforeEach(() => { | |
aws_access_key_id=${uid}booccess | ||
aws_secret_access_key=boocret | ||
# No region here | ||
|
||
[profile assumable] | ||
role_arn=arn:aws:iam::12356789012:role/Assumable | ||
source_profile=assumer | ||
|
||
[profile assumer] | ||
region=us-east-2 | ||
`), | ||
}); | ||
|
||
|
@@ -138,6 +149,40 @@ describe('CLI compatible credentials loading', () => { | |
|
||
await expect(provider.forEnvironment(`${uid}some_account_#`, 'def', Mode.ForReading)).rejects.toThrow('Need to perform AWS calls'); | ||
}); | ||
|
||
test('even when using a profile to assume another profile, STS calls goes through the proxy', async () => { | ||
// Messy mocking | ||
let called = false; | ||
jest.mock('proxy-agent', () => { | ||
class FakeAgent extends require('https').Agent { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this not complain about using require? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Of course it does :) |
||
public addRequest(_: any, __: any) { | ||
// This error takes 6 seconds to be completely handled. It might be retries in the SDK | ||
// somewhere, or something about the Node event loop. I've spent an hour trying to figure | ||
// it out and I can't, and I gave up. We'll just have to live with this. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe add a |
||
const error = new Error('ABORTED BY TEST'); | ||
(error as any).code = 'RequestAbortedError'; | ||
(error as any).retryable = false; | ||
called = true; | ||
throw error; | ||
} | ||
} | ||
return FakeAgent; | ||
}); | ||
|
||
// WHEN | ||
const provider = await SdkProvider.withAwsCliCompatibleDefaults({ ...defaultCredOptions, | ||
ec2creds: false, | ||
profile: 'assumable', | ||
httpOptions: { | ||
proxyAddress: 'http://DOESNTMATTER/', | ||
} | ||
}); | ||
|
||
await provider.defaultAccount(); | ||
|
||
// THEN -- the fake proxy agent got called, we don't care about the result | ||
expect(called).toEqual(true); | ||
}); | ||
}); | ||
|
||
describe('Plugins', () => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove?