Skip to content

Commit 621fc45

Browse files
committed
fix(middleware-endpoint): fix for resolving file/env endpoint
1 parent 437f58f commit 621fc45

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

.changeset/fifty-news-serve.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@smithy/middleware-endpoint": patch
3+
---
4+
5+
fix resolving file/env configured endpoint
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { describe, expect, test as it, vi } from "vitest";
2+
3+
import { getEndpointFromInstructions } from "./getEndpointFromInstructions";
4+
5+
describe(getEndpointFromInstructions.name, () => {
6+
it("should set the isCustomEndpoint flag after resolving an externally configured endpoint", async () => {
7+
process.env.AWS_ENDPOINT_URL = "https://localhost";
8+
9+
const config = {
10+
serviceId: "service id",
11+
isCustomEndpoint: false,
12+
endpointProvider: vi.fn(),
13+
};
14+
15+
await getEndpointFromInstructions(
16+
{},
17+
{
18+
getEndpointParameterInstructions() {
19+
return {};
20+
},
21+
},
22+
config
23+
);
24+
25+
expect(config.isCustomEndpoint).toBe(true);
26+
});
27+
28+
it("should not use externally configured endpoint if code-level endpoint was set", async () => {
29+
process.env.AWS_ENDPOINT_URL = "https://localhost";
30+
31+
const config = {
32+
serviceId: "service id",
33+
isCustomEndpoint: true,
34+
endpointProvider: vi.fn().mockReturnValue(Symbol.for("endpoint")),
35+
};
36+
37+
const endpoint = await getEndpointFromInstructions(
38+
{},
39+
{
40+
getEndpointParameterInstructions() {
41+
return {};
42+
},
43+
},
44+
config
45+
);
46+
47+
expect(config.isCustomEndpoint).toBe(true);
48+
expect(endpoint).toBe(Symbol.for("endpoint"));
49+
});
50+
});

packages/middleware-endpoint/src/adaptors/getEndpointFromInstructions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export const getEndpointFromInstructions = async <
5252

5353
if (endpointFromConfig) {
5454
clientConfig.endpoint = () => Promise.resolve(toEndpointV1(endpointFromConfig!));
55+
clientConfig.isCustomEndpoint = true;
5556
}
5657
}
5758

0 commit comments

Comments
 (0)