mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
fix(ses): apply the v2 boolean coercion to the remaining boolean members (#4944)
* fix(ses): apply the v2 boolean coercion to the remaining boolean members SigningEnabled, EmailForwardingEnabled, ReputationMetricsEnabled, an event destination's Enabled, the account SendingEnabled and ProductionAccessEnabled now coerce a JSON string the way SES v2 does instead of rejecting it with an error of Floci's own. SigningEnabled, EmailForwardingEnabled and the account SendingEnabled also accept a missing member as false, as SES v2 does, where Floci required it. * test(ses): create the event destination with "yes" so the create path is checked * fix(ses): default a create-time ReputationMetricsEnabled to false when ReputationOptions omits it
This commit is contained in:
1 parent
02b0a3f536
commit
3597afda07
8 files changed
+227
-104
No files matched your search
@@ -26,6 +26,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.coerceBoolean;
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.coerceBooleanOrFalse;
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.readOptionBody;
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.remapV1Exception;
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.requireJsonObject;
|
||||
@@ -197,10 +198,8 @@ public class SesAccountController {
|
||||
}
|
||||
}
|
||||
JsonNode productionAccess = request.path("ProductionAccessEnabled");
|
||||
if (!productionAccess.isMissingNode() && !productionAccess.isNull() && !productionAccess.isBoolean()) {
|
||||
throw new AwsException("SerializationException", null, 400);
|
||||
}
|
||||
boolean productionAccessEnabled = productionAccess.asBoolean(false);
|
||||
boolean productionAccessEnabled = !productionAccess.isMissingNode() && !productionAccess.isNull()
|
||||
&& coerceBoolean(productionAccess);
|
||||
|
||||
// The service owns validation and the synthetic review/case so they can't be bypassed; the
|
||||
// controller only parses the REST JSON and rejects wrong JSON types.
|
||||
@@ -227,7 +226,7 @@ public class SesAccountController {
|
||||
// AutoWarmupEnabled has a default of false: the SDK omits it when false, so a missing
|
||||
// member is treated as false rather than rejected. A present value goes through the
|
||||
// shared SES v2 boolean coercion.
|
||||
boolean enabled = enabledNode.isMissingNode() ? false : coerceBoolean(enabledNode);
|
||||
boolean enabled = coerceBooleanOrFalse(enabledNode);
|
||||
accountService.setDedicatedIpAutoWarmup(region, enabled);
|
||||
LOG.infov("SES V2 PutAccountDedicatedIpWarmupAttributes: {0}", enabled);
|
||||
return Response.ok(objectMapper.createObjectNode()).build();
|
||||
@@ -274,13 +273,9 @@ public class SesAccountController {
|
||||
public Response putAccountSendingAttributes(@Context HttpHeaders headers, String body) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
try {
|
||||
JsonNode request = objectMapper.readTree(body);
|
||||
JsonNode sendingEnabledNode = request.get("SendingEnabled");
|
||||
if (sendingEnabledNode == null || !sendingEnabledNode.isBoolean()) {
|
||||
throw new AwsException("BadRequestException",
|
||||
"SendingEnabled must be present and must be a boolean", 400);
|
||||
}
|
||||
accountService.setAccountSendingEnabled(region, sendingEnabledNode.booleanValue());
|
||||
JsonNode request = readOptionBody(objectMapper, body);
|
||||
accountService.setAccountSendingEnabled(region,
|
||||
coerceBooleanOrFalse(request.path("SendingEnabled")));
|
||||
return Response.ok(objectMapper.createObjectNode()).build();
|
||||
} catch (AwsException e) {
|
||||
throw remapV1Exception(e);
|
||||
|
||||
+18
-22
@@ -36,8 +36,8 @@ import org.jboss.logging.Logger;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.coerceBooleanOrFalse;
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.parseOptionString;
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.parseSendingEnabled;
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.parseSuppressedReasons;
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.parseTagsArray;
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.readOptionBody;
|
||||
@@ -107,15 +107,13 @@ public class SesConfigurationSetController {
|
||||
if (!sendingNode.isObject()) {
|
||||
throw new AwsException("SerializationException", "Expected null", 400);
|
||||
}
|
||||
cs.setSendingEnabled(parseSendingEnabled(sendingNode.path("SendingEnabled")));
|
||||
cs.setSendingEnabled(coerceBooleanOrFalse(sendingNode.path("SendingEnabled")));
|
||||
}
|
||||
JsonNode reputationNode = request.path("ReputationOptions");
|
||||
if (!reputationNode.isMissingNode() && !reputationNode.isNull()) {
|
||||
requireOptionObject(reputationNode);
|
||||
Boolean rme = parseReputationMetricsEnabled(reputationNode.path("ReputationMetricsEnabled"));
|
||||
if (rme != null) {
|
||||
cs.setReputationMetricsEnabled(rme);
|
||||
}
|
||||
cs.setReputationMetricsEnabled(
|
||||
coerceBooleanOrFalse(reputationNode.path("ReputationMetricsEnabled")));
|
||||
}
|
||||
JsonNode trackingNode = request.path("TrackingOptions");
|
||||
if (!trackingNode.isMissingNode() && !trackingNode.isNull()) {
|
||||
@@ -240,7 +238,7 @@ public class SesConfigurationSetController {
|
||||
// Reuse the AWS-aligned SendingEnabled deserialization shared with CreateConfigurationSet:
|
||||
// absent -> false, otherwise SesV2Json.coerceBoolean. An empty body / {} therefore
|
||||
// disables sending (200). Verified against real AWS.
|
||||
boolean enabled = parseSendingEnabled(
|
||||
boolean enabled = coerceBooleanOrFalse(
|
||||
readOptionBody(objectMapper, body).path("SendingEnabled"));
|
||||
configSetService.setSendingEnabled(name, enabled, region);
|
||||
LOG.infov("SES V2 PutConfigurationSetSendingOptions: {0} on {1}", enabled, name);
|
||||
@@ -258,10 +256,9 @@ public class SesConfigurationSetController {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
try {
|
||||
JsonNode request = readOptionBody(objectMapper, body);
|
||||
Boolean enabled = parseReputationMetricsEnabled(request.path("ReputationMetricsEnabled"));
|
||||
boolean effectiveEnabled = enabled != null && enabled;
|
||||
configSetService.setReputationMetricsEnabled(name, effectiveEnabled, region);
|
||||
LOG.infov("SES V2 PutConfigurationSetReputationOptions: {0} on {1}", effectiveEnabled, name);
|
||||
boolean enabled = coerceBooleanOrFalse(request.path("ReputationMetricsEnabled"));
|
||||
configSetService.setReputationMetricsEnabled(name, enabled, region);
|
||||
LOG.infov("SES V2 PutConfigurationSetReputationOptions: {0} on {1}", enabled, name);
|
||||
return Response.ok(objectMapper.createObjectNode()).build();
|
||||
} catch (AwsException e) {
|
||||
throw remapV1Exception(e);
|
||||
@@ -342,15 +339,14 @@ public class SesConfigurationSetController {
|
||||
}
|
||||
}
|
||||
|
||||
private static Boolean parseReputationMetricsEnabled(JsonNode node) {
|
||||
if (node.isMissingNode() || node.isNull()) {
|
||||
return null;
|
||||
}
|
||||
if (!node.isBoolean()) {
|
||||
throw new AwsException("BadRequestException",
|
||||
"ReputationMetricsEnabled must be a boolean.", 400);
|
||||
}
|
||||
return node.booleanValue();
|
||||
// Enabled takes the shared SES v2 boolean coercion, which Jackson's own binding does not match.
|
||||
private EventDestination parseEventDestination(JsonNode edNode) throws JsonProcessingException {
|
||||
boolean enabled = coerceBooleanOrFalse(edNode.path("Enabled"));
|
||||
ObjectNode withoutEnabled = edNode.deepCopy();
|
||||
withoutEnabled.remove("Enabled");
|
||||
EventDestination dest = objectMapper.treeToValue(withoutEnabled, EventDestination.class);
|
||||
dest.setEnabled(enabled);
|
||||
return dest;
|
||||
}
|
||||
|
||||
private static TrackingOptions parseTrackingOptions(JsonNode node) {
|
||||
@@ -460,7 +456,7 @@ public class SesConfigurationSetController {
|
||||
if (!edNode.isObject()) {
|
||||
throw new AwsException("BadRequestException", "EventDestination is required.", 400);
|
||||
}
|
||||
EventDestination dest = objectMapper.treeToValue(edNode, EventDestination.class);
|
||||
EventDestination dest = parseEventDestination(edNode);
|
||||
configSetService.createEventDestination(configurationSetName, edName, dest,
|
||||
regionResolver.getAccountId(), region);
|
||||
LOG.infov("SES V2 CreateConfigurationSetEventDestination: {0} on {1}", edName, configurationSetName);
|
||||
@@ -504,7 +500,7 @@ public class SesConfigurationSetController {
|
||||
if (!edNode.isObject()) {
|
||||
throw new AwsException("BadRequestException", "EventDestination is required.", 400);
|
||||
}
|
||||
EventDestination dest = objectMapper.treeToValue(edNode, EventDestination.class);
|
||||
EventDestination dest = parseEventDestination(edNode);
|
||||
configSetService.updateEventDestination(configurationSetName, eventDestinationName,
|
||||
dest, regionResolver.getAccountId(), region);
|
||||
LOG.infov("SES V2 UpdateConfigurationSetEventDestination: {0} on {1}",
|
||||
|
||||
@@ -29,8 +29,10 @@ import org.jboss.logging.Logger;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.coerceBooleanOrFalse;
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.parseTagsArray;
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.putTimestamp;
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.readOptionBody;
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.remapV1Exception;
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.requireJsonObject;
|
||||
import static io.github.hectorvent.floci.services.ses.SesV2Json.requireObjectOrAbsent;
|
||||
@@ -266,13 +268,8 @@ public class SesIdentityController {
|
||||
String body) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
try {
|
||||
JsonNode request = objectMapper.readTree(body);
|
||||
JsonNode signingEnabledNode = request.get("SigningEnabled");
|
||||
if (signingEnabledNode == null || !signingEnabledNode.isBoolean()) {
|
||||
throw new AwsException("BadRequestException",
|
||||
"SigningEnabled must be present and must be a boolean", 400);
|
||||
}
|
||||
boolean signingEnabled = signingEnabledNode.booleanValue();
|
||||
JsonNode request = readOptionBody(objectMapper, body);
|
||||
boolean signingEnabled = coerceBooleanOrFalse(request.path("SigningEnabled"));
|
||||
identityService.setDkimAttributes(emailIdentity, signingEnabled, region);
|
||||
return Response.ok(objectMapper.createObjectNode()).build();
|
||||
} catch (AwsException e) {
|
||||
@@ -376,13 +373,8 @@ public class SesIdentityController {
|
||||
String body) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
try {
|
||||
JsonNode request = objectMapper.readTree(body);
|
||||
JsonNode emailForwardingEnabledNode = request.get("EmailForwardingEnabled");
|
||||
if (emailForwardingEnabledNode == null || !emailForwardingEnabledNode.isBoolean()) {
|
||||
throw new AwsException("BadRequestException",
|
||||
"EmailForwardingEnabled must be present and must be a boolean", 400);
|
||||
}
|
||||
boolean emailForwardingEnabled = emailForwardingEnabledNode.booleanValue();
|
||||
JsonNode request = readOptionBody(objectMapper, body);
|
||||
boolean emailForwardingEnabled = coerceBooleanOrFalse(request.path("EmailForwardingEnabled"));
|
||||
identityService.setFeedbackForwardingEnabled(emailIdentity, emailForwardingEnabled,
|
||||
region);
|
||||
return Response.ok(objectMapper.createObjectNode()).build();
|
||||
|
||||
@@ -246,12 +246,13 @@ final class SesV2Json {
|
||||
}
|
||||
|
||||
/**
|
||||
* Reproduces the AWS deserialization behavior for {@code SendingEnabled}
|
||||
* (verified against real AWS SES V2 on 2026-06-13): a missing member
|
||||
* defaults to {@code false}, and a present value goes through
|
||||
* {@link #coerceBoolean(JsonNode)}.
|
||||
* An optional SES v2 boolean member whose absence means {@code false}: a missing member is
|
||||
* {@code false}, and a present value, {@code null} included, goes through
|
||||
* {@link #coerceBoolean(JsonNode)}. AWS-verified for the account's and a configuration set's
|
||||
* SendingEnabled, SigningEnabled, EmailForwardingEnabled, ReputationMetricsEnabled and an event
|
||||
* destination's Enabled.
|
||||
*/
|
||||
static boolean parseSendingEnabled(JsonNode enabledNode) {
|
||||
static boolean coerceBooleanOrFalse(JsonNode enabledNode) {
|
||||
if (enabledNode.isMissingNode()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+3
-2
@@ -149,9 +149,10 @@ class SesAccountDetailsV2IntegrationTest {
|
||||
void putDetails_nonBooleanProductionAccess_returnsBadRequest() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
.body("{\"MailType\":\"TRANSACTIONAL\",\"WebsiteURL\":\"https://example.com\","
|
||||
+ "\"ProductionAccessEnabled\":\"yes\"}")
|
||||
+ "\"ProductionAccessEnabled\":\"abc\"}")
|
||||
.when().post("/v2/email/account/details").then().statusCode(400)
|
||||
.body("__type", equalTo("SerializationException"));
|
||||
.body("__type", equalTo("SerializationException"))
|
||||
.body("message", equalTo("STRING_VALUE can not be converted to an Boolean"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+180
@@ -0,0 +1,180 @@
|
||||
package io.github.hectorvent.floci.services.ses;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.response.ValidatableResponse;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
/**
|
||||
* The SES v2 boolean members that share {@code SesV2Json.coerceBoolean}: a string coerces only
|
||||
* when it names a boolean, any other string is a SerializationException, and on the members whose
|
||||
* absence means false an empty body stores false. All of it probe-confirmed against real SES v2.
|
||||
* Runs in its own region because it toggles account-level sending.
|
||||
*/
|
||||
@QuarkusTest
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
class SesBooleanCoercionV2IntegrationTest {
|
||||
|
||||
private static final String REGION = "il-central-1";
|
||||
private static final String AUTH =
|
||||
"AWS4-HMAC-SHA256 Credential=AKID/20260101/" + REGION + "/ses/aws4_request";
|
||||
private static final String DOMAIN = "coercion.example.com";
|
||||
private static final String CS = "coercion-cs";
|
||||
private static final String ED = "coercion-ed";
|
||||
private static final String NOT_A_BOOLEAN = "STRING_VALUE can not be converted to an Boolean";
|
||||
|
||||
private boolean created;
|
||||
|
||||
// Not @BeforeAll: the Quarkus test port is only bound once the first test starts.
|
||||
@BeforeEach
|
||||
void createResources() {
|
||||
if (created) {
|
||||
return;
|
||||
}
|
||||
send("POST", "/v2/email/identities", "{\"EmailIdentity\":\"" + DOMAIN + "\"}").statusCode(200);
|
||||
send("POST", "/v2/email/configuration-sets", "{\"ConfigurationSetName\":\"" + CS + "\"}")
|
||||
.statusCode(200);
|
||||
send("POST", "/v2/email/configuration-sets/" + CS + "/event-destinations", """
|
||||
{"EventDestinationName": "%s",
|
||||
"EventDestination": {"Enabled": "yes", "MatchingEventTypes": ["SEND"],
|
||||
"SnsDestination": {"TopicArn": "arn:aws:sns:%s:000000000000:coercion"}}}
|
||||
""".formatted(ED, REGION)).statusCode(200);
|
||||
created = true;
|
||||
}
|
||||
|
||||
@Test
|
||||
void signingEnabled_coercesStringsAndDefaultsToFalse() {
|
||||
String path = "/v2/email/identities/" + DOMAIN + "/dkim";
|
||||
assertStored(path, "SigningEnabled", "/v2/email/identities/" + DOMAIN, "DkimAttributes.SigningEnabled");
|
||||
}
|
||||
|
||||
@Test
|
||||
void emailForwardingEnabled_coercesStringsAndDefaultsToFalse() {
|
||||
String path = "/v2/email/identities/" + DOMAIN + "/feedback";
|
||||
assertStored(path, "EmailForwardingEnabled", "/v2/email/identities/" + DOMAIN, "FeedbackForwardingStatus");
|
||||
}
|
||||
|
||||
@Test
|
||||
void identityAttributes_nonObjectBody_isRejectedAndKeepsTheFlag() {
|
||||
// Absence means false, so a body that is not an object must not reach that default.
|
||||
for (String suffix : new String[] {"/dkim", "/feedback"}) {
|
||||
String member = suffix.equals("/dkim") ? "SigningEnabled" : "EmailForwardingEnabled";
|
||||
String readField = suffix.equals("/dkim") ? "DkimAttributes.SigningEnabled" : "FeedbackForwardingStatus";
|
||||
String path = "/v2/email/identities/" + DOMAIN + suffix;
|
||||
send("PUT", path, "{\"" + member + "\":true}").statusCode(200);
|
||||
send("PUT", path, "[]").statusCode(400).body("__type", equalTo("BadRequestException"));
|
||||
get("/v2/email/identities/" + DOMAIN).body(readField, equalTo(true));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void reputationMetricsEnabled_coercesStringsAndDefaultsToFalse() {
|
||||
String path = "/v2/email/configuration-sets/" + CS + "/reputation-options";
|
||||
assertStored(path, "ReputationMetricsEnabled", "/v2/email/configuration-sets/" + CS,
|
||||
"ReputationOptions.ReputationMetricsEnabled");
|
||||
send("PUT", path, "{\"ReputationMetricsEnabled\":null}").statusCode(400)
|
||||
.body("__type", equalTo("SerializationException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void createConfigurationSet_reputationMetricsString_isCoerced() {
|
||||
send("POST", "/v2/email/configuration-sets", """
|
||||
{"ConfigurationSetName": "coercion-cs-create",
|
||||
"ReputationOptions": {"ReputationMetricsEnabled": "no"}}
|
||||
""").statusCode(200);
|
||||
get("/v2/email/configuration-sets/coercion-cs-create")
|
||||
.body("ReputationOptions.ReputationMetricsEnabled", equalTo(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
void createConfigurationSet_emptyReputationOptions_disablesMetrics() {
|
||||
// Without ReputationOptions the metrics stay on; an empty block means the member is false.
|
||||
send("POST", "/v2/email/configuration-sets", """
|
||||
{"ConfigurationSetName": "coercion-cs-empty", "ReputationOptions": {}}
|
||||
""").statusCode(200);
|
||||
get("/v2/email/configuration-sets/coercion-cs-empty")
|
||||
.body("ReputationOptions.ReputationMetricsEnabled", equalTo(false));
|
||||
send("POST", "/v2/email/configuration-sets", """
|
||||
{"ConfigurationSetName": "coercion-cs-null", "ReputationOptions": {"ReputationMetricsEnabled": null}}
|
||||
""").statusCode(400).body("__type", equalTo("SerializationException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void eventDestinationEnabled_coercesStringsAndDefaultsToFalse() {
|
||||
String path = "/v2/email/configuration-sets/" + CS + "/event-destinations/" + ED;
|
||||
String read = "/v2/email/configuration-sets/" + CS + "/event-destinations";
|
||||
// Created with "yes": a create path that ignored the string would read back the false default.
|
||||
get(read).body("EventDestinations[0].Enabled", equalTo(true));
|
||||
|
||||
send("PUT", path, eventDestination("\"Enabled\": \"no\",")).statusCode(200);
|
||||
get(read).body("EventDestinations[0].Enabled", equalTo(false));
|
||||
send("PUT", path, eventDestination("\"Enabled\": \"yes\",")).statusCode(200);
|
||||
get(read).body("EventDestinations[0].Enabled", equalTo(true));
|
||||
send("PUT", path, eventDestination("")).statusCode(200);
|
||||
get(read).body("EventDestinations[0].Enabled", equalTo(false));
|
||||
send("PUT", path, eventDestination("\"Enabled\": \"abc\",")).statusCode(400)
|
||||
.body("__type", equalTo("SerializationException"))
|
||||
.body("message", equalTo(NOT_A_BOOLEAN));
|
||||
}
|
||||
|
||||
@Test
|
||||
void accountSendingEnabled_coercesStringsAndDefaultsToFalse() {
|
||||
send("PUT", "/v2/email/account/sending", "{\"SendingEnabled\":\"no\"}").statusCode(200);
|
||||
get("/v2/email/account").body("SendingEnabled", equalTo(false));
|
||||
send("PUT", "/v2/email/account/sending", "{\"SendingEnabled\":\"yes\"}").statusCode(200);
|
||||
get("/v2/email/account").body("SendingEnabled", equalTo(true));
|
||||
send("PUT", "/v2/email/account/sending", "{\"SendingEnabled\":\"abc\"}").statusCode(400)
|
||||
.body("__type", equalTo("SerializationException"))
|
||||
.body("message", equalTo(NOT_A_BOOLEAN));
|
||||
send("PUT", "/v2/email/account/sending", "{\"SendingEnabled\":null}").statusCode(400)
|
||||
.body("__type", equalTo("SerializationException"));
|
||||
get("/v2/email/account").body("SendingEnabled", equalTo(true));
|
||||
send("PUT", "/v2/email/account/sending", "{}").statusCode(200);
|
||||
get("/v2/email/account").body("SendingEnabled", equalTo(false));
|
||||
send("PUT", "/v2/email/account/sending", "{\"SendingEnabled\":true}").statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void productionAccessEnabled_acceptsABooleanString() {
|
||||
send("POST", "/v2/email/account/details", """
|
||||
{"MailType": "TRANSACTIONAL", "WebsiteURL": "https://example.com",
|
||||
"ProductionAccessEnabled": "yes"}
|
||||
""").statusCode(200);
|
||||
}
|
||||
|
||||
// "no" then "yes" tells a coerced value from a default, {} proves absence means false, and
|
||||
// "abc" is the fallback error.
|
||||
private void assertStored(String path, String member, String readPath, String readField) {
|
||||
send("PUT", path, "{\"" + member + "\":\"yes\"}").statusCode(200);
|
||||
get(readPath).body(readField, equalTo(true));
|
||||
send("PUT", path, "{\"" + member + "\":\"no\"}").statusCode(200);
|
||||
get(readPath).body(readField, equalTo(false));
|
||||
send("PUT", path, "{\"" + member + "\":\"TRUE\"}").statusCode(200);
|
||||
get(readPath).body(readField, equalTo(true));
|
||||
send("PUT", path, "{}").statusCode(200);
|
||||
get(readPath).body(readField, equalTo(false));
|
||||
send("PUT", path, "{\"" + member + "\":\"abc\"}").statusCode(400)
|
||||
.body("__type", equalTo("SerializationException"))
|
||||
.body("message", equalTo(NOT_A_BOOLEAN));
|
||||
}
|
||||
|
||||
private static String eventDestination(String enabledMember) {
|
||||
return """
|
||||
{"EventDestination": {%s "MatchingEventTypes": ["SEND"],
|
||||
"SnsDestination": {"TopicArn": "arn:aws:sns:%s:000000000000:coercion"}}}
|
||||
""".formatted(enabledMember, REGION);
|
||||
}
|
||||
|
||||
private static ValidatableResponse send(String method, String path, String body) {
|
||||
return given().contentType("application/json").header("Authorization", AUTH).body(body)
|
||||
.when().request(method, path).then();
|
||||
}
|
||||
|
||||
private static ValidatableResponse get(String path) {
|
||||
return given().header("Authorization", AUTH).when().get(path).then().statusCode(200);
|
||||
}
|
||||
}
|
||||
@@ -740,20 +740,6 @@ class SesV2IntegrationTest {
|
||||
.body("SendingEnabled", equalTo(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(52)
|
||||
void putAccountSendingAttributes_missingField() {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.body("{}")
|
||||
.when()
|
||||
.put("/v2/email/account/sending")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(58)
|
||||
void putAccountSuppressionAttributes_storesReasons_visibleViaGetAccount() {
|
||||
@@ -965,34 +951,6 @@ class SesV2IntegrationTest {
|
||||
|
||||
// ──────────────── Validation edge cases ────────────────
|
||||
|
||||
@Test
|
||||
@Order(53)
|
||||
void putDkimAttributes_missingField() {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.body("{}")
|
||||
.when()
|
||||
.put("/v2/email/identities/dkim-test@example.com/dkim")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(54)
|
||||
void putFeedbackAttributes_missingField() {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.body("{}")
|
||||
.when()
|
||||
.put("/v2/email/identities/dkim-test@example.com/feedback")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(55)
|
||||
void sendEmail_raw_missingData() {
|
||||
|
||||
@@ -239,13 +239,13 @@ class SesV2JsonTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void parseSendingEnabled_missingIsFalse_otherwiseCoerces() {
|
||||
assertFalse(SesV2Json.parseSendingEnabled(json("{}").path("SendingEnabled")));
|
||||
assertTrue(SesV2Json.parseSendingEnabled(json("true")));
|
||||
assertTrue(SesV2Json.parseSendingEnabled(json("\"yes\"")));
|
||||
assertFalse(SesV2Json.parseSendingEnabled(json("\"no\"")));
|
||||
assertAws("SerializationException", 400, () -> SesV2Json.parseSendingEnabled(json("null")));
|
||||
assertAws("SerializationException", 400, () -> SesV2Json.parseSendingEnabled(json("0")));
|
||||
void coerceBooleanOrFalse_missingIsFalse_otherwiseCoerces() {
|
||||
assertFalse(SesV2Json.coerceBooleanOrFalse(json("{}").path("SendingEnabled")));
|
||||
assertTrue(SesV2Json.coerceBooleanOrFalse(json("true")));
|
||||
assertTrue(SesV2Json.coerceBooleanOrFalse(json("\"yes\"")));
|
||||
assertFalse(SesV2Json.coerceBooleanOrFalse(json("\"no\"")));
|
||||
assertAws("SerializationException", 400, () -> SesV2Json.coerceBooleanOrFalse(json("null")));
|
||||
assertAws("SerializationException", 400, () -> SesV2Json.coerceBooleanOrFalse(json("0")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user