Skip to content

Commit

Permalink
Merge branch 'main' into vpc-endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
badmintoncryer authored Dec 18, 2024
2 parents e59cbdd + c1d3130 commit 61adb8f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions packages/aws-cdk/test/api/sdk-provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,19 @@ describe('with intercepted network calls', () => {
expect((await provider.defaultAccount())?.accountId).toEqual(uniq('22222'));
});

test('mfa_serial in profile will ask user for token', async () => {
const providersForMfa = [
(() => providerFromProfile('mfa-role')),
(async () => {
// The profile is not passed explicitly. Should be picked from the environment variable
process.env.AWS_PROFILE = 'mfa-role';
// Awaiting to make sure the environment variable is only deleted after it's used
const provider = await SdkProvider.withAwsCliCompatibleDefaults({ logger: console });
delete process.env.AWS_PROFILE;
return Promise.resolve(provider);
}),
];

test.each(providersForMfa)('mfa_serial in profile will ask user for token', async (metaProvider: () => Promise<SdkProvider>) => {
// GIVEN
const mockPrompt = jest.spyOn(promptly, 'prompt').mockResolvedValue('1234');

Expand All @@ -320,7 +332,8 @@ describe('with intercepted network calls', () => {
},
},
});
const provider = await providerFromProfile('mfa-role');

const provider = await metaProvider();

// THEN
const sdk = (await provider.forEnvironment(env(uniq('66666')), Mode.ForReading)).sdk;
Expand Down

0 comments on commit 61adb8f

Please sign in to comment.