mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(s3): Ensure tags are added on multipart s3 uploads. (#2151)
This commit is contained in:
1 parent
e0aab2e27d
commit
f6faf0ffe5
5 files changed
+105
-2
No files matched your search
@@ -501,8 +501,67 @@ class S3MultipartIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Order(18)
|
||||
void multipartUploadAppliesInlineTagging() {
|
||||
String taggedKey = "tagged-multipart.bin";
|
||||
String taggingUploadId = given()
|
||||
.header("x-amz-tagging", "token=abc-123&teamId=42¬e=hello%20world")
|
||||
.when()
|
||||
.post("/" + BUCKET + "/" + taggedKey + "?uploads")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract().xmlPath().getString("InitiateMultipartUploadResult.UploadId");
|
||||
|
||||
given()
|
||||
.body("TaggedPartData")
|
||||
.when()
|
||||
.put("/" + BUCKET + "/" + taggedKey + "?uploadId=" + taggingUploadId + "&partNumber=1")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
String completeXml = """
|
||||
<CompleteMultipartUpload>
|
||||
<Part><PartNumber>1</PartNumber><ETag>etag1</ETag></Part>
|
||||
</CompleteMultipartUpload>""";
|
||||
given()
|
||||
.contentType("application/xml")
|
||||
.body(completeXml)
|
||||
.when()
|
||||
.post("/" + BUCKET + "/" + taggedKey + "?uploadId=" + taggingUploadId)
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
// Tags from the x-amz-tagging header on CreateMultipartUpload must be present
|
||||
// on the completed object, including URL-decoded values.
|
||||
given()
|
||||
.when()
|
||||
.get("/" + BUCKET + "/" + taggedKey + "?tagging")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("<Key>token</Key>"))
|
||||
.body(containsString("<Value>abc-123</Value>"))
|
||||
.body(containsString("<Key>teamId</Key>"))
|
||||
.body(containsString("<Value>42</Value>"))
|
||||
.body(containsString("<Key>note</Key>"))
|
||||
.body(containsString("<Value>hello world</Value>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(19)
|
||||
void initiateMultipartUploadRejectsMalformedTaggingHeader() {
|
||||
given()
|
||||
.header("x-amz-tagging", "missing-equals-sign")
|
||||
.when()
|
||||
.post("/" + BUCKET + "/bad-tagging.bin?uploads")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body(containsString("InvalidArgument"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(20)
|
||||
void cleanUp() {
|
||||
given().when().delete("/" + BUCKET + "/" + KEY).then().statusCode(204);
|
||||
given().when().delete("/" + BUCKET + "/tagged-multipart.bin").then().statusCode(204);
|
||||
given().when().delete("/" + BUCKET + "/source-for-copy.bin").then().statusCode(204);
|
||||
given().when().delete("/" + BUCKET + "/copy-dest.bin").then().statusCode(204);
|
||||
given().when().delete("/" + BUCKET + "/sse-c-multipart.bin").then().statusCode(204);
|
||||
|
||||
@@ -94,6 +94,31 @@ class S3MultipartServiceTest {
|
||||
assertEquals("COMPOSITE", result.getChecksum().getChecksumType());
|
||||
}
|
||||
|
||||
@Test
|
||||
void completeMultipartUploadAppliesTagging() {
|
||||
MultipartUpload upload = s3Service.initiateMultipartUpload("test-bucket", "tagged.bin", null,
|
||||
null, null, null, null, null, null, null, null, null,
|
||||
Map.of("token", "abc-123", "teamId", "42"));
|
||||
s3Service.uploadPart("test-bucket", "tagged.bin", upload.getUploadId(), 1, "part1".getBytes());
|
||||
|
||||
s3Service.completeMultipartUpload("test-bucket", "tagged.bin", upload.getUploadId(), List.of(1));
|
||||
|
||||
Map<String, String> tags = s3Service.getObjectTagging("test-bucket", "tagged.bin");
|
||||
assertEquals(2, tags.size());
|
||||
assertEquals("abc-123", tags.get("token"));
|
||||
assertEquals("42", tags.get("teamId"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void completeMultipartUploadWithoutTaggingLeavesObjectUntagged() {
|
||||
MultipartUpload upload = s3Service.initiateMultipartUpload("test-bucket", "untagged.bin", null);
|
||||
s3Service.uploadPart("test-bucket", "untagged.bin", upload.getUploadId(), 1, "part1".getBytes());
|
||||
|
||||
s3Service.completeMultipartUpload("test-bucket", "untagged.bin", upload.getUploadId(), List.of(1));
|
||||
|
||||
assertTrue(s3Service.getObjectTagging("test-bucket", "untagged.bin").isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void completeMultipartUploadMissingPart() {
|
||||
MultipartUpload upload = s3Service.initiateMultipartUpload("test-bucket", "file.bin", null);
|
||||
|
||||
Reference in new issue
Block a user