diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationCustomResourceRollbackIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationCustomResourceRollbackIntegrationTest.java index 07835a988a..7b562c7eee 100644 --- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationCustomResourceRollbackIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationCustomResourceRollbackIntegrationTest.java @@ -15,6 +15,7 @@ import org.junit.jupiter.api.Test; import java.util.List; import java.util.Map; +import static io.github.hectorvent.floci.testing.CfnRequests.physicalIdUnauthenticated; import static io.restassured.RestAssured.given; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -57,7 +58,7 @@ class CloudFormationCustomResourceRollbackIntegrationTest { String stackName = "cr-rollback-" + Long.toString(System.nanoTime(), 36); String stackId = createStack(stackName, template("1", false)); awaitStackStatus(stackId, "CREATE_COMPLETE"); - String physicalId = probePhysicalId(stackName); + String physicalId = physicalIdUnauthenticated(stackName, "Probe"); updateStack(stackName, template("2", true)); awaitStackStatus(stackId, "UPDATE_ROLLBACK_COMPLETE"); @@ -67,7 +68,7 @@ class CloudFormationCustomResourceRollbackIntegrationTest { assertProperties(probe.events().get(1), "2", "1"); assertProperties(probe.events().get(2), "1", "2"); assertEquals(physicalId, probe.events().get(2).get("PhysicalResourceId").asText()); - assertEquals(physicalId, probePhysicalId(stackName)); + assertEquals(physicalId, physicalIdUnauthenticated(stackName, "Probe")); assertFalse(describeStackEvents(stackId).contains("Rollback is not implemented")); } @@ -98,7 +99,7 @@ class CloudFormationCustomResourceRollbackIntegrationTest { String stackName = "cr-own-update-failed-" + Long.toString(System.nanoTime(), 36); String stackId = createStack(stackName, template("1", false)); awaitStackStatus(stackId, "CREATE_COMPLETE"); - String physicalId = probePhysicalId(stackName); + String physicalId = physicalIdUnauthenticated(stackName, "Probe"); updateStack(stackName, template("3", false)); awaitStackStatus(stackId, "UPDATE_ROLLBACK_COMPLETE"); @@ -108,7 +109,7 @@ class CloudFormationCustomResourceRollbackIntegrationTest { assertProperties(probe.events().get(1), "3", "1"); assertProperties(probe.events().get(2), "1", "3"); assertEquals(physicalId, probe.events().get(2).get("PhysicalResourceId").asText()); - assertEquals(physicalId, probePhysicalId(stackName)); + assertEquals(physicalId, physicalIdUnauthenticated(stackName, "Probe")); List probeStatuses = XmlParser.extractGroups(describeStackEvents(stackId), "member") .reversed() .stream() @@ -125,7 +126,7 @@ class CloudFormationCustomResourceRollbackIntegrationTest { String stackName = "cr-delete-after-failed-" + Long.toString(System.nanoTime(), 36); String stackId = createStack(stackName, template("1", false)); awaitStackStatus(stackId, "CREATE_COMPLETE"); - String physicalId = probePhysicalId(stackName); + String physicalId = physicalIdUnauthenticated(stackName, "Probe"); updateStack(stackName, template("2", true)); awaitStackStatus(stackId, "UPDATE_ROLLBACK_FAILED"); @@ -209,12 +210,6 @@ class CloudFormationCustomResourceRollbackIntegrationTest { cfn(Map.of("Action", "DeleteStack", "StackName", stackName)); } - private static String probePhysicalId(String stackName) { - String xml = cfn(Map.of("Action", "DescribeStackResource", "StackName", stackName, - "LogicalResourceId", "Probe")); - return XmlParser.extractFirst(xml, "PhysicalResourceId", null); - } - private static String describeStackEvents(String stackId) { return cfn(Map.of("Action", "DescribeStackEvents", "StackName", stackId)); } diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationCustomResourceUsesIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationCustomResourceUsesIntegrationTest.java index 279da567b2..61e40e80bd 100644 --- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationCustomResourceUsesIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationCustomResourceUsesIntegrationTest.java @@ -12,6 +12,7 @@ import org.junit.jupiter.api.Test; import java.util.Map; +import static io.github.hectorvent.floci.testing.CfnRequests.physicalIdUnauthenticated; import static io.restassured.RestAssured.given; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -57,7 +58,7 @@ class CloudFormationCustomResourceUsesIntegrationTest { Map kept = attributes(stack); assertEquals(stack + "-data", kept.get(USES + "Data"), kept::toString); - assertEquals(queueUrl(stack), kept.get(USES + "Queue"), kept::toString); + assertEquals(physicalIdUnauthenticated(stack, "Queue"), kept.get(USES + "Queue"), kept::toString); assertFalse(kept.containsValue(stack + ".example.com"), kept::toString); updateStack(stack, template(stack, "Archive", "")); @@ -168,12 +169,6 @@ class CloudFormationCustomResourceUsesIntegrationTest { .getResources().get("Emptier").getAttributes(); } - private static String queueUrl(String stack) { - String xml = cfn(Map.of("Action", "DescribeStackResource", "StackName", stack, - "LogicalResourceId", "Queue")); - return XmlParser.extractFirst(xml, "PhysicalResourceId", null); - } - private static String createStack(String stackName, String template) { String xml = cfn(Map.of("Action", "CreateStack", "StackName", stackName, "TemplateBody", template)); return XmlParser.extractFirst(xml, "StackId", null);