fix(s3): return copy destination version id (#3669)

This commit is contained in:
Aniket Shukla authored and GitHub committed 2026-09-15 07:45:44 -04:00
1 parent e1e98fd8dc
commit 7d58be1d4f
2 files changed
+11 -2

No files matched your search

@@ -2661,6 +2661,9 @@ public class S3Controller {
if (copy.getSseKmsKeyId() != null) {
response.header("x-amz-server-side-encryption-aws-kms-key-id", copy.getSseKmsKeyId());
}
if (copy.getVersionId() != null) {
response.header("x-amz-version-id", copy.getVersionId());
}
appendSseCustomerHeaders(response, copy);
return response.build();
}
@@ -22,6 +22,8 @@ class S3CopyObjectVersionedIntegrationTest {
private static final String BUCKET = "copy-version-repro-it";
/** First object version id (after v1 upload, while still latest). */
private static String v1VersionId;
/** Version created by copying v1 back over the key. */
private static String copiedVersionId;
@Test
@Order(1)
@@ -78,19 +80,23 @@ class S3CopyObjectVersionedIntegrationTest {
@Test
@Order(6)
void copyObjectFromV1RestoresV1AsLatest() {
given()
copiedVersionId = given()
.header("x-amz-copy-source", "/" + BUCKET + "/key?versionId=" + v1VersionId)
.when()
.put("/" + BUCKET + "/key")
.then()
.statusCode(200)
.body(containsString("CopyObjectResult"));
.body(containsString("CopyObjectResult"))
.header("x-amz-version-id", notNullValue())
.extract()
.header("x-amz-version-id");
given()
.when()
.get("/" + BUCKET + "/key")
.then()
.statusCode(200)
.header("x-amz-version-id", equalTo(copiedVersionId))
.body(equalTo("v1"));
}
}