Light, fluffy, and always free - The AWS Local Emulator alternative
fix(cloudformation): apply every SQS queue property and reset dropped ones on update (#4972)
Hector Venturaab2c0def0ad8
diff --git a/src/main/java/io/github/hectorvent/floci/services/cloudformation/provisioners/SqsCfnProvisioner.java b/src/main/java/io/github/hectorvent/floci/services/cloudformation/provisioners/SqsCfnProvisioner.javaindex f47b564d5d..bcf3e1e631 100644--- a/src/main/java/io/github/hectorvent/floci/services/cloudformation/provisioners/SqsCfnProvisioner.java+++ b/src/main/java/io/github/hectorvent/floci/services/cloudformation/provisioners/SqsCfnProvisioner.java@@ -28,6 +28,29 @@ public class SqsCfnProvisioner implements CfnResourceProvisioner {private static final Logger LOG = Logger.getLogger(SqsCfnProvisioner.class);private static final ObjectMapper MAPPER = new ObjectMapper();+ /** The schema's mutable properties that map one to one onto a queue attribute of the same name. */+ private static final List<String> SCALAR_ATTRIBUTES = List.of(+ "ContentBasedDeduplication", "DeduplicationScope", "DelaySeconds", "FifoThroughputLimit",+ "KmsDataKeyReusePeriodSeconds", "KmsMasterKeyId", "MaximumMessageSize", "MessageRetentionPeriod",+ "ReceiveMessageWaitTimeSeconds", "SqsManagedSseEnabled", "VisibilityTimeout");+ /** The mutable properties a template gives as a JSON document and SQS stores as a JSON string. */+ private static final List<String> JSON_ATTRIBUTES = List.of("RedriveAllowPolicy", "RedrivePolicy");+ private static final Set<String> FIFO_ONLY_ATTRIBUTES =+ Set.of("ContentBasedDeduplication", "DeduplicationScope", "FifoThroughputLimit");+ /**+ * Properties AWS keeps when an update drops them from the template, rather than resetting: in+ * LocalStack's AWS-recorded parity test+ * {@code test_update_fifo_queue_remove_all_properties_except_queuename} all three are unchanged+ * after an in-place name-only update, while every other property is back at its default.+ */+ private static final Set<String> RETAINED_ON_UPDATE =+ Set.of("SqsManagedSseEnabled", "DeduplicationScope", "FifoThroughputLimit");+ /**+ * Resets that cannot be an empty value: a fresh FIFO queue stores ContentBasedDeduplication as+ * false, and SetQueueAttributes rejects an empty MessageRetentionPeriod, whose default is fixed.+ */+ private static final Map<String, String> EXPLICIT_RESETS =+ Map.of("ContentBasedDeduplication", "false", "MessageRetentionPeriod", "345600");private final SqsService sqsService;@@ -137,25 +160,21 @@ public class SqsCfnProvisioner implements CfnResourceProvisioner {if (fifoFlag != null) {attrs.put("FifoQueue", fifoFlag);}- if (props.has("VisibilityTimeout")) {- attrs.put("VisibilityTimeout", ctx.engine().resolve(props.get("VisibilityTimeout")));- }- if (props.has("ContentBasedDeduplication")) {- attrs.put("ContentBasedDeduplication", ctx.engine().resolve(props.get("ContentBasedDeduplication")));+ // A property that resolves to blank is absent: the engine resolves AWS::NoValue to blank,+ // which is how Fn::If [cond, value, AWS::NoValue] drops a property. Stored as an empty+ // attribute it would replace the queue's default rather than leave it in place.+ for (String attribute : SCALAR_ATTRIBUTES) {+ putUnlessBlank(attrs, attribute, ctx.resolveOptional(props, attribute));}- if (props.has("DeduplicationScope")) {- attrs.put("DeduplicationScope", ctx.engine().resolve(props.get("DeduplicationScope")));- }- if (props.has("FifoThroughputLimit")) {- attrs.put("FifoThroughputLimit", ctx.engine().resolve(props.get("FifoThroughputLimit")));- }- if (props.has("RedrivePolicy") && !props.path("RedrivePolicy").isNull()) {- // Usually a JSON object in the template (deadLetterTargetArn is an Fn::GetAtt);- // resolveNode resolves intrinsics in place and SqsService expects the JSON string.- // CDK commonly emits RedrivePolicy as an already-serialized string via Fn::Join,- // which resolveNode collapses to a TextNode — unwrap it instead of calling- // toString(), which would JSON-re-encode (quote/escape) the string a second time.- attrs.put("RedrivePolicy", ctx.engine().resolveJsonAttribute(props.path("RedrivePolicy")));+ for (String attribute : JSON_ATTRIBUTES) {+ if (props.has(attribute) && !props.path(attribute).isNull()) {+ // Usually a JSON object in the template (deadLetterTargetArn is an Fn::GetAtt);+ // resolveNode resolves intrinsics in place and SqsService expects the JSON string.+ // CDK commonly emits RedrivePolicy as an already-serialized string via Fn::Join,+ // which resolveNode collapses to a TextNode: unwrap it instead of calling+ // toString(), which would JSON-re-encode (quote/escape) the string a second time.+ putUnlessBlank(attrs, attribute, ctx.engine().resolveJsonAttribute(props.path(attribute)));+ }}}// provision is also the update path. createQueue on a name that exists hands back the@@ -176,6 +195,7 @@ public class SqsCfnProvisioner implements CfnResourceProvisioner {String queueUrl;if (ctx.isUpdate() && queueName.equals(priorName)) {attrs.remove("FifoQueue");+ resetDroppedAttributes(attrs, fifo);Map<String, String> currentAttrs = sqsService.getQueueAttributes(ctx.priorPhysicalId(), List.of("All"), ctx.region());Map<String, String> currentTags = sqsService.listQueueTags(ctx.priorPhysicalId(), ctx.region());ObjectNode snapshot = MAPPER.createObjectNode();@@ -207,6 +227,34 @@ public class SqsCfnProvisioner implements CfnResourceProvisioner {ReplacementCleanup.record(r, ctx, attributesBefore);}+ private static void putUnlessBlank(Map<String, String> attrs, String attribute, String value) {+ if (value != null && !value.isBlank()) {+ attrs.put(attribute, value);+ }+ }++ /**+ * Puts every mutable property the template does not declare back to its default, which is how+ * CloudFormation applies an update: the desired state is the whole template, so a property dropped+ * from it no longer holds its old value. An empty value removes the stored attribute, leaving the+ * queue as a fresh create would, with {@code SqsService} reporting the default for it; the+ * {@link #EXPLICIT_RESETS} are written out instead. The FIFO-only attributes are left alone on a+ * standard queue, which cannot hold them, and the {@link #RETAINED_ON_UPDATE} ones keep their+ * stored value, as AWS does.+ */+ private static void resetDroppedAttributes(Map<String, String> attrs, boolean fifo) {+ for (String attribute : SCALAR_ATTRIBUTES) {+ if (attrs.containsKey(attribute) || RETAINED_ON_UPDATE.contains(attribute)+ || (!fifo && FIFO_ONLY_ATTRIBUTES.contains(attribute))) {+ continue;+ }+ attrs.put(attribute, EXPLICIT_RESETS.getOrDefault(attribute, ""));+ }+ for (String attribute : JSON_ATTRIBUTES) {+ attrs.putIfAbsent(attribute, "");+ }+ }+/*** Drives the queue's tags to the template's desired set, which is what CloudFormation does on* update: a key the template drops is untagged, and a template with no {@code Tags} leaves thediff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationSqsQueuePropertiesIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationSqsQueuePropertiesIntegrationTest.javanew file mode 100644index 0000000000..5e7d273a55--- /dev/null+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationSqsQueuePropertiesIntegrationTest.java@@ -0,0 +1,263 @@+package io.github.hectorvent.floci.services.cloudformation;++import io.github.hectorvent.floci.core.common.XmlParser;+import io.quarkus.test.junit.QuarkusTest;+import org.junit.jupiter.api.Test;++import java.util.Map;++import static io.restassured.RestAssured.given;+import static org.awaitility.Awaitility.await;+import static org.hamcrest.Matchers.containsString;+import static org.junit.jupiter.api.Assertions.assertEquals;+import static org.junit.jupiter.api.Assertions.assertFalse;++/**+ * {@code AWS::SQS::Queue} properties end to end through the real SQS service: every mutable property+ * the template declares reaches the queue, and an update that drops one puts it back to its default,+ * because CloudFormation applies the whole template as the desired state.+ */+@QuarkusTest+class CloudFormationSqsQueuePropertiesIntegrationTest {++ private static final String CFN_AUTH =+ "AWS4-HMAC-SHA256 Credential=test/20260205/us-east-1/cloudformation/aws4_request";+ private static final String STACK = "cfn-sqs-queue-properties";+ private static final String NO_VALUE_STACK = "cfn-sqs-queue-no-value";+ private static final String SSE_STACK = "cfn-sqs-queue-sse";+ private static final String FIFO_STACK = "cfn-sqs-queue-fifo";++ @Test+ void declaredPropertiesReachTheQueueAndDroppedOnesReturnToTheirDefaults() {+ String declared = """+ {+ "Resources": {+ "Queue": {+ "Type": "AWS::SQS::Queue",+ "Properties": {+ "VisibilityTimeout": 60,+ "DelaySeconds": 5,+ "MessageRetentionPeriod": 86400,+ "ReceiveMessageWaitTimeSeconds": 10,+ "RedriveAllowPolicy": {"redrivePermission": "denyAll"}+ }+ }+ },+ "Outputs": {"QueueUrl": {"Value": {"Ref": "Queue"}}}+ }+ """;+ cloudFormation(STACK, "CreateStack", declared);+ String queueUrl = XmlParser.extractPairs(describeStacks(STACK, "CREATE_COMPLETE"), "Outputs", "OutputKey",+ "OutputValue").get("QueueUrl");++ Map<String, String> created = queueAttributes(queueUrl);+ assertEquals("60", created.get("VisibilityTimeout"));+ assertEquals("5", created.get("DelaySeconds"));+ assertEquals("86400", created.get("MessageRetentionPeriod"));+ assertEquals("10", created.get("ReceiveMessageWaitTimeSeconds"));+ assertEquals("{\"redrivePermission\":\"denyAll\"}", created.get("RedriveAllowPolicy"));++ String dropped = """+ {+ "Resources": {+ "Queue": {"Type": "AWS::SQS::Queue", "Properties": {"VisibilityTimeout": 45}}+ },+ "Outputs": {"QueueUrl": {"Value": {"Ref": "Queue"}}}+ }+ """;+ cloudFormation(STACK, "UpdateStack", dropped);+ describeStacks(STACK, "UPDATE_COMPLETE");++ Map<String, String> updated = queueAttributes(queueUrl);+ assertEquals("45", updated.get("VisibilityTimeout"));+ assertEquals("0", updated.get("DelaySeconds"));+ assertEquals("345600", updated.get("MessageRetentionPeriod"));+ assertEquals("0", updated.get("ReceiveMessageWaitTimeSeconds"));+ assertFalse(updated.containsKey("RedriveAllowPolicy"), "a dropped RedriveAllowPolicy is removed");++ cloudFormation(STACK, "DeleteStack", null);+ await().untilAsserted(() -> given()+ .contentType("application/x-www-form-urlencoded")+ .formParam("Action", "GetQueueUrl")+ .formParam("QueueName", queueUrl.substring(queueUrl.lastIndexOf('/') + 1))+ .when().post("/").then().statusCode(400));+ }++ @Test+ void aPropertyAConditionDropsWithNoValueKeepsItsDefault() {+ String template = """+ {+ "Parameters": {"LongRetention": {"Type": "String", "Default": "%s"}},+ "Conditions": {"Long": {"Fn::Equals": [{"Ref": "LongRetention"}, "yes"]}},+ "Resources": {+ "Queue": {+ "Type": "AWS::SQS::Queue",+ "Properties": {+ "MessageRetentionPeriod": {"Fn::If": ["Long", 1209600, {"Ref": "AWS::NoValue"}]},+ "RedriveAllowPolicy": {"Fn::If": ["Long", {"redrivePermission": "denyAll"},+ {"Ref": "AWS::NoValue"}]}+ }+ }+ },+ "Outputs": {"QueueUrl": {"Value": {"Ref": "Queue"}}}+ }+ """;+ cloudFormation(NO_VALUE_STACK, "CreateStack", template.formatted("no"));+ String queueUrl = XmlParser.extractPairs(describeStacks(NO_VALUE_STACK, "CREATE_COMPLETE"), "Outputs",+ "OutputKey", "OutputValue").get("QueueUrl");+ assertEquals("345600", queueAttributes(queueUrl).get("MessageRetentionPeriod"));+ assertFalse(queueAttributes(queueUrl).containsKey("RedriveAllowPolicy"));++ cloudFormation(NO_VALUE_STACK, "UpdateStack", template.formatted("yes"));+ describeStacks(NO_VALUE_STACK, "UPDATE_COMPLETE");+ assertEquals("1209600", queueAttributes(queueUrl).get("MessageRetentionPeriod"));++ cloudFormation(NO_VALUE_STACK, "UpdateStack", template.formatted("no"));+ describeStacks(NO_VALUE_STACK, "UPDATE_COMPLETE");+ assertEquals("345600", queueAttributes(queueUrl).get("MessageRetentionPeriod"));+ assertFalse(queueAttributes(queueUrl).containsKey("RedriveAllowPolicy"));++ cloudFormation(NO_VALUE_STACK, "DeleteStack", null);+ }++ /**+ * Replays the AWS-recorded parity case behind the SqsManagedSseEnabled exception (LocalStack+ * {@code test_update_fifo_queue_remove_all_properties_except_queuename}): an in-place update+ * that drops {@code SqsManagedSseEnabled: false} and the KMS key resets the other properties,+ * clears the key, and leaves SSE-SQS reported as false.+ */+ @Test+ void droppingSqsManagedSseEnabledKeepsTheStoredValueAsAwsDoes() {+ String declared = """+ {+ "Resources": {+ "Queue": {+ "Type": "AWS::SQS::Queue",+ "Properties": {+ "QueueName": "cfn-sqs-sse-%s",+ "DelaySeconds": 13,+ "SqsManagedSseEnabled": false,+ "KmsMasterKeyId": "alias/aws/sqs"+ }+ }+ },+ "Outputs": {"QueueUrl": {"Value": {"Ref": "Queue"}}}+ }+ """;+ String nameOnly = """+ {+ "Resources": {+ "Queue": {"Type": "AWS::SQS::Queue", "Properties": {"QueueName": "cfn-sqs-sse-%s"}}+ },+ "Outputs": {"QueueUrl": {"Value": {"Ref": "Queue"}}}+ }+ """;+ String suffix = Long.toString(System.nanoTime(), 36);+ cloudFormation(SSE_STACK, "CreateStack", declared.formatted(suffix));+ String queueUrl = XmlParser.extractPairs(describeStacks(SSE_STACK, "CREATE_COMPLETE"), "Outputs",+ "OutputKey", "OutputValue").get("QueueUrl");+ assertEquals("false", queueAttributes(queueUrl).get("SqsManagedSseEnabled"));++ cloudFormation(SSE_STACK, "UpdateStack", nameOnly.formatted(suffix));+ describeStacks(SSE_STACK, "UPDATE_COMPLETE");++ Map<String, String> updated = queueAttributes(queueUrl);+ assertEquals("0", updated.get("DelaySeconds"));+ assertFalse(updated.containsKey("KmsMasterKeyId"), "the dropped KMS key is cleared");+ assertEquals("false", updated.get("SqsManagedSseEnabled"), "AWS keeps the stored value");++ cloudFormation(SSE_STACK, "DeleteStack", null);+ }++ /**+ * The FIFO half of the same AWS-recorded case: a name-only update resets ContentBasedDeduplication+ * to false and keeps DeduplicationScope and FifoThroughputLimit as they were.+ */+ @Test+ void aFifoNameOnlyUpdateKeepsTheThroughputSettingsAsAwsDoes() {+ String declared = """+ {+ "Resources": {+ "Queue": {+ "Type": "AWS::SQS::Queue",+ "Properties": {+ "QueueName": "cfn-sqs-fifo-%s.fifo",+ "FifoQueue": true,+ "ContentBasedDeduplication": true,+ "DeduplicationScope": "messageGroup",+ "FifoThroughputLimit": "perMessageGroupId",+ "DelaySeconds": 13+ }+ }+ },+ "Outputs": {"QueueUrl": {"Value": {"Ref": "Queue"}}}+ }+ """;+ String nameOnly = """+ {+ "Resources": {+ "Queue": {+ "Type": "AWS::SQS::Queue",+ "Properties": {"QueueName": "cfn-sqs-fifo-%s.fifo", "FifoQueue": true}+ }+ },+ "Outputs": {"QueueUrl": {"Value": {"Ref": "Queue"}}}+ }+ """;+ String suffix = Long.toString(System.nanoTime(), 36);+ cloudFormation(FIFO_STACK, "CreateStack", declared.formatted(suffix));+ String queueUrl = XmlParser.extractPairs(describeStacks(FIFO_STACK, "CREATE_COMPLETE"), "Outputs",+ "OutputKey", "OutputValue").get("QueueUrl");++ cloudFormation(FIFO_STACK, "UpdateStack", nameOnly.formatted(suffix));+ describeStacks(FIFO_STACK, "UPDATE_COMPLETE");++ Map<String, String> updated = queueAttributes(queueUrl);+ assertEquals("0", updated.get("DelaySeconds"));+ assertEquals("false", updated.get("ContentBasedDeduplication"));+ assertEquals("messageGroup", updated.get("DeduplicationScope"));+ assertEquals("perMessageGroupId", updated.get("FifoThroughputLimit"));++ cloudFormation(FIFO_STACK, "DeleteStack", null);+ }++ private static void cloudFormation(String stack, String action, String templateBody) {+ if (templateBody == null) {+ given()+ .contentType("application/x-www-form-urlencoded")+ .header("Authorization", CFN_AUTH)+ .formParam("Action", action)+ .formParam("StackName", stack)+ .when().post("/").then().statusCode(200);+ return;+ }+ given()+ .contentType("application/x-www-form-urlencoded")+ .header("Authorization", CFN_AUTH)+ .formParam("Action", action)+ .formParam("StackName", stack)+ .formParam("TemplateBody", templateBody)+ .when().post("/").then().statusCode(200);+ }++ private static String describeStacks(String stack, String expectedStatus) {+ return given()+ .contentType("application/x-www-form-urlencoded")+ .header("Authorization", CFN_AUTH)+ .formParam("Action", "DescribeStacks")+ .formParam("StackName", stack)+ .when().post("/").then().statusCode(200)+ .body(containsString("<StackStatus>" + expectedStatus + "</StackStatus>"))+ .extract().asString();+ }++ private static Map<String, String> queueAttributes(String queueUrl) {+ String xml = given()+ .contentType("application/x-www-form-urlencoded")+ .formParam("Action", "GetQueueAttributes")+ .formParam("QueueUrl", queueUrl)+ .formParam("AttributeName.1", "All")+ .when().post("/").then().statusCode(200).extract().asString();+ return XmlParser.extractPairs(xml, "Attribute", "Name", "Value");+ }+}diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/provisioners/SqsCfnProvisionerTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/provisioners/SqsCfnProvisionerTest.javaindex 89132f1213..63a369e085 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/provisioners/SqsCfnProvisionerTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/provisioners/SqsCfnProvisionerTest.java@@ -256,6 +256,115 @@ class SqsCfnProvisionerTest {assertEquals("arn:aws:sqs:us-east-1:000000000000:orders.fifo", r.getAttributes().get("Arn"));}+ @Test+ void everyMutableQueuePropertyReachesCreateQueue() {+ when(sqs.createQueue(eq("jobs"), any(), eq("us-east-1")))+ .thenReturn(new Queue("jobs", "http://localhost:4566/000000000000/jobs"));+ ObjectNode props = mapper.createObjectNode()+ .put("QueueName", "jobs")+ .put("DelaySeconds", 5)+ .put("MessageRetentionPeriod", 86400)+ .put("MaximumMessageSize", 2048)+ .put("ReceiveMessageWaitTimeSeconds", 20)+ .put("KmsMasterKeyId", "alias/aws/sqs")+ .put("KmsDataKeyReusePeriodSeconds", 600)+ .put("SqsManagedSseEnabled", false);+ props.putObject("RedriveAllowPolicy").put("redrivePermission", "denyAll");++ provisioner.provision(resource("AWS::SQS::Queue", "Jobs"), props, ctx());++ @SuppressWarnings("unchecked")+ ArgumentCaptor<Map<String, String>> captor = ArgumentCaptor.forClass(Map.class);+ verify(sqs).createQueue(eq("jobs"), captor.capture(), eq("us-east-1"));+ assertEquals(Map.of(+ "DelaySeconds", "5",+ "MessageRetentionPeriod", "86400",+ "MaximumMessageSize", "2048",+ "ReceiveMessageWaitTimeSeconds", "20",+ "KmsMasterKeyId", "alias/aws/sqs",+ "KmsDataKeyReusePeriodSeconds", "600",+ "SqsManagedSseEnabled", "false",+ "RedriveAllowPolicy", "{\"redrivePermission\":\"denyAll\"}"), captor.getValue());+ }++ @Test+ void aPropertyThatResolvesToNoValueIsAbsentOnCreate() {+ // The engine resolves AWS::NoValue to blank; the mocked engine does the same for an object.+ when(sqs.createQueue(eq("jobs"), any(), eq("us-east-1")))+ .thenReturn(new Queue("jobs", "http://localhost:4566/000000000000/jobs"));+ ObjectNode props = mapper.createObjectNode().put("QueueName", "jobs").put("DelaySeconds", 5);+ props.putObject("MessageRetentionPeriod").put("Ref", "AWS::NoValue");+ props.putObject("VisibilityTimeout").put("Ref", "AWS::NoValue");++ provisioner.provision(resource("AWS::SQS::Queue", "Jobs"), props, ctx());++ @SuppressWarnings("unchecked")+ ArgumentCaptor<Map<String, String>> captor = ArgumentCaptor.forClass(Map.class);+ verify(sqs).createQueue(eq("jobs"), captor.capture(), eq("us-east-1"));+ assertEquals(Map.of("DelaySeconds", "5"), captor.getValue());+ }++ @Test+ void aPropertyThatResolvesToNoValueIsResetOnUpdate() {+ StackResource r = resource("AWS::SQS::Queue", "Jobs");+ r.setAttributes(new HashMap<>(Map.of("QueueName", "jobs")));+ ObjectNode props = mapper.createObjectNode().put("QueueName", "jobs");+ props.putObject("MessageRetentionPeriod").put("Ref", "AWS::NoValue");++ provisioner.provision(r, props, updateCtx("http://localhost:4566/000000000000/jobs"));++ @SuppressWarnings("unchecked")+ ArgumentCaptor<Map<String, String>> captor = ArgumentCaptor.forClass(Map.class);+ verify(sqs).setQueueAttributes(anyString(), captor.capture(), eq("us-east-1"));+ assertEquals("345600", captor.getValue().get("MessageRetentionPeriod"));+ }++ @Test+ void anUpdateResetsThePropertiesTheTemplateDropped() {+ // CloudFormation applies the whole template as the desired state, so a property dropped from+ // it goes back to its default. An empty value removes the stored attribute, which SqsService+ // then reports at its default; MessageRetentionPeriod cannot be empty and is written out.+ StackResource r = resource("AWS::SQS::Queue", "Jobs");+ r.setAttributes(new HashMap<>(Map.of("QueueName", "jobs")));+ ObjectNode props = mapper.createObjectNode().put("QueueName", "jobs").put("VisibilityTimeout", 45);++ provisioner.provision(r, props, updateCtx("http://localhost:4566/000000000000/jobs"));++ @SuppressWarnings("unchecked")+ ArgumentCaptor<Map<String, String>> captor = ArgumentCaptor.forClass(Map.class);+ verify(sqs).setQueueAttributes(eq("http://localhost:4566/000000000000/jobs"), captor.capture(),+ eq("us-east-1"));+ assertEquals(Map.of(+ "VisibilityTimeout", "45",+ "DelaySeconds", "",+ "MessageRetentionPeriod", "345600",+ "MaximumMessageSize", "",+ "ReceiveMessageWaitTimeSeconds", "",+ "KmsMasterKeyId", "",+ "KmsDataKeyReusePeriodSeconds", "",+ "RedrivePolicy", "",+ "RedriveAllowPolicy", ""), captor.getValue(),+ "a standard queue gets no FIFO-only attribute and SqsManagedSseEnabled is not reset");+ }++ @Test+ void aFifoUpdateResetsContentBasedDeduplicationAndKeepsTheThroughputSettings() {+ // As AWS records: ContentBasedDeduplication returns to false, while DeduplicationScope and+ // FifoThroughputLimit keep their stored values when the template drops them.+ StackResource r = resource("AWS::SQS::Queue", "Orders");+ r.setAttributes(new HashMap<>(Map.of("QueueName", "orders.fifo")));+ ObjectNode props = mapper.createObjectNode().put("QueueName", "orders.fifo").put("FifoQueue", true);++ provisioner.provision(r, props, updateCtx("http://localhost:4566/000000000000/orders.fifo"));++ @SuppressWarnings("unchecked")+ ArgumentCaptor<Map<String, String>> captor = ArgumentCaptor.forClass(Map.class);+ verify(sqs).setQueueAttributes(anyString(), captor.capture(), eq("us-east-1"));+ assertEquals("false", captor.getValue().get("ContentBasedDeduplication"));+ assertFalse(captor.getValue().containsKey("DeduplicationScope"));+ assertFalse(captor.getValue().containsKey("FifoThroughputLimit"));+ }+@Testvoid flippingFifoQueueIsAReplacingUpdate() {// FifoQueue is createOnly too: a prior plain name cannot serve a queue that is now FIFO, so