Make mock stsClient fail when region is missing

Signed-off-by: Lee Chiang Fong <lee_chiang_fong@tech.gov.sg>
This commit is contained in:
Lee Chiang Fong
2025-01-09 15:28:48 +08:00
parent f6294c49f9
commit 2d0afb02bc
@@ -91,6 +91,18 @@ describe('DefaultAwsCredentialsManager', () => {
Account: '123456789012',
});
stsMock
.on(GetCallerIdentityCommand)
.callsFake(async (_input, getClient) => {
const client = getClient();
const region = await client.config.region();
if (!region) {
throw new Error('Region is missing');
}
return {
Account: '123456789012',
};
});
stsMock
.on(AssumeRoleCommand, {
RoleArn: 'arn:aws:iam::111111111111:role/hello',