diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationIntegrationTest.java index 10549ced6a..0fb1b2b34f 100644 --- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationIntegrationTest.java @@ -5284,6 +5284,15 @@ class CloudFormationIntegrationTest { .formParam("TemplateBody", template) .when().post("/") .then().statusCode(200); + + // Tear the recreated stack back down so the security group is not left behind in the + // shared in-memory EC2 store, where it would pollute other tests' DescribeSecurityGroups. + given() + .formParam("Action", "DeleteStack") + .formParam("Version", "2010-05-15") + .formParam("StackName", stackName) + .when().post("/") + .then().statusCode(200); } @Test diff --git a/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2IntegrationTest.java index 064a9c3fb2..5d0f9aa6b5 100644 --- a/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2IntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2IntegrationTest.java @@ -92,8 +92,16 @@ class Ec2IntegrationTest { @Test @Order(3) void describeDefaultSecurityGroup() { + // Filter to the default VPC's default group rather than assuming it is item[0] of an + // unfiltered list: DescribeSecurityGroups returns groups in the store's iteration order, + // so any other group in this region (e.g. one left behind by another test class sharing + // the in-memory EC2 store) could otherwise land at item[0] and flake this assertion. given() .formParam("Action", "DescribeSecurityGroups") + .formParam("Filter.1.Name", "group-name") + .formParam("Filter.1.Value.1", "default") + .formParam("Filter.2.Name", "vpc-id") + .formParam("Filter.2.Value.1", "vpc-default") .header("Authorization", AUTH_HEADER) .when() .post("/")