mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
7981e23dcd604209ea07194f45b2e05ab4823886
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
724be0a6a7 |
fix(s3): return composite multipart checksums and match S3 on UploadPart, GetObjectAttributes and CopyObject responses (#3093)
* fix(s3): return composite checksums for multipart uploads CompleteMultipartUpload stored the checksum of the whole object but labelled it COMPOSITE, so clients that recompute the composite value from the part checksums, as the AWS documentation describes, never matched it. Follow the AWS checksum type rules, verified against real S3: - SHA1/SHA256 are always COMPOSITE, CRC32/CRC32C default to COMPOSITE and CRC64NVME is always FULL_OBJECT. x-amz-checksum-type on CreateMultipartUpload selects FULL_OBJECT for CRC32/CRC32C; incompatible combinations fail with InvalidRequest, and the response echoes x-amz-checksum-algorithm/-type. - The composite value is the algorithm applied to the concatenated binary part checksums, Base64 encoded, with a "-<part count>" suffix. It is returned by CompleteMultipartUpload, HeadObject and GetObject (with x-amz-checksum-type), while GetObjectAttributes omits the suffix, as AWS does. - A checksum sent on CompleteMultipartUpload is validated against the stored type: a mismatching value is a BadDigest (the composite is accepted with or without its suffix), a checksum type different from the one the upload was created with is an InvalidRequest, per-part checksums in the request body that do not match the uploaded parts are an InvalidPart, and a COMPOSITE upload completed without the checksum of every part is an InvalidRequest (FULL_OBJECT uploads need none, as on S3). A non-numeric PartNumber is a MalformedXML instead of a 500. - UploadPart echoes the part checksum (x-amz-checksum-<algorithm>) when the upload declared an algorithm, as S3 does; without one no header is returned. - CopyObject writes a single object without a part manifest; a composite source gets a full-object checksum recomputed with its algorithm, and CopyObjectResult carries the checksum elements, matching AWS. - GetObjectAttributes lists part-level checksums only for COMPOSITE objects: a FULL_OBJECT multipart object reports its PartsCount alone and a single-part object has no ObjectParts element. The algorithm and type rules live in two new enums, ChecksumAlgorithm and ChecksumType, parsed once from the request headers; S3Checksum builds the full-object, composite and GetObjectAttributes views of a checksum. The boto3 compatibility suite gains multipart upload_file cases for SHA256 and for the SDK's default CRC32, asserting the composite value and the part list. The S3 docs drop the stale note that checksum responses focus on SHA-1 and SHA-256 (CRC32, CRC32C and CRC64NVME have been supported since #877) and list the AWS algorithms Floci rejects. * fix(s3): return the GetObjectAttributes ETag without quotes S3 returns the ETag element of GetObjectAttributes without the surrounding quotes that HeadObject, ListParts and CompleteMultipartUpload keep. Verified against real S3 with the same object: head_object gives "af3c...-3" while get_object_attributes gives af3c...-3, and the AWS CLI reference shows the same in its get-object-attributes example. Floci echoed the quoted value, so a client comparing both saw different strings on Floci and equal ones nowhere. * fix(s3): give a copied object its own ETag CopyObject kept the ETag of the source, so the copy of a multipart object carried the "<md5-of-md5s>-N" value of its parts. S3 writes a copy as a single object and returns the MD5 of the whole content as its ETag, in CopyObjectResult and HeadObject alike (verified against real S3: source "af3c...-3", copy "a5f04f..."). The copy now keeps the ETag storeObject computes. * fix(s3): send CopyObjectResult as application/xml The CopyObject response carried Content-Type: text/plain;charset=UTF-8 for an XML body. S3 labels it application/xml like every other XML response. * test(s3): cover multipart checksums in every SDK compatibility suite Each SDK implements flexible checksums differently, so the multipart flows are exercised per client rather than once: the Go transfer manager (what terraform-provider-aws uses), @aws-sdk/lib-storage for Node, the Java SDK v2 both low-level and through S3TransferManager on the multipart-enabled async client, the AWS CLI (s3api, aws s3 cp --checksum-algorithm and a plain aws s3 cp that goes multipart on its own) and boto3. Every case asserts the composite or full-object value computed in the test itself, the UploadPart echo, the suffix-less GetObjectAttributes checksum and unquoted ETag, the rejected Complete without part checksums, and the copy of a multipart object as a single full object with its own ETag. The default algorithm cases accept whatever the SDK version declares (CRC32 composite or full object, or none) and check the stored value against it. * test(terraform): upload a large aws_s3_object with Terraform and OpenTofu The IaC suites created buckets but never an object, so the code path that surfaced the composite checksum bug, an aws_s3_object above the provider's part size uploaded through the SDK transfer manager, was not covered. Both suites now upload a 12 MiB file generated by the test setup with checksum_algorithm SHA256 and check that HeadObject reports a COMPOSITE checksum equal to the composite computed locally over the part sizes GetObjectAttributes lists, that the state attribute holds the same value, and that re-planning the object shows no drift. compat-opentofu moves to the same aws-cli image as compat-terraform (2.34.32): 2.15 predates the S3 checksum type and cannot show ChecksumType in its output. * fix(s3): reject x-amz-checksum-type without a checksum algorithm CreateMultipartUpload only parsed x-amz-checksum-type when an algorithm was declared, so a type sent on its own, valid or not, was silently ignored. S3 validates the header regardless: an unknown value is InvalidRequest "Value for x-amz-checksum-type header is invalid." and a valid one without an algorithm is InvalidRequest "The x-amz-checksum-type header can only be used with the x-amz-checksum-algorithm header." (both verified against real S3). * test(s3): log cleanup failures in the multipart checksum compat tests The Java, Node and Go cases swallowed errors while deleting their objects and bucket. They now report what could not be deleted and why, so a leftover is diagnosable instead of silent. --------- Co-authored-by: Mihai Blidaru <mihai.blidaru@lynxfctech.com> |
||
|
|
eeefb729c4 |
test: move compatibility tests into this repo (#225)
* test: move compatibility tests into this repo * fix: add StatisticValues parsing to CloudWatchMetricsJsonHandler * fix: add missing required abstract methods to EmulatorConfig in EventBridgeSchedulerIntegrationTest * test: add sdk tests for multipart S3 copy coverage * fix: cover and fix smithy cbor and multipart s3 copy regressions * test: migrate more test coverage to new folder * test: add missing ec2 expectation in healthcheck test * docs: update READMEs in `./compatibility-tests` |