Skip to content

Commit

Permalink
fix(middleware-flexible-checksums): use input from args and not middl…
Browse files Browse the repository at this point in the history
…eware config (#6677)
  • Loading branch information
trivikr authored Nov 19, 2024
1 parent ed4619e commit 199aad0
Show file tree
Hide file tree
Showing 27 changed files with 4 additions and 34 deletions.
1 change: 0 additions & 1 deletion clients/client-s3/src/commands/DeleteObjectsCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ export class DeleteObjectsCommand extends $Command
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
input: this.input,
requestAlgorithmMember: "ChecksumAlgorithm",
requestChecksumRequired: true,
}),
Expand Down
1 change: 0 additions & 1 deletion clients/client-s3/src/commands/GetObjectCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,6 @@ export class GetObjectCommand extends $Command
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
input: this.input,
requestChecksumRequired: false,
requestValidationModeMember: "ChecksumMode",
responseAlgorithms: ["CRC32", "CRC32C", "SHA256", "SHA1"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ export class PutBucketAccelerateConfigurationCommand extends $Command
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
input: this.input,
requestAlgorithmMember: "ChecksumAlgorithm",
requestChecksumRequired: false,
}),
Expand Down
1 change: 0 additions & 1 deletion clients/client-s3/src/commands/PutBucketAclCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ export class PutBucketAclCommand extends $Command
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
input: this.input,
requestAlgorithmMember: "ChecksumAlgorithm",
requestChecksumRequired: true,
}),
Expand Down
1 change: 0 additions & 1 deletion clients/client-s3/src/commands/PutBucketCorsCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ export class PutBucketCorsCommand extends $Command
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
input: this.input,
requestAlgorithmMember: "ChecksumAlgorithm",
requestChecksumRequired: true,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ export class PutBucketEncryptionCommand extends $Command
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
input: this.input,
requestAlgorithmMember: "ChecksumAlgorithm",
requestChecksumRequired: true,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ export class PutBucketLifecycleConfigurationCommand extends $Command
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
input: this.input,
requestAlgorithmMember: "ChecksumAlgorithm",
requestChecksumRequired: true,
}),
Expand Down
1 change: 0 additions & 1 deletion clients/client-s3/src/commands/PutBucketLoggingCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ export class PutBucketLoggingCommand extends $Command
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
input: this.input,
requestAlgorithmMember: "ChecksumAlgorithm",
requestChecksumRequired: true,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ export class PutBucketOwnershipControlsCommand extends $Command
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
input: this.input,
requestChecksumRequired: true,
}),
];
Expand Down
1 change: 0 additions & 1 deletion clients/client-s3/src/commands/PutBucketPolicyCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ export class PutBucketPolicyCommand extends $Command
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
input: this.input,
requestAlgorithmMember: "ChecksumAlgorithm",
requestChecksumRequired: true,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ export class PutBucketReplicationCommand extends $Command
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
input: this.input,
requestAlgorithmMember: "ChecksumAlgorithm",
requestChecksumRequired: true,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ export class PutBucketRequestPaymentCommand extends $Command
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
input: this.input,
requestAlgorithmMember: "ChecksumAlgorithm",
requestChecksumRequired: true,
}),
Expand Down
1 change: 0 additions & 1 deletion clients/client-s3/src/commands/PutBucketTaggingCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ export class PutBucketTaggingCommand extends $Command
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
input: this.input,
requestAlgorithmMember: "ChecksumAlgorithm",
requestChecksumRequired: true,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ export class PutBucketVersioningCommand extends $Command
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
input: this.input,
requestAlgorithmMember: "ChecksumAlgorithm",
requestChecksumRequired: true,
}),
Expand Down
1 change: 0 additions & 1 deletion clients/client-s3/src/commands/PutBucketWebsiteCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ export class PutBucketWebsiteCommand extends $Command
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
input: this.input,
requestAlgorithmMember: "ChecksumAlgorithm",
requestChecksumRequired: true,
}),
Expand Down
1 change: 0 additions & 1 deletion clients/client-s3/src/commands/PutObjectAclCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ export class PutObjectAclCommand extends $Command
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
input: this.input,
requestAlgorithmMember: "ChecksumAlgorithm",
requestChecksumRequired: true,
}),
Expand Down
1 change: 0 additions & 1 deletion clients/client-s3/src/commands/PutObjectCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,6 @@ export class PutObjectCommand extends $Command
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
input: this.input,
requestAlgorithmMember: "ChecksumAlgorithm",
requestChecksumRequired: false,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ export class PutObjectLegalHoldCommand extends $Command
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
input: this.input,
requestAlgorithmMember: "ChecksumAlgorithm",
requestChecksumRequired: true,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ export class PutObjectLockConfigurationCommand extends $Command
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
input: this.input,
requestAlgorithmMember: "ChecksumAlgorithm",
requestChecksumRequired: true,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ export class PutObjectRetentionCommand extends $Command
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
input: this.input,
requestAlgorithmMember: "ChecksumAlgorithm",
requestChecksumRequired: true,
}),
Expand Down
1 change: 0 additions & 1 deletion clients/client-s3/src/commands/PutObjectTaggingCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ export class PutObjectTaggingCommand extends $Command
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
input: this.input,
requestAlgorithmMember: "ChecksumAlgorithm",
requestChecksumRequired: true,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ export class PutPublicAccessBlockCommand extends $Command
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
input: this.input,
requestAlgorithmMember: "ChecksumAlgorithm",
requestChecksumRequired: true,
}),
Expand Down
1 change: 0 additions & 1 deletion clients/client-s3/src/commands/RestoreObjectCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,6 @@ export class RestoreObjectCommand extends $Command
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
input: this.input,
requestAlgorithmMember: "ChecksumAlgorithm",
requestChecksumRequired: false,
}),
Expand Down
1 change: 0 additions & 1 deletion clients/client-s3/src/commands/UploadPartCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ export class UploadPartCommand extends $Command
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
getFlexibleChecksumsPlugin(config, {
input: this.input,
requestAlgorithmMember: "ChecksumAlgorithm",
requestChecksumRequired: false,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.util.TreeMap;
import java.util.function.Consumer;
import software.amazon.smithy.aws.traits.HttpChecksumTrait;
import software.amazon.smithy.codegen.core.Symbol;
import software.amazon.smithy.codegen.core.SymbolProvider;
import software.amazon.smithy.model.Model;
import software.amazon.smithy.model.knowledge.TopDownIndex;
Expand Down Expand Up @@ -197,7 +196,6 @@ private static Map<String, Object> getPluginFunctionParams(
OperationShape operation
) {
Map<String, Object> params = new TreeMap<String, Object>();
params.put("input", Symbol.builder().name("this.input").build());

HttpChecksumTrait httpChecksumTrait = operation.expectTrait(HttpChecksumTrait.class);
params.put("requestChecksumRequired", httpChecksumTrait.isRequestChecksumRequired());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ describe(flexibleChecksumsMiddleware.name, () => {

const mockInput = {};
const mockConfig = {} as PreviouslyResolved;
const mockMiddlewareConfig = { input: mockInput, requestChecksumRequired: false };
const mockMiddlewareConfig = { requestChecksumRequired: false };

const mockBody = { body: "mockRequestBody" };
const mockHeaders = { "content-length": 100, "content-encoding": "gzip" };
const mockRequest = { body: mockBody, headers: mockHeaders };
const mockArgs = { request: mockRequest } as BuildHandlerArguments<any>;
const mockArgs = { input: mockInput, request: mockRequest } as BuildHandlerArguments<any>;
const mockResult = { response: { body: "mockResponsebody" } };

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ import { stringHasher } from "./stringHasher";

export interface FlexibleChecksumsRequestMiddlewareConfig {
/**
* The input object for the operation.
*/
input: Object;

/**
* Indicates an operation requires a checksum in its HTTP request.
*/
Expand Down Expand Up @@ -57,10 +53,10 @@ export const flexibleChecksumsMiddleware =
return next(args);
}

const { request } = args;
const { request, input } = args;
const { body: requestBody, headers } = request;
const { base64Encoder, streamHasher } = config;
const { input, requestChecksumRequired, requestAlgorithmMember } = middlewareConfig;
const { requestChecksumRequired, requestAlgorithmMember } = middlewareConfig;

const checksumAlgorithm = getChecksumAlgorithmForRequest(
input,
Expand Down

0 comments on commit 199aad0

Please sign in to comment.