mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
test(cloudformation): reuse physical ID helpers in group and API tests (#7688)
This commit is contained in:
1 parent
d9f0bab177
commit
949eb894e9
2 files changed
+6
-28
No files matched your search
+3
-6
@@ -16,6 +16,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static io.floci.aws.testing.CfnRequests.cfn;
|
||||
import static io.floci.aws.testing.CfnRequests.physicalIdUnauthenticated;
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
@@ -69,7 +70,7 @@ class ApiGatewayRestApiCfnUpdateRollbackRetryIntegrationTest {
|
||||
try {
|
||||
stackAction(stack, "CreateStack", TEMPLATE.formatted(name, "first", "REGIONAL", ""));
|
||||
assertEquals("CREATE_COMPLETE", CfnStackWaits.awaitTerminal(stack).status());
|
||||
String apiId = physicalId(stack);
|
||||
String apiId = physicalIdUnauthenticated(stack, "Api");
|
||||
// After putRestApi accepted the document, applying the declared name and description
|
||||
// again (just those two operations) fails once.
|
||||
Mockito.doThrow(new AwsException("TooManyRequestsException", "Too Many Requests", 429))
|
||||
@@ -108,7 +109,7 @@ class ApiGatewayRestApiCfnUpdateRollbackRetryIntegrationTest {
|
||||
try {
|
||||
stackAction(stack, "CreateStack", TEMPLATE.formatted(name, "first", "REGIONAL", ""));
|
||||
assertEquals("CREATE_COMPLETE", CfnStackWaits.awaitTerminal(stack).status());
|
||||
String apiId = physicalId(stack);
|
||||
String apiId = physicalIdUnauthenticated(stack, "Api");
|
||||
// The import rejects the document, and the first restore of the patch fails.
|
||||
ArgumentMatcher<List<Map<String, String>>> restore =
|
||||
operations -> operations != null && operations.contains(replace("/description", "first"));
|
||||
@@ -152,10 +153,6 @@ class ApiGatewayRestApiCfnUpdateRollbackRetryIntegrationTest {
|
||||
.body("item.path", containsInAnyOrder(paths));
|
||||
}
|
||||
|
||||
private static String physicalId(String stack) {
|
||||
return XmlParser.extractFirst(apiResource(stack), "PhysicalResourceId", null);
|
||||
}
|
||||
|
||||
private static String apiResourceReason(String stack) {
|
||||
return XmlParser.extractFirst(apiResource(stack), "ResourceStatusReason", null);
|
||||
}
|
||||
|
||||
+3
-22
@@ -1,6 +1,7 @@
|
||||
package io.floci.aws.services.cloudformation;
|
||||
|
||||
import io.floci.aws.core.common.XmlParser;
|
||||
import io.floci.aws.testing.CfnRequests;
|
||||
import io.floci.aws.testing.CfnStackWaits;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.RestAssured;
|
||||
@@ -218,17 +219,7 @@ class CloudFormationCognitoUserPoolGroupIntegrationTest {
|
||||
CfnStackWaits.StackState state = CfnStackWaits.awaitTerminal(stackName);
|
||||
assertEquals("UPDATE_ROLLBACK_COMPLETE", state.status(), state.reason());
|
||||
assertEquals(name, output(describeStack(stackName), "GroupRef"));
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", CFN_AUTH)
|
||||
.formParam("Action", "DescribeStackResource")
|
||||
.formParam("StackName", stackName)
|
||||
.formParam("LogicalResourceId", "Group")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("<PhysicalResourceId>" + name + "</PhysicalResourceId>"));
|
||||
assertEquals(name, CfnRequests.physicalId(stackName, "Group", CFN_AUTH));
|
||||
cognito("GetGroup", "{\"UserPoolId\": \"" + firstPool + "\", \"GroupName\": \"" + name + "\"}")
|
||||
.statusCode(200)
|
||||
.body("Group.Description", equalTo("d1"))
|
||||
@@ -277,17 +268,7 @@ class CloudFormationCognitoUserPoolGroupIntegrationTest {
|
||||
assertThat(failures, contains(containsString("CloudFormation cannot update a stack when a custom-named"
|
||||
+ " resource requires replacing. Rename " + generated + " and update the stack again.")));
|
||||
assertEquals(generated, output(describeStack(stackName), "GroupRef"));
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", CFN_AUTH)
|
||||
.formParam("Action", "DescribeStackResource")
|
||||
.formParam("StackName", stackName)
|
||||
.formParam("LogicalResourceId", "Group")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(containsString("<PhysicalResourceId>" + generated + "</PhysicalResourceId>"));
|
||||
assertEquals(generated, CfnRequests.physicalId(stackName, "Group", CFN_AUTH));
|
||||
cognito("GetGroup", "{\"UserPoolId\": \"" + poolId + "\", \"GroupName\": \"" + generated + "\"}")
|
||||
.statusCode(200)
|
||||
.body("Group.Description", equalTo("d1"))
|
||||
|
||||
Reference in new issue
Block a user