mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
Fix(s3)/1560 fix copy object (#1670)
* fix(s3): add support for S3 CopyObject operation and multipart uploads * fix(s3): correct checksum type when copying multipart objects in S3 * fix(s3): validate checksum algorithms and support standard header fallbacks * fix(s3): handle integration tests * fix(s3): return InvalidRequest for valid but unsupported checksum algorithms
This commit is contained in:
1 parent
2288da7f23
commit
caacbc8afa
6 files changed
+273
-110
No files matched your search
@@ -194,6 +194,7 @@ class S3IntegrationTest {
|
||||
.header("x-amz-metadata-directive", "REPLACE")
|
||||
.header("x-amz-meta-owner", "team-b")
|
||||
.header("x-amz-storage-class", "GLACIER")
|
||||
.header("x-amz-checksum-algorithm", "SHA256")
|
||||
.contentType("application/json")
|
||||
.when()
|
||||
.put("/test-bucket/greeting-copy.txt")
|
||||
@@ -209,11 +210,104 @@ class S3IntegrationTest {
|
||||
.statusCode(200)
|
||||
.header("x-amz-meta-owner", equalTo("team-b"))
|
||||
.header("x-amz-storage-class", equalTo("GLACIER"))
|
||||
.header("x-amz-checksum-sha256", notNullValue())
|
||||
.body(equalTo("Hello World from S3!"));
|
||||
|
||||
// Verify GetObjectAttributes returns the overridden checksum algorithm
|
||||
given()
|
||||
.header("x-amz-object-attributes", "Checksum")
|
||||
.when()
|
||||
.get("/test-bucket/greeting-copy.txt?attributes")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("<GetObjectAttributesResponse"))
|
||||
.body(containsString("<ChecksumSHA256>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(14)
|
||||
void copyObjectWithoutChecksumOverride() {
|
||||
given()
|
||||
.header("x-amz-copy-source", "/test-bucket/greeting.txt")
|
||||
.header("x-amz-metadata-directive", "REPLACE")
|
||||
.header("x-amz-meta-owner", "team-b")
|
||||
.header("x-amz-storage-class", "GLACIER")
|
||||
.contentType("application/json")
|
||||
.when()
|
||||
.put("/test-bucket/greeting-copy-no-override.txt")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("CopyObjectResult"));
|
||||
|
||||
// Verify the copy inherits the source checksum (CRC64NVME)
|
||||
given()
|
||||
.when()
|
||||
.get("/test-bucket/greeting-copy-no-override.txt")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.header("x-amz-meta-owner", equalTo("team-b"))
|
||||
.header("x-amz-storage-class", equalTo("GLACIER"))
|
||||
.header("x-amz-checksum-crc64nvme", notNullValue())
|
||||
.header("x-amz-checksum-sha256", nullValue())
|
||||
.body(equalTo("Hello World from S3!"));
|
||||
|
||||
// Clean up
|
||||
given()
|
||||
.when()
|
||||
.delete("/test-bucket/greeting-copy-no-override.txt")
|
||||
.then()
|
||||
.statusCode(204);
|
||||
}
|
||||
@Test
|
||||
@Order(15)
|
||||
void copyObjectPreservesNonDefaultChecksum() {
|
||||
// Put an object with a non-default checksum algorithm (SHA256 instead of CRC64NVME)
|
||||
given()
|
||||
.contentType("text/plain")
|
||||
.header("x-amz-sdk-checksum-algorithm", "SHA256")
|
||||
.body("Non-default checksum data")
|
||||
.when()
|
||||
.put("/test-bucket/sha256-source.txt")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.header("ETag", notNullValue());
|
||||
|
||||
// Verify the source object has a SHA256 checksum
|
||||
given()
|
||||
.when()
|
||||
.get("/test-bucket/sha256-source.txt")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.header("x-amz-checksum-sha256", notNullValue())
|
||||
.header("x-amz-checksum-crc64nvme", nullValue())
|
||||
.body(equalTo("Non-default checksum data"));
|
||||
|
||||
// Copy WITHOUT specifying x-amz-checksum-algorithm — should preserve SHA256
|
||||
given()
|
||||
.header("x-amz-copy-source", "/test-bucket/sha256-source.txt")
|
||||
.when()
|
||||
.put("/test-bucket/sha256-copy.txt")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("CopyObjectResult"));
|
||||
|
||||
// Verify the copy preserves the source's SHA256 checksum
|
||||
given()
|
||||
.when()
|
||||
.get("/test-bucket/sha256-copy.txt")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.header("x-amz-checksum-sha256", notNullValue())
|
||||
.header("x-amz-checksum-crc64nvme", nullValue())
|
||||
.body(equalTo("Non-default checksum data"));
|
||||
|
||||
// Clean up
|
||||
given().when().delete("/test-bucket/sha256-source.txt").then().statusCode(204);
|
||||
given().when().delete("/test-bucket/sha256-copy.txt").then().statusCode(204);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(16)
|
||||
void deleteObject() {
|
||||
given()
|
||||
.when()
|
||||
@@ -230,7 +324,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(15)
|
||||
@Order(17)
|
||||
void deleteNonEmptyBucketFails() {
|
||||
given()
|
||||
.when()
|
||||
@@ -241,7 +335,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(15)
|
||||
@Order(18)
|
||||
void getObjectAttributesRejectsUnknownSelector() {
|
||||
given()
|
||||
.header("x-amz-object-attributes", "ETag,UnknownThing")
|
||||
@@ -253,7 +347,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(16)
|
||||
@Order(19)
|
||||
void getNonExistentBucket() {
|
||||
given()
|
||||
.when()
|
||||
@@ -264,7 +358,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(17)
|
||||
@Order(20)
|
||||
void headBucketReturnsStoredRegionForLocationConstraintBucket() {
|
||||
String bucket = "eu-head-bucket";
|
||||
String createBucketConfiguration = """
|
||||
@@ -297,7 +391,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(18)
|
||||
@Order(21)
|
||||
void createBucketUsesSigningRegionWhenBodyEmpty() {
|
||||
String bucket = "signed-region-bucket";
|
||||
|
||||
@@ -325,7 +419,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(19)
|
||||
@Order(22)
|
||||
void createBucketRejectsUsEast1LocationConstraint() {
|
||||
String createBucketConfiguration = """
|
||||
<CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
||||
@@ -344,7 +438,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(20)
|
||||
@Order(23)
|
||||
void copyObjectWithNonAsciiKeySucceeds() {
|
||||
String bucket = "copy-nonascii-bucket";
|
||||
String srcKey = "src/テスト画像.png";
|
||||
@@ -382,7 +476,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(21)
|
||||
@Order(24)
|
||||
void copyObjectWithMalformedEncodedSourceReturns400() {
|
||||
given()
|
||||
.header("x-amz-copy-source", "/test-bucket/%ZZinvalid")
|
||||
@@ -394,7 +488,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(22)
|
||||
@Order(25)
|
||||
void copyObjectWithEmptyBucketReturns400() {
|
||||
given()
|
||||
.header("x-amz-copy-source", "/key-only-no-bucket")
|
||||
@@ -406,7 +500,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(21)
|
||||
@Order(26)
|
||||
void putLargeObject() {
|
||||
// 22 MB – exceeds the old Jackson 20 MB maxStringLength default
|
||||
byte[] largeBody = new byte[22 * 1024 * 1024];
|
||||
@@ -439,7 +533,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(30)
|
||||
@Order(27)
|
||||
void getObjectWithFullRange() {
|
||||
given()
|
||||
.header("Range", "bytes=0-4")
|
||||
@@ -454,7 +548,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(31)
|
||||
@Order(28)
|
||||
void getObjectWithOpenEndedRange() {
|
||||
given()
|
||||
.header("Range", "bytes=15-")
|
||||
@@ -467,7 +561,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(32)
|
||||
@Order(29)
|
||||
void getObjectWithSuffixRange() {
|
||||
given()
|
||||
.header("Range", "bytes=-4")
|
||||
@@ -480,7 +574,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(33)
|
||||
@Order(30)
|
||||
void getObjectWithInvalidRange() {
|
||||
given()
|
||||
.header("Range", "bytes=50-100")
|
||||
@@ -493,7 +587,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(34)
|
||||
@Order(31)
|
||||
void getObjectWithMalformedRangeNoDash() {
|
||||
given()
|
||||
.header("Range", "bytes=0")
|
||||
@@ -505,7 +599,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(35)
|
||||
@Order(32)
|
||||
void getObjectWithMalformedRangeEmptySuffix() {
|
||||
given()
|
||||
.header("Range", "bytes=-")
|
||||
@@ -517,7 +611,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(36)
|
||||
@Order(33)
|
||||
void getObjectWithMalformedRangeNonNumeric() {
|
||||
given()
|
||||
.header("Range", "bytes=abc-def")
|
||||
@@ -529,7 +623,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(37)
|
||||
@Order(34)
|
||||
void getObjectWithMalformedRangeNegativeStart() {
|
||||
given()
|
||||
.header("Range", "bytes=-1-4")
|
||||
@@ -541,7 +635,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(38)
|
||||
@Order(35)
|
||||
void getObjectWithoutRangeReturnsAcceptRanges() {
|
||||
given()
|
||||
.when()
|
||||
@@ -552,7 +646,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(39)
|
||||
@Order(36)
|
||||
void headObjectReturnsAcceptRanges() {
|
||||
given()
|
||||
.when()
|
||||
@@ -563,7 +657,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(40)
|
||||
@Order(37)
|
||||
void getObjectRangeOmitsWholeObjectChecksum() {
|
||||
// greeting.txt has a stored whole-object CRC64NVME checksum (see getObject).
|
||||
// A 206 partial response must NOT carry that checksum: it is computed over the
|
||||
@@ -581,7 +675,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(41)
|
||||
@Order(38)
|
||||
void getObjectWithSuffixRangeForEmptyObject() {
|
||||
given()
|
||||
.header("x-amz-meta-kind", "empty")
|
||||
@@ -610,7 +704,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(42)
|
||||
@Order(39)
|
||||
void getObjectRangeStreamsExactBytesFromLargeObject() {
|
||||
String bucket = "stream-range-bucket";
|
||||
String key = "large-range.txt";
|
||||
@@ -651,7 +745,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(50)
|
||||
@Order(40)
|
||||
void getObjectIfNoneMatchReturns304() {
|
||||
String eTag = given()
|
||||
.when().head("/test-bucket/greeting.txt")
|
||||
@@ -668,7 +762,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(51)
|
||||
@Order(41)
|
||||
void getObjectIfNoneMatchNonMatchingReturns200() {
|
||||
given()
|
||||
.header("If-None-Match", "\"wrong-etag\"")
|
||||
@@ -680,7 +774,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(52)
|
||||
@Order(42)
|
||||
void getObjectIfMatchReturns200() {
|
||||
String eTag = given()
|
||||
.when().head("/test-bucket/greeting.txt")
|
||||
@@ -697,7 +791,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(53)
|
||||
@Order(43)
|
||||
void getObjectIfMatchWrongEtagReturns412() {
|
||||
given()
|
||||
.header("If-Match", "\"wrong-etag\"")
|
||||
@@ -709,7 +803,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(54)
|
||||
@Order(44)
|
||||
void headObjectIfNoneMatchReturns304() {
|
||||
String eTag = given()
|
||||
.when().head("/test-bucket/greeting.txt")
|
||||
@@ -725,7 +819,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(55)
|
||||
@Order(45)
|
||||
void headObjectIfMatchReturns200() {
|
||||
String eTag = given()
|
||||
.when().head("/test-bucket/greeting.txt")
|
||||
@@ -741,7 +835,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(56)
|
||||
@Order(46)
|
||||
void headObjectIfMatchWrongEtagReturns412() {
|
||||
given()
|
||||
.header("If-Match", "\"wrong-etag\"")
|
||||
@@ -752,7 +846,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(57)
|
||||
@Order(47)
|
||||
void headObjectIfModifiedSinceReturns304() {
|
||||
given()
|
||||
.header("If-Modified-Since", "Sun, 24 Mar 2030 00:00:00 GMT")
|
||||
@@ -763,7 +857,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(58)
|
||||
@Order(48)
|
||||
void headObjectIfUnmodifiedSinceReturns412() {
|
||||
given()
|
||||
.header("If-Unmodified-Since", "Tue, 24 Mar 2020 00:00:00 GMT")
|
||||
@@ -774,7 +868,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(61)
|
||||
@Order(49)
|
||||
void getObjectIfModifiedSinceReturns304() {
|
||||
given()
|
||||
.header("If-Modified-Since", "Sun, 24 Mar 2030 00:00:00 GMT")
|
||||
@@ -785,7 +879,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(62)
|
||||
@Order(50)
|
||||
void getObjectIfUnmodifiedSinceReturns412() {
|
||||
given()
|
||||
.header("If-Unmodified-Since", "Tue, 24 Mar 2020 00:00:00 GMT")
|
||||
@@ -797,7 +891,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(63)
|
||||
@Order(51)
|
||||
void getObjectIfMatchWildcardReturns200() {
|
||||
given()
|
||||
.header("If-Match", "*")
|
||||
@@ -809,7 +903,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(64)
|
||||
@Order(52)
|
||||
void getObjectIfNoneMatchCommaListReturns304() {
|
||||
String eTag = given()
|
||||
.when().head("/test-bucket/greeting.txt")
|
||||
@@ -825,7 +919,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(65)
|
||||
@Order(53)
|
||||
void ifNoneMatchTakesPrecedenceOverIfModifiedSince() {
|
||||
String eTag = given()
|
||||
.when().head("/test-bucket/greeting.txt")
|
||||
@@ -842,7 +936,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(66)
|
||||
@Order(54)
|
||||
void notModifiedResponseIncludesLastModified() {
|
||||
String eTag = given()
|
||||
.when().head("/test-bucket/greeting.txt")
|
||||
@@ -860,7 +954,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(70)
|
||||
@Order(55)
|
||||
void cleanupAndDeleteBucket() {
|
||||
// Delete all objects
|
||||
given().delete("/test-bucket/greeting.txt");
|
||||
@@ -875,7 +969,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(80)
|
||||
@Order(56)
|
||||
void createEncodingTestBucket() {
|
||||
given()
|
||||
.when()
|
||||
@@ -885,7 +979,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(81)
|
||||
@Order(57)
|
||||
void putObjectWithContentEncoding() {
|
||||
given()
|
||||
.contentType("text/plain")
|
||||
@@ -902,7 +996,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(82)
|
||||
@Order(58)
|
||||
void getObjectReturnsContentEncoding() {
|
||||
RestAssuredConfig noDecompress = RestAssuredConfig.config()
|
||||
.decoderConfig(DecoderConfig.decoderConfig().noContentDecoders());
|
||||
@@ -916,7 +1010,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(83)
|
||||
@Order(59)
|
||||
void headObjectReturnsContentEncoding() {
|
||||
given()
|
||||
.when()
|
||||
@@ -927,7 +1021,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(84)
|
||||
@Order(60)
|
||||
void copyObjectPreservesContentEncoding() {
|
||||
given()
|
||||
.header("x-amz-copy-source", "/encoding-test-bucket/encoded.txt")
|
||||
@@ -946,7 +1040,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(85)
|
||||
@Order(61)
|
||||
void copyObjectReplaceContentEncoding() {
|
||||
given()
|
||||
.header("x-amz-copy-source", "/encoding-test-bucket/encoded.txt")
|
||||
@@ -967,7 +1061,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(86)
|
||||
@Order(62)
|
||||
void putObjectWithCompositeEncoding_stripsAwsChunkedToken() {
|
||||
RestAssuredConfig noDecompress = RestAssuredConfig.config()
|
||||
.decoderConfig(DecoderConfig.decoderConfig().noContentDecoders());
|
||||
@@ -990,7 +1084,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(88)
|
||||
@Order(63)
|
||||
void cleanupContentEncodingBucket() {
|
||||
given().delete("/encoding-test-bucket/encoded.txt");
|
||||
given().delete("/encoding-test-bucket/encoded-copy.txt");
|
||||
@@ -1002,7 +1096,7 @@ class S3IntegrationTest {
|
||||
// --- Cache-Control header preservation ---
|
||||
|
||||
@Test
|
||||
@Order(89)
|
||||
@Order(64)
|
||||
void createCacheControlBucketAndPutObject() {
|
||||
given()
|
||||
.put("/cache-control-bucket")
|
||||
@@ -1021,7 +1115,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(90)
|
||||
@Order(65)
|
||||
void getObjectReturnsCacheControl() {
|
||||
given()
|
||||
.when()
|
||||
@@ -1032,7 +1126,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(90)
|
||||
@Order(66)
|
||||
void headObjectReturnsCacheControl() {
|
||||
given()
|
||||
.when()
|
||||
@@ -1043,7 +1137,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(91)
|
||||
@Order(67)
|
||||
void copyObjectPreservesCacheControl() {
|
||||
given()
|
||||
.header("x-amz-copy-source", "/cache-control-bucket/cached.txt")
|
||||
@@ -1062,7 +1156,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(91)
|
||||
@Order(68)
|
||||
void copyObjectReplaceCacheControl() {
|
||||
given()
|
||||
.header("x-amz-copy-source", "/cache-control-bucket/cached.txt")
|
||||
@@ -1083,7 +1177,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(92)
|
||||
@Order(69)
|
||||
void cleanupCacheControlBucket() {
|
||||
given().delete("/cache-control-bucket/cached.txt");
|
||||
given().delete("/cache-control-bucket/cached-copy.txt");
|
||||
@@ -1094,7 +1188,7 @@ class S3IntegrationTest {
|
||||
// --- Content-Disposition header preservation ---
|
||||
|
||||
@Test
|
||||
@Order(130)
|
||||
@Order(70)
|
||||
void createContentDispositionBucketAndPutObject() {
|
||||
String disposition = "attachment; filename=\"download.txt\"";
|
||||
|
||||
@@ -1115,7 +1209,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(131)
|
||||
@Order(71)
|
||||
void getObjectReturnsContentDisposition() {
|
||||
given()
|
||||
.when()
|
||||
@@ -1126,7 +1220,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(132)
|
||||
@Order(72)
|
||||
void headObjectReturnsContentDisposition() {
|
||||
given()
|
||||
.when()
|
||||
@@ -1137,7 +1231,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(133)
|
||||
@Order(73)
|
||||
void copyObjectPreservesContentDisposition() {
|
||||
given()
|
||||
.header("x-amz-copy-source", "/content-disposition-bucket/disposition.txt")
|
||||
@@ -1156,7 +1250,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(134)
|
||||
@Order(74)
|
||||
void copyObjectReplaceContentDisposition() {
|
||||
given()
|
||||
.header("x-amz-copy-source", "/content-disposition-bucket/disposition.txt")
|
||||
@@ -1177,7 +1271,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(135)
|
||||
@Order(75)
|
||||
void cleanupContentDispositionBucket() {
|
||||
given().delete("/content-disposition-bucket/disposition.txt");
|
||||
given().delete("/content-disposition-bucket/disposition-copy.txt");
|
||||
@@ -1188,7 +1282,7 @@ class S3IntegrationTest {
|
||||
// --- Server-Side Encryption header preservation ---
|
||||
|
||||
@Test
|
||||
@Order(136)
|
||||
@Order(76)
|
||||
void createSseBucketAndPutObject() {
|
||||
given()
|
||||
.put("/sse-bucket")
|
||||
@@ -1208,7 +1302,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(137)
|
||||
@Order(77)
|
||||
void getObjectReturnsServerSideEncryption() {
|
||||
given()
|
||||
.when()
|
||||
@@ -1219,7 +1313,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(138)
|
||||
@Order(78)
|
||||
void headObjectReturnsServerSideEncryption() {
|
||||
given()
|
||||
.when()
|
||||
@@ -1230,7 +1324,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(139)
|
||||
@Order(79)
|
||||
void copyObjectPreservesServerSideEncryption() {
|
||||
given()
|
||||
.header("x-amz-copy-source", "/sse-bucket/encrypted.txt")
|
||||
@@ -1249,7 +1343,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(140)
|
||||
@Order(80)
|
||||
void putObjectRejectsUnsupportedServerSideEncryption() {
|
||||
given()
|
||||
.contentType("text/plain")
|
||||
@@ -1264,7 +1358,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(141)
|
||||
@Order(81)
|
||||
void putObjectWithSseCustomerKey() {
|
||||
given()
|
||||
.contentType("text/plain")
|
||||
@@ -1281,7 +1375,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(142)
|
||||
@Order(82)
|
||||
void getObjectWithSseCustomerKeyRequiresMatchingKey() {
|
||||
given()
|
||||
.when()
|
||||
@@ -1314,7 +1408,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(143)
|
||||
@Order(83)
|
||||
void headObjectWithSseCustomerKeyRequiresMatchingKey() {
|
||||
given()
|
||||
.when()
|
||||
@@ -1335,7 +1429,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(144)
|
||||
@Order(84)
|
||||
void copyObjectWithSseCustomerKeyRequiresSourceKeyAndSupportsDestinationKey() {
|
||||
given()
|
||||
.header("x-amz-copy-source", "/sse-bucket/sse-c.txt")
|
||||
@@ -1390,7 +1484,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(145)
|
||||
@Order(85)
|
||||
void putObjectRejectsInvalidSseCustomerKeyMd5() {
|
||||
given()
|
||||
.contentType("text/plain")
|
||||
@@ -1406,7 +1500,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(146)
|
||||
@Order(86)
|
||||
void putObjectRejectsUnsupportedSseCustomerAlgorithm() {
|
||||
given()
|
||||
.contentType("text/plain")
|
||||
@@ -1423,7 +1517,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(147)
|
||||
@Order(87)
|
||||
void putObjectRejectsInvalidSseCustomerKeyBase64() {
|
||||
given()
|
||||
.contentType("text/plain")
|
||||
@@ -1440,7 +1534,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(148)
|
||||
@Order(88)
|
||||
void putObjectRejectsInvalidSseCustomerKeyLength() {
|
||||
given()
|
||||
.contentType("text/plain")
|
||||
@@ -1457,7 +1551,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(149)
|
||||
@Order(89)
|
||||
void putObjectRejectsConflictingServerSideEncryption() {
|
||||
given()
|
||||
.contentType("text/plain")
|
||||
@@ -1475,7 +1569,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(153)
|
||||
@Order(90)
|
||||
void cleanupSseBucket() {
|
||||
given().delete("/sse-bucket/encrypted.txt");
|
||||
given().delete("/sse-bucket/encrypted-copy.txt");
|
||||
@@ -1487,7 +1581,7 @@ class S3IntegrationTest {
|
||||
// --- S3 Notification Configuration with Filter ---
|
||||
|
||||
@Test
|
||||
@Order(90)
|
||||
@Order(91)
|
||||
void createNotificationBucket() {
|
||||
given()
|
||||
.when()
|
||||
@@ -1497,7 +1591,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(91)
|
||||
@Order(92)
|
||||
void putNotificationConfigWithFilterIsNotDropped() {
|
||||
String xml = """
|
||||
<NotificationConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
||||
@@ -1543,7 +1637,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(92)
|
||||
@Order(93)
|
||||
void putNotificationConfigWithFilterBeforeQueueIsNotDropped() {
|
||||
// Filter appears BEFORE Queue — ensures element order doesn't matter
|
||||
String xml = """
|
||||
@@ -1587,7 +1681,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(93)
|
||||
@Order(94)
|
||||
void putLambdaNotificationConfigWithFilterIsPersisted() {
|
||||
String xml = """
|
||||
<NotificationConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
||||
@@ -1636,7 +1730,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(94)
|
||||
@Order(95)
|
||||
void notificationDeliveredToQueueInDifferentRegion() {
|
||||
String sqsAuth = "Credential=AKID/20260507/ap-southeast-2/s3/aws4_request";
|
||||
|
||||
@@ -1702,7 +1796,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(95)
|
||||
@Order(96)
|
||||
void cleanupNotificationBucket() {
|
||||
given().delete("/notif-test-bucket");
|
||||
}
|
||||
@@ -1710,7 +1804,7 @@ class S3IntegrationTest {
|
||||
// --- PublicAccessBlock ---
|
||||
|
||||
@Test
|
||||
@Order(100)
|
||||
@Order(97)
|
||||
void putPublicAccessBlockReturns200() {
|
||||
given().when().put("/test-bucket").then().statusCode(anyOf(equalTo(200), equalTo(409)));
|
||||
|
||||
@@ -1729,7 +1823,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(101)
|
||||
@Order(98)
|
||||
void getPublicAccessBlockReturnsStoredConfig() {
|
||||
given()
|
||||
.when()
|
||||
@@ -1741,7 +1835,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(102)
|
||||
@Order(99)
|
||||
void deletePublicAccessBlockReturns204() {
|
||||
given()
|
||||
.when()
|
||||
@@ -1751,7 +1845,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(103)
|
||||
@Order(100)
|
||||
void getPublicAccessBlockAfterDeleteReturns404() {
|
||||
given()
|
||||
.when()
|
||||
@@ -1764,7 +1858,7 @@ class S3IntegrationTest {
|
||||
// --- ListObjectsV2 pagination ---
|
||||
|
||||
@Test
|
||||
@Order(110)
|
||||
@Order(101)
|
||||
void listObjectsV2StartAfterFiltersResults() {
|
||||
// bucket and objects from earlier test orders exist; add fresh ones in a dedicated bucket
|
||||
given().when().put("/pag-test-bucket").then().statusCode(200);
|
||||
@@ -1784,7 +1878,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(111)
|
||||
@Order(102)
|
||||
void listObjectsV2ContinuationTokenPaginates() {
|
||||
// First page: max-keys=2
|
||||
String page1Body =
|
||||
@@ -1814,7 +1908,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(112)
|
||||
@Order(103)
|
||||
void listObjectsV2EncodingTypeIsEchoed() {
|
||||
given()
|
||||
.when()
|
||||
@@ -1825,7 +1919,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(113)
|
||||
@Order(104)
|
||||
void cleanupPaginationBucket() {
|
||||
given().when().delete("/pag-test-bucket/a.txt");
|
||||
given().when().delete("/pag-test-bucket/b.txt");
|
||||
@@ -1834,7 +1928,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(120)
|
||||
@Order(105)
|
||||
void getBucketLocation_usEast1ReturnsEmptyLocationConstraint() {
|
||||
String bucket = "location-us-east-1-bucket";
|
||||
|
||||
@@ -1857,7 +1951,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(121)
|
||||
@Order(106)
|
||||
void getBucketLocation_nonUsEast1ReturnsRegionInBody() {
|
||||
String bucket = "location-eu-central-bucket";
|
||||
String createBucketConfiguration = """
|
||||
@@ -1921,7 +2015,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(150)
|
||||
@Order(107)
|
||||
void putObjectRejectsMismatchedCRC32() {
|
||||
given()
|
||||
.body("hello")
|
||||
@@ -1934,7 +2028,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(151)
|
||||
@Order(108)
|
||||
void putObjectRejectsMismatchedCRC32C() {
|
||||
given()
|
||||
.body("hello")
|
||||
@@ -1947,7 +2041,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(152)
|
||||
@Order(109)
|
||||
void putObjectRejectsMismatchedCRC64NVME() {
|
||||
given()
|
||||
.body("hello")
|
||||
@@ -1960,7 +2054,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(200)
|
||||
@Order(110)
|
||||
void putObjectWithRawTraversalAboveBucketReturnsBadRequest() {
|
||||
given()
|
||||
.contentType("text/plain")
|
||||
@@ -1973,7 +2067,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(201)
|
||||
@Order(111)
|
||||
void putObjectWithEncodedTraversalAboveBucketReturnsBadRequest() {
|
||||
given()
|
||||
.urlEncodingEnabled(false)
|
||||
@@ -1987,7 +2081,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(202)
|
||||
@Order(112)
|
||||
void putObjectWithEncodedSlashTraversalAboveBucketReturnsBadRequest() {
|
||||
given()
|
||||
.urlEncodingEnabled(false)
|
||||
@@ -2001,7 +2095,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(203)
|
||||
@Order(113)
|
||||
void putObjectWithInternalTraversalSucceeds() {
|
||||
given()
|
||||
.urlEncodingEnabled(false)
|
||||
@@ -2022,7 +2116,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(204)
|
||||
@Order(114)
|
||||
void listObjectsAllowsTraversalInQueryString() {
|
||||
given()
|
||||
.urlEncodingEnabled(false)
|
||||
@@ -2034,7 +2128,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(205)
|
||||
@Order(115)
|
||||
void putObjectWithTraversalAfterBucketPrefixReturnsBadRequest() {
|
||||
given()
|
||||
.contentType("text/plain")
|
||||
@@ -2047,7 +2141,7 @@ class S3IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(206)
|
||||
@Order(116)
|
||||
void bucketLogging_roundTripAndDisable() {
|
||||
String bucket = "bucket-logging-test";
|
||||
String targetBucket = "bucket-logging-target";
|
||||
@@ -2113,6 +2207,32 @@ class S3IntegrationTest {
|
||||
.body(not(containsString("LoggingEnabled")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(117)
|
||||
void putObjectRejectsUnsupportedOrInvalidChecksumAlgorithms() {
|
||||
// 1. Valid but unsupported AWS checksum algorithm (SHA512) -> should return 400 InvalidRequest
|
||||
given()
|
||||
.body("hello")
|
||||
.header("x-amz-checksum-algorithm", "SHA512")
|
||||
.when()
|
||||
.put("/test-bucket/checksum-sha512-test.txt")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body(containsString("InvalidRequest"))
|
||||
.body(containsString("The checksum algorithm you specified is a valid AWS checksum algorithm, but is not currently supported by Floci"));
|
||||
|
||||
// 2. Completely invalid checksum algorithm (FOO) -> should return 400 InvalidArgument
|
||||
given()
|
||||
.body("hello")
|
||||
.header("x-amz-checksum-algorithm", "FOO")
|
||||
.when()
|
||||
.put("/test-bucket/checksum-foo-test.txt")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body(containsString("InvalidArgument"))
|
||||
.body(containsString("The checksum algorithm you specified is not supported."));
|
||||
}
|
||||
|
||||
private static String customerKeyMd5(String customerKey) {
|
||||
try {
|
||||
byte[] md5 = MessageDigest.getInstance("MD5").digest(Base64.getDecoder().decode(customerKey));
|
||||
|
||||
+2
-1
@@ -43,6 +43,7 @@ class S3MultipartIntegrationTest {
|
||||
.header("x-amz-storage-class", "STANDARD_IA")
|
||||
.header("Content-Disposition", "attachment; filename=\"multipart.bin\"")
|
||||
.header("x-amz-server-side-encryption", "AES256")
|
||||
.header("x-amz-checksum-algorithm", "SHA256")
|
||||
.when()
|
||||
.post("/" + BUCKET + "/" + KEY + "?uploads")
|
||||
.then()
|
||||
@@ -157,7 +158,7 @@ class S3MultipartIntegrationTest {
|
||||
.body(containsString("<StorageClass>STANDARD_IA</StorageClass>"))
|
||||
.body(containsString("<ObjectParts>"))
|
||||
.body(containsString("<PartsCount>2</PartsCount>"))
|
||||
.body(containsString("<ChecksumCRC64NVME>"));
|
||||
.body(containsString("<ChecksumSHA256>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user