Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

fix(ses): treat missing SendingEnabled as false in v2 PutConfigurationSetSendingOptions (#1594)

Kenshin Okinakadec3b6366e47
diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesController.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesController.java
index 99a19683ac..ec07dc1fd4 100644
--- a/src/main/java/io/github/hectorvent/floci/services/ses/SesController.java
+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesController.java
@@ -768,23 +768,15 @@ public class SesController {
String body) {
String region = regionResolver.resolveRegion(headers);
try {
- JsonNode request = (body == null || body.isBlank())
- ? objectMapper.createObjectNode()
- : objectMapper.readTree(body);
- requireJsonObject(request);
- JsonNode enabledNode = request.path("SendingEnabled");
- if (enabledNode.isMissingNode() || enabledNode.isNull() || !enabledNode.isBoolean()) {
- throw new AwsException("BadRequestException",
- "SendingEnabled must be present and must be a boolean.", 400);
- }
- sesService.setConfigurationSetSendingEnabled(name, enabledNode.booleanValue(), region);
- LOG.infov("SES V2 PutConfigurationSetSendingOptions: {0} on {1}",
- enabledNode.booleanValue(), name);
+ // Reuse the AWS-aligned SendingEnabled deserialization shared with CreateConfigurationSet:
+ // absent -> false, string -> true, null/number -> SerializationException. An empty body
+ // / {} therefore disables sending (200). Verified against real AWS.
+ boolean enabled = parseSendingEnabled(readOptionBody(body).path("SendingEnabled"));
+ sesService.setConfigurationSetSendingEnabled(name, enabled, region);
+ LOG.infov("SES V2 PutConfigurationSetSendingOptions: {0} on {1}", enabled, name);
return Response.ok(objectMapper.createObjectNode()).build();
} catch (AwsException e) {
throw remapV1Exception(e);
- } catch (com.fasterxml.jackson.core.JsonProcessingException e) {
- throw new AwsException("BadRequestException", e.getMessage(), 400);
}
}
diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesConfigurationSetSendingOptionsV2IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesConfigurationSetSendingOptionsV2IntegrationTest.java
index 329c6de94d..8209a83569 100644
--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesConfigurationSetSendingOptionsV2IntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesConfigurationSetSendingOptionsV2IntegrationTest.java
@@ -170,21 +170,31 @@ class SesConfigurationSetSendingOptionsV2IntegrationTest {
@Test
@Order(12)
- void putSendingOptions_missingSendingEnabled_returns400() {
+ void putSendingOptions_emptyBody_treatsSendingEnabledAsFalse() {
+ // AWS treats an absent SendingEnabled as false: a true empty body succeeds (200) and
+ // disables sending (verified against real AWS). Sending is enabled here from @Order(9).
given()
.contentType("application/json")
.header("Authorization", SES_AUTH)
- .body("{}")
.when()
.put("/v2/email/configuration-sets/" + CS + "/sending")
.then()
- .statusCode(400)
- .body("message", containsString("SendingEnabled"));
+ .statusCode(200);
+
+ given()
+ .header("Authorization", SES_AUTH)
+ .when()
+ .get("/v2/email/configuration-sets/" + CS)
+ .then()
+ .statusCode(200)
+ .body("SendingOptions.SendingEnabled", equalTo(false));
}
@Test
@Order(13)
- void putSendingOptions_nonBooleanSendingEnabled_returns400() {
+ void putSendingOptions_stringSendingEnabled_coercesToTrue() {
+ // Real AWS coerces any string to true (200), matching CreateConfigurationSet. Verify the
+ // persisted value, not just the status — CS was disabled by @Order(12).
given()
.contentType("application/json")
.header("Authorization", SES_AUTH)
@@ -192,12 +202,35 @@ class SesConfigurationSetSendingOptionsV2IntegrationTest {
.when()
.put("/v2/email/configuration-sets/" + CS + "/sending")
.then()
- .statusCode(400)
- .body("message", containsString("SendingEnabled"));
+ .statusCode(200);
+
+ given()
+ .header("Authorization", SES_AUTH)
+ .when()
+ .get("/v2/email/configuration-sets/" + CS)
+ .then()
+ .statusCode(200)
+ .body("SendingOptions.SendingEnabled", equalTo(true));
}
@Test
@Order(14)
+ void putSendingOptions_nullSendingEnabled_returnsSerializationException() {
+ // Real AWS rejects an explicit JSON null for the boolean field with SerializationException,
+ // matching CreateConfigurationSet's deserialization.
+ given()
+ .contentType("application/json")
+ .header("Authorization", SES_AUTH)
+ .body("{\"SendingEnabled\":null}")
+ .when()
+ .put("/v2/email/configuration-sets/" + CS + "/sending")
+ .then()
+ .statusCode(400)
+ .body("__type", equalTo("SerializationException"));
+ }
+
+ @Test
+ @Order(15)
void putSendingOptions_unknownConfigSet_returns404_NotFoundException() {
given()
.contentType("application/json")
@@ -212,7 +245,7 @@ class SesConfigurationSetSendingOptionsV2IntegrationTest {
}
@Test
- @Order(15)
+ @Order(16)
void v1_updateConfigurationSetSendingEnabled_nonBooleanEnabled_returnsInvalidParameterValue() {
// parseRequiredBoolean enforces AWS-style "true"|"false". Anything else (e.g.
// "yes") must surface as InvalidParameterValue instead of being silently