mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(s3): persist Content-Encoding header on S3 objects (#57)
Add contentEncoding field to S3Object and thread it through putObject, copyObject, getObject, and headObject. aws-chunked is excluded from persistence as it is a transfer-protocol marker, not a real encoding. CopyObject respects x-amz-metadata-directive: REPLACE by adopting the new Content-Encoding from the request instead of the source object.
This commit is contained in:
1 parent
2f875d4169
commit
ff2f68d8ab
4 files changed
+192
-4
No files matched your search
@@ -6,6 +6,8 @@ import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
import io.restassured.config.DecoderConfig;
|
||||
import io.restassured.config.RestAssuredConfig;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
@@ -732,4 +734,126 @@ class S3IntegrationTest {
|
||||
.then()
|
||||
.statusCode(204);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(80)
|
||||
void createEncodingTestBucket() {
|
||||
given()
|
||||
.when()
|
||||
.put("/encoding-test-bucket")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(81)
|
||||
void putObjectWithContentEncoding() {
|
||||
given()
|
||||
.contentType("text/plain")
|
||||
.header("Content-Encoding", "gzip")
|
||||
.body("compressed-content")
|
||||
.when()
|
||||
.put("/encoding-test-bucket/encoded.txt")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.header("ETag", notNullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(82)
|
||||
void getObjectReturnsContentEncoding() {
|
||||
RestAssuredConfig noDecompress = RestAssuredConfig.config()
|
||||
.decoderConfig(DecoderConfig.decoderConfig().noContentDecoders());
|
||||
given()
|
||||
.config(noDecompress)
|
||||
.when()
|
||||
.get("/encoding-test-bucket/encoded.txt")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.header("Content-Encoding", equalTo("gzip"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(83)
|
||||
void headObjectReturnsContentEncoding() {
|
||||
given()
|
||||
.when()
|
||||
.head("/encoding-test-bucket/encoded.txt")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.header("Content-Encoding", equalTo("gzip"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(84)
|
||||
void copyObjectPreservesContentEncoding() {
|
||||
given()
|
||||
.header("x-amz-copy-source", "/encoding-test-bucket/encoded.txt")
|
||||
.when()
|
||||
.put("/encoding-test-bucket/encoded-copy.txt")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("CopyObjectResult"));
|
||||
|
||||
given()
|
||||
.when()
|
||||
.head("/encoding-test-bucket/encoded-copy.txt")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.header("Content-Encoding", equalTo("gzip"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(85)
|
||||
void copyObjectReplaceContentEncoding() {
|
||||
given()
|
||||
.header("x-amz-copy-source", "/encoding-test-bucket/encoded.txt")
|
||||
.header("x-amz-metadata-directive", "REPLACE")
|
||||
.header("Content-Encoding", "identity")
|
||||
.when()
|
||||
.put("/encoding-test-bucket/encoded-replace.txt")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("CopyObjectResult"));
|
||||
|
||||
given()
|
||||
.when()
|
||||
.head("/encoding-test-bucket/encoded-replace.txt")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.header("Content-Encoding", equalTo("identity"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(86)
|
||||
void putObjectWithCompositeEncoding_stripsAwsChunkedToken() {
|
||||
RestAssuredConfig noDecompress = RestAssuredConfig.config()
|
||||
.decoderConfig(DecoderConfig.decoderConfig().noContentDecoders());
|
||||
given()
|
||||
.contentType("text/plain")
|
||||
.header("Content-Encoding", "gzip,aws-chunked")
|
||||
.body("compressed-chunked-content")
|
||||
.when()
|
||||
.put("/encoding-test-bucket/composite-encoded.txt")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
given()
|
||||
.config(noDecompress)
|
||||
.when()
|
||||
.head("/encoding-test-bucket/composite-encoded.txt")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.header("Content-Encoding", equalTo("gzip"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(88)
|
||||
void cleanupContentEncodingBucket() {
|
||||
given().delete("/encoding-test-bucket/encoded.txt");
|
||||
given().delete("/encoding-test-bucket/encoded-copy.txt");
|
||||
given().delete("/encoding-test-bucket/encoded-replace.txt");
|
||||
given().delete("/encoding-test-bucket/composite-encoded.txt");
|
||||
given().delete("/encoding-test-bucket");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user