Skip to content

Commit c8ab6fa

Browse files
committed
test: unit test fixes
1 parent c2a9541 commit c8ab6fa

File tree

4 files changed

+20
-23
lines changed

4 files changed

+20
-23
lines changed

packages/credential-provider-ini/src/fromIni.integ.spec.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ describe("fromIni region search order", () => {
174174
});
175175
});
176176

177-
it("should use 2nd priority for the context client", async () => {
177+
it("should use 2nd priority for the profile region", async () => {
178178
const sts = new STS({
179179
requestHandler: new MockNodeHttpHandler(),
180180
region: "ap-northeast-2",
@@ -190,29 +190,29 @@ describe("fromIni region search order", () => {
190190
expect(credentials).toContain({
191191
accessKeyId: "STS_AR_ACCESS_KEY_ID",
192192
secretAccessKey: "STS_AR_SECRET_ACCESS_KEY",
193-
sessionToken: "STS_AR_SESSION_TOKEN_ap-northeast-2",
193+
sessionToken: "STS_AR_SESSION_TOKEN_us-stsar-1",
194194
});
195195
});
196196

197-
it("should use 3rd priority for the profile region if not used in the context of a client with a region", async () => {
198-
const credentialsData = await fromIni({
199-
clientConfig: {
200-
requestHandler: new MockNodeHttpHandler(),
201-
},
202-
})();
197+
it("should use 3rd priority for the caller client", async () => {
198+
delete iniProfileData.default.region;
203199

204200
const sts = new STS({
205201
requestHandler: new MockNodeHttpHandler(),
206202
region: "ap-northeast-2",
207-
credentials: credentialsData,
203+
credentials: fromIni({
204+
clientConfig: {
205+
requestHandler: new MockNodeHttpHandler(),
206+
},
207+
}),
208208
});
209209

210210
await sts.getCallerIdentity({});
211211
const credentials = await sts.config.credentials();
212212
expect(credentials).toContain({
213213
accessKeyId: "STS_AR_ACCESS_KEY_ID",
214214
secretAccessKey: "STS_AR_SECRET_ACCESS_KEY",
215-
sessionToken: "STS_AR_SESSION_TOKEN_us-stsar-1",
215+
sessionToken: "STS_AR_SESSION_TOKEN_ap-northeast-2",
216216
});
217217
});
218218

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,7 @@ export const resolveAssumeRoleCredentials = async (
119119
credentialProviderLogger: options.logger,
120120
parentClientConfig: {
121121
...options?.parentClientConfig,
122-
// The profile region is the last fallback, and only applies
123-
// if the clientConfig.region is not defined by the user
124-
// and no contextual outer client configuration region can be found.
125-
region: options?.parentClientConfig?.region ?? region,
122+
region: region ?? options?.parentClientConfig?.region,
126123
},
127124
},
128125
options.clientPlugins

packages/credential-provider-node/src/credential-provider-node.integ.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ describe("credential-provider-node integration test", () => {
398398
expect(credentials).toEqual({
399399
accessKeyId: "STS_AR_ACCESS_KEY_ID",
400400
secretAccessKey: "STS_AR_SECRET_ACCESS_KEY",
401-
sessionToken: "STS_AR_SESSION_TOKEN_us-west-2",
401+
sessionToken: "STS_AR_SESSION_TOKEN_us-stsar-1",
402402
expiration: new Date("3000-01-01T00:00:00.000Z"),
403403
$source: {
404404
CREDENTIALS_PROFILE_SOURCE_PROFILE: "o",
@@ -805,7 +805,7 @@ describe("credential-provider-node integration test", () => {
805805
});
806806

807807
describe("Region resolution for code-level providers given to a client", () => {
808-
it("fromCognitoIdentity provider should use context client region", async () => {
808+
it("fromCognitoIdentity provider should use caller client region", async () => {
809809
sts = new STS({
810810
region: "ap-northeast-1",
811811
credentials: fromCognitoIdentity({
@@ -824,7 +824,7 @@ describe("credential-provider-node integration test", () => {
824824
});
825825
});
826826

827-
it("fromCognitoIdentityPool provider should use context client region", async () => {
827+
it("fromCognitoIdentityPool provider should use caller client region", async () => {
828828
sts = new STS({
829829
region: "ap-northeast-1",
830830
credentials: fromCognitoIdentityPool({
@@ -843,7 +843,7 @@ describe("credential-provider-node integration test", () => {
843843
});
844844
});
845845

846-
it("fromIni assumeRole provider should use the context client's region for STS", async () => {
846+
it("fromIni assumeRole provider should use the caller client's region for STS", async () => {
847847
sts = new STS({
848848
region: "eu-west-1",
849849
credentials: fromIni(),
@@ -875,7 +875,7 @@ describe("credential-provider-node integration test", () => {
875875
});
876876
});
877877

878-
it("fromWebToken provider should use context client region", async () => {
878+
it("fromWebToken provider should use caller client region", async () => {
879879
sts = new STS({
880880
region: "ap-northeast-1",
881881
credentials: fromWebToken({
@@ -899,7 +899,7 @@ describe("credential-provider-node integration test", () => {
899899

900900
it.skip(
901901
"fromSSO (SSO) provider is excluded from testing because the SSO_REGION is a required parameter and is used " +
902-
"instead of any fallback to the context client region",
902+
"instead of any fallback to the caller client region",
903903
async () => {}
904904
);
905905

packages/credential-providers/src/createCredentialChain.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ describe(createCredentialChain.name, () => {
8282
});
8383

8484
it("is compatible with contextual-region-aware credential providers", async () => {
85-
const provider: RegionalAwsCredentialIdentityProvider = async ({ contextClientConfig } = {}) => {
85+
const provider: RegionalAwsCredentialIdentityProvider = async ({ callerClientConfig } = {}) => {
8686
return {
8787
accessKeyId: "",
8888
secretAccessKey: "",
89-
sessionToken: (await contextClientConfig?.region()) ?? "wrong_region",
89+
sessionToken: (await callerClientConfig?.region()) ?? "wrong_region",
9090
};
9191
};
9292
const errorProvider = async () => {
@@ -97,7 +97,7 @@ describe(createCredentialChain.name, () => {
9797

9898
expect(
9999
await chain({
100-
contextClientConfig: {
100+
callerClientConfig: {
101101
async region() {
102102
return "ap-northeast-1";
103103
},

0 commit comments

Comments
 (0)