mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(ses): reject non-array v2 reply-to and bulk destination members (#5477)
ReplyToAddresses in SendEmail and SendBulkEmail, and the To/Cc/Bcc of each SendBulkEmail entry, read a value of the wrong JSON type as an empty list. They are rejected with SerializationException, as the SendEmail Destination members already are.
This commit is contained in:
1 parent
1e92b7e17b
commit
a96cc04fab
4 files changed
+80
-24
No files matched your search
+64
@@ -0,0 +1,64 @@
|
||||
package io.github.hectorvent.floci.services.ses;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
@QuarkusTest
|
||||
class SesSendAddressListTypeIntegrationTest {
|
||||
|
||||
private static final String AUTH =
|
||||
"AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request";
|
||||
private static final String TO = "success@simulator.amazonses.com";
|
||||
|
||||
private static void assertSerializationException(String path, String body) {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", AUTH)
|
||||
.body(body)
|
||||
.when()
|
||||
.post(path)
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("SerializationException"));
|
||||
}
|
||||
|
||||
private static String bulkSend(String replyTo, String entryDestination) {
|
||||
return """
|
||||
{
|
||||
"FromEmailAddress": "sender@example.com",
|
||||
%s
|
||||
"DefaultContent": {"Template": {
|
||||
"TemplateContent": {"Subject": "s", "Text": "b"},
|
||||
"TemplateData": "{}"}},
|
||||
"BulkEmailEntries": [{"Destination": %s}]
|
||||
}
|
||||
""".formatted(replyTo, entryDestination);
|
||||
}
|
||||
|
||||
@Test
|
||||
void v2SendEmail_nonArrayReplyTo_returnsSerializationException() {
|
||||
assertSerializationException("/v2/email/outbound-emails", """
|
||||
{
|
||||
"FromEmailAddress": "sender@example.com",
|
||||
"Destination": {"ToAddresses": ["%s"]},
|
||||
"ReplyToAddresses": "reply@example.com",
|
||||
"Content": {"Simple": {"Subject": {"Data": "s"}, "Body": {"Text": {"Data": "b"}}}}
|
||||
}
|
||||
""".formatted(TO));
|
||||
}
|
||||
|
||||
@Test
|
||||
void v2SendBulkEmail_nonArrayReplyTo_returnsSerializationException() {
|
||||
assertSerializationException("/v2/email/outbound-bulk-emails",
|
||||
bulkSend("\"ReplyToAddresses\": \"reply@example.com\",", "{\"ToAddresses\": [\"" + TO + "\"]}"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void v2SendBulkEmail_nonArrayEntryDestinationMember_returnsSerializationException() {
|
||||
assertSerializationException("/v2/email/outbound-bulk-emails",
|
||||
bulkSend("", "{\"ToAddresses\": [\"" + TO + "\"], \"CcAddresses\": \"bad-shape\"}"));
|
||||
}
|
||||
}
|
||||
@@ -217,13 +217,14 @@ class SesV2JsonTest {
|
||||
|
||||
@Test
|
||||
void stringArrayOrAbsent_keepsEmptyListDistinctFromAbsent() {
|
||||
JsonNode node = json("{\"a\":[\"x\",\"y\"],\"e\":[],\"z\":null,\"s\":\"x\",\"m\":[1]}");
|
||||
JsonNode node = json("{\"a\":[\"x\",\"y\"],\"e\":[],\"z\":null,\"s\":\"x\",\"m\":[1],\"n\":[null]}");
|
||||
assertEquals(List.of("x", "y"), SesV2Json.stringArrayOrAbsent(node, "a"));
|
||||
assertEquals(List.of(), SesV2Json.stringArrayOrAbsent(node, "e"));
|
||||
assertNull(SesV2Json.stringArrayOrAbsent(node, "z"));
|
||||
assertNull(SesV2Json.stringArrayOrAbsent(node, "missing"));
|
||||
assertAws("SerializationException", 400, () -> SesV2Json.stringArrayOrAbsent(node, "s"));
|
||||
assertAws("SerializationException", 400, () -> SesV2Json.stringArrayOrAbsent(node, "m"));
|
||||
assertAws("SerializationException", 400, () -> SesV2Json.stringArrayOrAbsent(node, "n"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user