Skip to content

Commit 90e8b5b

Browse files
committed
test: update tests
1 parent 65944f1 commit 90e8b5b

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

packages/middleware-sdk-s3-control/src/process-arnables-plugin/plugin.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ describe("getProcessArnablesMiddleware", () => {
2020
regionInfoProvider: options.regionInfoProvider ?? jest.fn().mockResolvedValue({ partition: "aws" }),
2121
region: jest.fn().mockResolvedValue(options.region),
2222
useArnRegion: jest.fn().mockResolvedValue(options.useArnRegion ?? false),
23+
isCustomEndpoint: false,
2324
};
2425
};
2526

packages/middleware-sdk-s3-control/src/process-arnables-plugin/update-arnables-request.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@ const REGEX_S3CONTROL_HOSTNAME = /^(.+\.)?s3-control[.-]([a-z0-9-]+)\./;
1212
* After outpost request is constructed, redirect request to outpost endpoint and set `x-amz-account-id` and
1313
* `x-amz-outpost-id` headers.
1414
*/
15-
export const updateArnablesRequestMiddleware = (options: S3ControlResolvedConfig): BuildMiddleware<any, any> => (
16-
next,
17-
context
18-
) => (args) => {
15+
export const updateArnablesRequestMiddleware = ({
16+
isCustomEndpoint,
17+
}: {
18+
isCustomEndpoint: boolean;
19+
}): BuildMiddleware<any, any> => (next, context) => (args) => {
1920
const { request } = args;
2021
if (!HttpRequest.isInstance(request)) return next(args);
2122
if (context[CONTEXT_ACCOUNT_ID]) request.headers[ACCOUNT_ID_HEADER] = context[CONTEXT_ACCOUNT_ID];
2223
if (context[CONTEXT_OUTPOST_ID]) {
2324
request.headers[OUTPOST_ID_HEADER] = context[CONTEXT_OUTPOST_ID];
2425
request.hostname = getOutpostEndpoint(request.hostname, {
25-
isCustomEndpoint: options.isCustomEndpoint,
26+
isCustomEndpoint,
2627
regionOverride: context[CONTEXT_ARN_REGION],
2728
});
2829
}

packages/middleware-sdk-s3-control/src/redirect-from-postid.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ describe("redirectFromPostIdMiddleware", () => {
66
it("should redirect request if Bucket is a valid ARN", async () => {
77
const next: any = (args: any) => ({ output: args.request });
88
const context: any = {};
9-
const { output } = await redirectFromPostIdMiddleware(
10-
next,
11-
context
12-
)({
9+
const { output } = await redirectFromPostIdMiddleware({ isCustomEndpoint: false })(next, context)({
1310
input: { OutpostId: "op-123" },
1411
request: new HttpRequest({ hostname: "123456789012.s3-control.us-west-2.amazonaws.com" }),
1512
});

packages/middleware-sdk-s3-control/src/redirect-from-postid.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ type InputType = {
1313
* If OutpostId is set, redirect hostname to Outpost one, and change signing service to `s3-outposts`.
1414
* Applied to S3Control.CreateBucket and S3Control.ListRegionalBuckets
1515
*/
16-
export const redirectFromPostIdMiddleware = (options: S3ControlResolvedConfig): BuildMiddleware<InputType, any> => (
17-
next,
18-
context
19-
) => (args) => {
16+
export const redirectFromPostIdMiddleware = ({
17+
isCustomEndpoint,
18+
}: {
19+
isCustomEndpoint: boolean;
20+
}): BuildMiddleware<InputType, any> => (next, context) => (args) => {
2021
const { input, request } = args;
2122
if (!HttpRequest.isInstance(request)) return next(args);
2223
if (input.OutpostId) {
23-
request.hostname = getOutpostEndpoint(request.hostname);
24+
request.hostname = getOutpostEndpoint(request.hostname, { isCustomEndpoint });
2425
context[CONTEXT_SIGNING_SERVICE] = "s3-outposts";
2526
}
2627
return next(args);

0 commit comments

Comments
 (0)