Skip to content

armgit / floci

Public Imported from GitHub
0

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

fix(ses): keep MailFromAttributes block when MAIL FROM is unconfigured (#1310)

Kenshin Okinakaa032ec5ac0a5
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 db70afa48c..55408cec5c 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
@@ -1088,12 +1088,12 @@ public class SesController {
result.set("DkimAttributes", buildDkimAttributes(identity));
+ ObjectNode mailFromAttributes = result.putObject("MailFromAttributes");
+ mailFromAttributes.put("BehaviorOnMxFailure", v1BehaviorToV2(identity.getBehaviorOnMxFailure()));
String mailFromDomain = identity.getMailFromDomain();
if (mailFromDomain != null && !mailFromDomain.isEmpty()) {
- ObjectNode mailFromAttributes = result.putObject("MailFromAttributes");
mailFromAttributes.put("MailFromDomain", mailFromDomain);
mailFromAttributes.put("MailFromDomainStatus", toV2Status(identity.getMailFromDomainStatus()));
- mailFromAttributes.put("BehaviorOnMxFailure", v1BehaviorToV2(identity.getBehaviorOnMxFailure()));
}
result.putObject("Policies");
diff --git a/src/main/java/io/github/hectorvent/floci/services/ses/SesService.java b/src/main/java/io/github/hectorvent/floci/services/ses/SesService.java
index b5046c2595..1d38527952 100644
--- a/src/main/java/io/github/hectorvent/floci/services/ses/SesService.java
+++ b/src/main/java/io/github/hectorvent/floci/services/ses/SesService.java
@@ -474,7 +474,9 @@ public class SesService {
"Identity <" + identityValue + "> does not exist.", 400));
identity.setMailFromDomain(clearing ? null : mailFromDomain);
identity.setMailFromDomainStatus(clearing ? "Pending" : "Success");
- if (normalizedBehavior != null) {
+ if (clearing) {
+ identity.setBehaviorOnMxFailure("UseDefaultValue");
+ } else if (normalizedBehavior != null) {
identity.setBehaviorOnMxFailure(normalizedBehavior);
}
identityStore.put(key, identity);
diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesIdentityAttributesV2IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesIdentityAttributesV2IntegrationTest.java
index 8a1c24b6c7..ff7adf7618 100644
--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesIdentityAttributesV2IntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesIdentityAttributesV2IntegrationTest.java
@@ -32,14 +32,18 @@ class SesIdentityAttributesV2IntegrationTest {
.then()
.statusCode(200);
- // Verify MailFromAttributes is omitted by default
+ // With no MAIL FROM domain configured, AWS keeps the MailFromAttributes
+ // block carrying only BehaviorOnMxFailure and omits the inner
+ // MailFromDomain / MailFromDomainStatus fields.
given()
.header("Authorization", AUTH_HEADER)
.when()
.get("/v2/email/identities/v2-attrs.floci.test")
.then()
.statusCode(200)
- .body("MailFromAttributes", nullValue());
+ .body("MailFromAttributes.BehaviorOnMxFailure", equalTo("USE_DEFAULT_VALUE"))
+ .body("MailFromAttributes.MailFromDomain", nullValue())
+ .body("MailFromAttributes.MailFromDomainStatus", nullValue());
}
@Test
@@ -88,13 +92,18 @@ class SesIdentityAttributesV2IntegrationTest {
.then()
.statusCode(200);
+ // Clearing the MAIL FROM domain returns to the unconfigured shape:
+ // the block stays, BehaviorOnMxFailure resets to USE_DEFAULT_VALUE,
+ // and the inner domain / status fields drop out.
given()
.header("Authorization", AUTH_HEADER)
.when()
.get("/v2/email/identities/v2-attrs.floci.test")
.then()
.statusCode(200)
- .body("MailFromAttributes", nullValue());
+ .body("MailFromAttributes.BehaviorOnMxFailure", equalTo("USE_DEFAULT_VALUE"))
+ .body("MailFromAttributes.MailFromDomain", nullValue())
+ .body("MailFromAttributes.MailFromDomainStatus", nullValue());
}
@Test
diff --git a/src/test/java/io/github/hectorvent/floci/services/ses/SesV2IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ses/SesV2IntegrationTest.java
index 3ba3446037..2830f08ce3 100644
--- a/src/test/java/io/github/hectorvent/floci/services/ses/SesV2IntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/ses/SesV2IntegrationTest.java
@@ -1189,7 +1189,9 @@ class SesV2IntegrationTest {
.body("DkimAttributes", notNullValue())
.body("DkimAttributes.SigningEnabled", notNullValue())
.body("DkimAttributes.Status", notNullValue())
- .body("MailFromAttributes", nullValue())
+ .body("MailFromAttributes.BehaviorOnMxFailure", equalTo("USE_DEFAULT_VALUE"))
+ .body("MailFromAttributes.MailFromDomain", nullValue())
+ .body("MailFromAttributes.MailFromDomainStatus", nullValue())
.body("Policies", notNullValue())
.body("Tags", notNullValue());
}