Skip to content

Commit bebb3da

Browse files
committed
test(credentials): bug fixes for static and sts creds tests
1 parent 2eb7c57 commit bebb3da

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

clients/client-sts/test/defaultRoleAssumers.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ describe("getDefaultRoleAssumer", () => {
9797
};
9898
const sourceCred = { accessKeyId: "key", secretAccessKey: "secrete" };
9999
const assumedRole = await roleAssumer(sourceCred, params);
100-
expect(assumedRole.accountId).toEqual("123456789012");
100+
expect(assumedRole.accountId).toEqual("123");
101101
});
102102

103103
it("should use the STS client config", async () => {
@@ -180,6 +180,10 @@ describe("getDefaultRoleAssumer", () => {
180180
describe("getDefaultRoleAssumerWithWebIdentity", () => {
181181
const assumeRoleResponse = `<Response xmlns="https://sts.amazonaws.com/doc/2011-06-15/">
182182
<AssumeRoleWithWebIdentityResult>
183+
<AssumedRoleUser>
184+
<AssumedRoleId>AROAZOX2IL27GNRBJHWC2:session</AssumedRoleId>
185+
<Arn>arn:aws:sts::123456789012:assumed-role/assume-role-test/session</Arn>
186+
</AssumedRoleUser>
183187
<Credentials>
184188
<AccessKeyId>key</AccessKeyId>
185189
<SecretAccessKey>secrete</SecretAccessKey>

codegen/smithy-aws-typescript-codegen/src/main/resources/software/amazon/smithy/aws/typescript/codegen/sts-client-defaultRoleAssumers.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ describe("getDefaultRoleAssumer", () => {
9595
};
9696
const sourceCred = { accessKeyId: "key", secretAccessKey: "secrete" };
9797
const assumedRole = await roleAssumer(sourceCred, params);
98-
expect(assumedRole.accountId).toEqual("123456789012");
98+
expect(assumedRole.accountId).toEqual("123");
9999
});
100100

101101
it("should use the STS client config", async () => {
@@ -178,6 +178,10 @@ describe("getDefaultRoleAssumer", () => {
178178
describe("getDefaultRoleAssumerWithWebIdentity", () => {
179179
const assumeRoleResponse = `<Response xmlns="https://sts.amazonaws.com/doc/2011-06-15/">
180180
<AssumeRoleWithWebIdentityResult>
181+
<AssumedRoleUser>
182+
<AssumedRoleId>AROAZOX2IL27GNRBJHWC2:session</AssumedRoleId>
183+
<Arn>arn:aws:sts::123456789012:assumed-role/assume-role-test/session</Arn>
184+
</AssumedRoleUser>
181185
<Credentials>
182186
<AccessKeyId>key</AccessKeyId>
183187
<SecretAccessKey>secrete</SecretAccessKey>

packages/credential-provider-ini/src/resolveStaticCredentials.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ export const isStaticCredsProfile = (arg: any): arg is StaticCredsProfile =>
2121
typeof arg === "object" &&
2222
typeof arg.aws_access_key_id === "string" &&
2323
typeof arg.aws_secret_access_key === "string" &&
24-
["undefined", "string"].indexOf(typeof arg.aws_session_token) > -1;
24+
["undefined", "string"].indexOf(typeof arg.aws_session_token) > -1 &&
25+
["undefined", "string"].indexOf(typeof arg.aws_account_id) > -1;
2526

2627
/**
2728
* @internal

packages/credential-provider-process/src/resolveProcessCredentials.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ describe(resolveProcessCredentials.name, () => {
115115
const receivedCreds = await resolveProcessCredentials(mockProfileName, getMockProfiles());
116116
expect(receivedCreds).toStrictEqual(expectedCreds);
117117
expect(mockExecPromise).toHaveBeenCalledWith(mockCredentialProcess);
118-
expect(getValidatedProcessCredentials).toHaveBeenCalledWith(mockProfileName, JSON.parse(mockExecPromiseOutput));
118+
expect(getValidatedProcessCredentials).toHaveBeenCalledWith(
119+
mockProfileName,
120+
JSON.parse(mockExecPromiseOutput),
121+
getMockProfiles()
122+
);
119123
});
120124
});

0 commit comments

Comments
 (0)