mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(cloudformation): apply DisplayName on AWS::SNS::Topic (#8693)
AWS::SNS::Topic now forwards DisplayName to the topic, so GetTopicAttributes reports it once the stack is created. An update that drops a DisplayName the previous template declared resets it to empty; one the stack never declared is left alone, in case it is set outside the stack. A value over the documented 100-character limit is rejected with a ValidationError before anything is created, and the "accepted and ignored" row for DisplayName leaves writable-property-gaps.tsv. Closes #8666
This commit is contained in:
1 parent
15519216c3
commit
bf77705ace
3 files changed
+72
-2
No files matched your search
+58
-1
@@ -509,6 +509,58 @@ class SnsCfnProvisionerTest {
|
||||
anyString(), anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
void displayNameIsForwardedOnlyWhenSet() {
|
||||
ArgumentCaptor<Map<String, String>> attrs = ArgumentCaptor.forClass(Map.class);
|
||||
when(sns.createTopic(anyString(), attrs.capture(), anyMap(), anyString())).thenReturn(topic(TOPIC_ARN));
|
||||
|
||||
provision("AWS::SNS::Topic", """
|
||||
{"TopicName": "events", "DisplayName": "Expected Name"}
|
||||
""");
|
||||
assertEquals("Expected Name", attrs.getValue().get("DisplayName"));
|
||||
|
||||
setUp();
|
||||
ArgumentCaptor<Map<String, String>> plain = ArgumentCaptor.forClass(Map.class);
|
||||
when(sns.createTopic(anyString(), plain.capture(), anyMap(), anyString())).thenReturn(topic(TOPIC_ARN));
|
||||
provision("AWS::SNS::Topic", """
|
||||
{"TopicName": "events"}
|
||||
""");
|
||||
assertFalse(plain.getValue().containsKey("DisplayName"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anUpdateThatDropsDisplayNameClearsItButContinuedOmissionDoesNot() {
|
||||
when(sns.createTopic(eq("events"), anyMap(), anyMap(), eq(REGION))).thenReturn(topic(TOPIC_ARN));
|
||||
|
||||
provisionUpdate("""
|
||||
{"TopicName": "events", "DisplayName": "Expected Name"}
|
||||
""", """
|
||||
{"TopicName": "events"}
|
||||
""");
|
||||
verify(sns).setTopicAttributes(TOPIC_ARN, "DisplayName", "", REGION);
|
||||
|
||||
setUp();
|
||||
when(sns.createTopic(eq("events"), anyMap(), anyMap(), eq(REGION))).thenReturn(topic(TOPIC_ARN));
|
||||
provisionUpdate("""
|
||||
{"TopicName": "events"}
|
||||
""", """
|
||||
{"TopicName": "events"}
|
||||
""");
|
||||
verify(sns, never()).setTopicAttributes(anyString(), eq("DisplayName"), anyString(), anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
void displayNameOverOneHundredCharactersIsRejectedBeforeAnythingIsCreated() {
|
||||
String atLimit = "x".repeat(100);
|
||||
when(sns.createTopic(anyString(), anyMap(), anyMap(), anyString())).thenReturn(topic(TOPIC_ARN));
|
||||
provision("AWS::SNS::Topic", "{\"TopicName\": \"events\", \"DisplayName\": \"" + atLimit + "\"}");
|
||||
|
||||
setUp();
|
||||
assertThrows(AwsException.class, () -> provision("AWS::SNS::Topic",
|
||||
"{\"TopicName\": \"events\", \"DisplayName\": \"" + atLimit + "x\"}"));
|
||||
verify(sns, never()).createTopic(anyString(), anyMap(), anyMap(), anyString());
|
||||
}
|
||||
|
||||
/** Real SNS rejects both attributes on a standard topic, so an update must not invent them. */
|
||||
@Test
|
||||
void aStandardTopicUpdateWritesNoFifoDefaults() {
|
||||
@@ -523,6 +575,10 @@ class SnsCfnProvisionerTest {
|
||||
|
||||
/** Provisions an existing topic again, the way UpdateStack re-invokes the provisioner. */
|
||||
private void provisionUpdate(String json) {
|
||||
provisionUpdate(null, json);
|
||||
}
|
||||
|
||||
private void provisionUpdate(String priorJson, String json) {
|
||||
StackResource r = new StackResource();
|
||||
r.setLogicalId("Topic");
|
||||
r.setResourceType("AWS::SNS::Topic");
|
||||
@@ -530,8 +586,9 @@ class SnsCfnProvisionerTest {
|
||||
String priorName = resolved.path("TopicName").asText(null);
|
||||
r.setAttributes(new HashMap<>(Map.of("TopicName", priorName)));
|
||||
r.setPhysicalId(TOPIC_ARN);
|
||||
JsonNode prior = priorJson == null ? null : props(priorJson);
|
||||
provisioner.provision(r, resolved,
|
||||
new ProvisionContext(ctx.engine(), REGION, "000000000000", "my-stack", TOPIC_ARN));
|
||||
new ProvisionContext(ctx.engine(), REGION, "000000000000", "my-stack", TOPIC_ARN, null, prior));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user