mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat(s3): preserve explicit object SSE headers (#515)
* feat(s3): preserve explicit object SSE headers * refactor(s3): validate and encapsulate SSE write options * fix(s3): make notification filter parsing deterministic * fix(ses): harden identity deletion lookups * fix(ses): reject padded identities literally * fix(secretsmanager): keep a single previous stage
This commit is contained in:
1 parent
1b53e53dba
commit
2efb483390
15 files changed
+610
-75
No files matched your search
@@ -1104,6 +1104,92 @@ class S3IntegrationTest {
|
||||
given().delete("/content-disposition-bucket");
|
||||
}
|
||||
|
||||
// --- Server-Side Encryption header preservation ---
|
||||
|
||||
@Test
|
||||
@Order(136)
|
||||
void createSseBucketAndPutObject() {
|
||||
given()
|
||||
.put("/sse-bucket")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
given()
|
||||
.contentType("text/plain")
|
||||
.header("x-amz-server-side-encryption", "AES256")
|
||||
.body("encrypted-content")
|
||||
.when()
|
||||
.put("/sse-bucket/encrypted.txt")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.header("ETag", notNullValue())
|
||||
.header("x-amz-server-side-encryption", equalTo("AES256"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(137)
|
||||
void getObjectReturnsServerSideEncryption() {
|
||||
given()
|
||||
.when()
|
||||
.get("/sse-bucket/encrypted.txt")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.header("x-amz-server-side-encryption", equalTo("AES256"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(138)
|
||||
void headObjectReturnsServerSideEncryption() {
|
||||
given()
|
||||
.when()
|
||||
.head("/sse-bucket/encrypted.txt")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.header("x-amz-server-side-encryption", equalTo("AES256"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(139)
|
||||
void copyObjectPreservesServerSideEncryption() {
|
||||
given()
|
||||
.header("x-amz-copy-source", "/sse-bucket/encrypted.txt")
|
||||
.when()
|
||||
.put("/sse-bucket/encrypted-copy.txt")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("CopyObjectResult"));
|
||||
|
||||
given()
|
||||
.when()
|
||||
.head("/sse-bucket/encrypted-copy.txt")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.header("x-amz-server-side-encryption", equalTo("AES256"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(140)
|
||||
void putObjectRejectsUnsupportedServerSideEncryption() {
|
||||
given()
|
||||
.contentType("text/plain")
|
||||
.header("x-amz-server-side-encryption", "totally-unsupported")
|
||||
.body("bad encryption")
|
||||
.when()
|
||||
.put("/sse-bucket/invalid-encryption.txt")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body(containsString("InvalidArgument"))
|
||||
.body(containsString("Unsupported x-amz-server-side-encryption value"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(141)
|
||||
void cleanupSseBucket() {
|
||||
given().delete("/sse-bucket/encrypted.txt");
|
||||
given().delete("/sse-bucket/encrypted-copy.txt");
|
||||
given().delete("/sse-bucket");
|
||||
}
|
||||
|
||||
// --- S3 Notification Configuration with Filter ---
|
||||
|
||||
@Test
|
||||
|
||||
@@ -33,6 +33,7 @@ class S3MultipartIntegrationTest {
|
||||
.header("x-amz-meta-owner", "team-a")
|
||||
.header("x-amz-storage-class", "STANDARD_IA")
|
||||
.header("Content-Disposition", "attachment; filename=\"multipart.bin\"")
|
||||
.header("x-amz-server-side-encryption", "AES256")
|
||||
.when()
|
||||
.post("/" + BUCKET + "/" + KEY + "?uploads")
|
||||
.then()
|
||||
@@ -127,6 +128,7 @@ class S3MultipartIntegrationTest {
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.header("Content-Disposition", equalTo("attachment; filename=\"multipart.bin\""))
|
||||
.header("x-amz-server-side-encryption", equalTo("AES256"))
|
||||
.header("x-amz-meta-owner", equalTo("team-a"))
|
||||
.header("x-amz-storage-class", equalTo("STANDARD_IA"))
|
||||
.body(equalTo("Part1Data-HelloPart2Data-World"));
|
||||
@@ -260,6 +262,19 @@ class S3MultipartIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Order(14)
|
||||
void initiateMultipartUploadRejectsUnsupportedServerSideEncryption() {
|
||||
given()
|
||||
.header("x-amz-server-side-encryption", "totally-unsupported")
|
||||
.when()
|
||||
.post("/" + BUCKET + "/invalid-sse.bin?uploads")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body(containsString("InvalidArgument"))
|
||||
.body(containsString("Unsupported x-amz-server-side-encryption value"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(15)
|
||||
void cleanUp() {
|
||||
given().when().delete("/" + BUCKET + "/" + KEY).then().statusCode(204);
|
||||
given().when().delete("/" + BUCKET + "/source-for-copy.bin").then().statusCode(204);
|
||||
|
||||
@@ -9,6 +9,7 @@ import io.github.hectorvent.floci.services.s3.model.GetObjectAttributesResult;
|
||||
import io.github.hectorvent.floci.services.s3.model.LambdaNotification;
|
||||
import io.github.hectorvent.floci.services.s3.model.NotificationConfiguration;
|
||||
import io.github.hectorvent.floci.services.s3.model.ObjectAttributeName;
|
||||
import io.github.hectorvent.floci.services.s3.model.PutObjectOptions;
|
||||
import io.github.hectorvent.floci.services.s3.model.Bucket;
|
||||
import io.github.hectorvent.floci.services.s3.model.S3Object;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -111,6 +112,41 @@ class S3ServiceTest {
|
||||
assertEquals("text/plain", got.getContentType());
|
||||
}
|
||||
|
||||
@Test
|
||||
void putObjectTrimsBlankServerSideEncryptionToAbsent() {
|
||||
s3Service.createBucket("test-bucket", "us-east-1");
|
||||
|
||||
S3Object put = s3Service.putObject(
|
||||
"test-bucket",
|
||||
"blank-sse.txt",
|
||||
"data".getBytes(StandardCharsets.UTF_8),
|
||||
"text/plain",
|
||||
null,
|
||||
new PutObjectOptions().withServerSideEncryption(" ")
|
||||
);
|
||||
|
||||
assertNull(put.getServerSideEncryption());
|
||||
}
|
||||
|
||||
@Test
|
||||
void putObjectRejectsUnsupportedServerSideEncryption() {
|
||||
s3Service.createBucket("test-bucket", "us-east-1");
|
||||
|
||||
AwsException exception = assertThrows(AwsException.class, () ->
|
||||
s3Service.putObject(
|
||||
"test-bucket",
|
||||
"invalid-sse.txt",
|
||||
"data".getBytes(StandardCharsets.UTF_8),
|
||||
"text/plain",
|
||||
null,
|
||||
new PutObjectOptions().withServerSideEncryption("totally-unsupported")
|
||||
)
|
||||
);
|
||||
|
||||
assertEquals("InvalidArgument", exception.getErrorCode());
|
||||
assertTrue(exception.getMessage().contains("Unsupported x-amz-server-side-encryption value"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void putObjectWritesFileToDisk() {
|
||||
s3Service.createBucket("test-bucket", "us-east-1");
|
||||
|
||||
@@ -385,6 +385,63 @@ class SesIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Order(21)
|
||||
void deleteDomainIdentity() {
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", authorization("email"))
|
||||
.formParam("Action", "DeleteIdentity")
|
||||
.formParam("Identity", "example.com")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("DeleteIdentityResult"));
|
||||
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", authorization("email"))
|
||||
.formParam("Action", "ListIdentities")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(not(containsString("example.com")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(22)
|
||||
void verifyEmailIdentity_rejectsLeadingTrailingWhitespace() {
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", authorization("email"))
|
||||
.formParam("Action", "VerifyEmailIdentity")
|
||||
.formParam("EmailAddress", " sender@example.com ")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body(containsString("InvalidParameterValue"))
|
||||
.body(containsString("leading or trailing whitespace"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(23)
|
||||
void verifyDomainIdentity_rejectsLeadingTrailingWhitespace() {
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", authorization("email"))
|
||||
.formParam("Action", "VerifyDomainIdentity")
|
||||
.formParam("Domain", " example.com ")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body(containsString("InvalidParameterValue"))
|
||||
.body(containsString("leading or trailing whitespace"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(24)
|
||||
void unsupportedAction_returns400() {
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
|
||||
@@ -296,6 +296,23 @@ class SesV2IntegrationTest {
|
||||
.body("MessageId", notNullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(14)
|
||||
void createEmailIdentity_rejectsLeadingTrailingWhitespace() {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.body("""
|
||||
{"EmailIdentity": " padded@example.com "}
|
||||
""")
|
||||
.when()
|
||||
.post("/v2/email/identities")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"))
|
||||
.body("message", containsString("leading or trailing whitespace"));
|
||||
}
|
||||
|
||||
// ──────────────── DKIM Attributes ────────────────
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user