mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(s3): return correct checksum algorithm on PutObject (#877)
* fix(s3): return correct checksum algorithm on PutObject * fix(s3): use client-provided checksum header when present * fix(s3): use correct reflected polynomial for CRC64NVME checksum * fix(s3): validate CRC32, CRC32C and CRC64NVME client-provided checksums
This commit is contained in:
1 parent
371dd02404
commit
e1fa8ae8c7
8 files changed
+175
-14
No files matched your search
@@ -77,7 +77,7 @@ class S3IntegrationTest {
|
||||
.header("Content-Length", notNullValue())
|
||||
.header("x-amz-meta-owner", equalTo("team-a"))
|
||||
.header("x-amz-storage-class", equalTo("STANDARD_IA"))
|
||||
.header("x-amz-checksum-sha256", notNullValue())
|
||||
.header("x-amz-checksum-crc64nvme", notNullValue())
|
||||
.body(equalTo("Hello World from S3!"));
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ class S3IntegrationTest {
|
||||
.body(containsString("<GetObjectAttributesResponse"))
|
||||
.body(containsString("<StorageClass>STANDARD_IA</StorageClass>"))
|
||||
.body(containsString("<ObjectSize>20</ObjectSize>"))
|
||||
.body(containsString("<ChecksumSHA256>"));
|
||||
.body(containsString("<ChecksumCRC64NVME>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -108,7 +108,7 @@ class S3IntegrationTest {
|
||||
.header("Content-Length", notNullValue())
|
||||
.header("x-amz-meta-owner", equalTo("team-a"))
|
||||
.header("x-amz-storage-class", equalTo("STANDARD_IA"))
|
||||
.header("x-amz-checksum-sha256", notNullValue());
|
||||
.header("x-amz-checksum-crc64nvme", notNullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1625,4 +1625,43 @@ class S3IntegrationTest {
|
||||
.statusCode(400)
|
||||
.body(containsString("InvalidKey"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(150)
|
||||
void putObjectRejectsMismatchedCRC32() {
|
||||
given()
|
||||
.body("hello")
|
||||
.header("x-amz-checksum-crc32", "INVALID==")
|
||||
.when()
|
||||
.put("/test-bucket/checksum-crc32-test.txt")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body(containsString("BadDigest"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(151)
|
||||
void putObjectRejectsMismatchedCRC32C() {
|
||||
given()
|
||||
.body("hello")
|
||||
.header("x-amz-checksum-crc32c", "INVALID==")
|
||||
.when()
|
||||
.put("/test-bucket/checksum-crc32c-test.txt")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body(containsString("BadDigest"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(152)
|
||||
void putObjectRejectsMismatchedCRC64NVME() {
|
||||
given()
|
||||
.body("hello")
|
||||
.header("x-amz-checksum-crc64nvme", "INVALID==")
|
||||
.when()
|
||||
.put("/test-bucket/checksum-crc64nvme-test.txt")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body(containsString("BadDigest"));
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -148,7 +148,7 @@ class S3MultipartIntegrationTest {
|
||||
.body(containsString("<StorageClass>STANDARD_IA</StorageClass>"))
|
||||
.body(containsString("<ObjectParts>"))
|
||||
.body(containsString("<PartsCount>2</PartsCount>"))
|
||||
.body(containsString("<ChecksumSHA256>"));
|
||||
.body(containsString("<ChecksumCRC64NVME>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -172,6 +172,6 @@ class S3MultipartServiceTest {
|
||||
assertEquals(1, attributes.getObjectParts().getParts().size());
|
||||
assertTrue(attributes.getObjectParts().isTruncated());
|
||||
assertEquals(1, attributes.getObjectParts().getNextPartNumberMarker());
|
||||
assertNotNull(attributes.getObjectParts().getParts().get(0).getChecksum().getChecksumSHA256());
|
||||
assertNotNull(attributes.getObjectParts().getParts().get(0).getChecksum().getChecksumCRC64NVME());
|
||||
}
|
||||
}
|
||||
@@ -362,7 +362,7 @@ class S3ServiceTest {
|
||||
assertEquals("STANDARD_IA", head.getStorageClass());
|
||||
assertEquals("team-a", head.getMetadata().get("owner"));
|
||||
assertNotNull(head.getChecksum());
|
||||
assertNotNull(head.getChecksum().getChecksumSHA256());
|
||||
assertNotNull(head.getChecksum().getChecksumCRC64NVME());
|
||||
assertEquals("FULL_OBJECT", head.getChecksum().getChecksumType());
|
||||
assertEquals(stored.getETag(), head.getETag());
|
||||
}
|
||||
@@ -382,7 +382,7 @@ class S3ServiceTest {
|
||||
assertEquals(7L, attributes.getObjectSize());
|
||||
assertEquals("GLACIER", attributes.getStorageClass());
|
||||
assertNotNull(attributes.getChecksum());
|
||||
assertNotNull(attributes.getChecksum().getChecksumSHA256());
|
||||
assertNotNull(attributes.getChecksum().getChecksumCRC64NVME());
|
||||
assertNull(attributes.getObjectParts());
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user