Light, fluffy, and always free - The AWS Local Emulator alternative
Add integration test cases for DeleteChangeSet command
Benjamin Hintzc5c76c64ae97
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.javaindex aeda3a2796..0756a765c6 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@@ -5,6 +5,7 @@ import org.junit.jupiter.api.Test;import static io.restassured.RestAssured.given;import static org.hamcrest.Matchers.containsString;+import static org.hamcrest.Matchers.not;@QuarkusTestclass CloudFormationIntegrationTest {@@ -73,4 +74,122 @@ class CloudFormationIntegrationTest {.body(containsString("<StackName>test-stack</StackName>")).body(containsString("<StackStatus>CREATE_COMPLETE</StackStatus>"));}++ @Test+ void deleteChangeSet_removesChangeSet() {+ String template = """+ {+ "Resources": {+ "MyBucket": {+ "Type": "AWS::S3::Bucket",+ "Properties": {+ "BucketName": "cs-delete-test-bucket"+ }+ }+ }+ }+ """;++ // 1. Create a ChangeSet (implicitly creates the stack)+ given()+ .contentType("application/x-www-form-urlencoded")+ .formParam("Action", "CreateChangeSet")+ .formParam("StackName", "cs-delete-stack")+ .formParam("ChangeSetName", "my-changeset")+ .formParam("ChangeSetType", "CREATE")+ .formParam("TemplateBody", template)+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body(containsString("<Id>"));++ // 2. Verify ChangeSet exists+ given()+ .contentType("application/x-www-form-urlencoded")+ .formParam("Action", "DescribeChangeSet")+ .formParam("StackName", "cs-delete-stack")+ .formParam("ChangeSetName", "my-changeset")+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body(containsString("<ChangeSetName>my-changeset</ChangeSetName>"));++ // 3. Delete the ChangeSet+ given()+ .contentType("application/x-www-form-urlencoded")+ .formParam("Action", "DeleteChangeSet")+ .formParam("StackName", "cs-delete-stack")+ .formParam("ChangeSetName", "my-changeset")+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body(containsString("<DeleteChangeSetResult/>"));++ // 4. Verify ChangeSet no longer exists+ given()+ .contentType("application/x-www-form-urlencoded")+ .formParam("Action", "DescribeChangeSet")+ .formParam("StackName", "cs-delete-stack")+ .formParam("ChangeSetName", "my-changeset")+ .when()+ .post("/")+ .then()+ .statusCode(400)+ .body(containsString("ChangeSetNotFoundException"));++ // 5. Verify ChangeSet is absent from ListChangeSets+ given()+ .contentType("application/x-www-form-urlencoded")+ .formParam("Action", "ListChangeSets")+ .formParam("StackName", "cs-delete-stack")+ .when()+ .post("/")+ .then()+ .statusCode(200)+ .body(not(containsString("my-changeset")));+ }++ @Test+ void deleteChangeSet_nonExistentChangeSet_returnsError() {+ String template = """+ {+ "Resources": {+ "MyBucket": {+ "Type": "AWS::S3::Bucket",+ "Properties": {+ "BucketName": "cs-error-test-bucket"+ }+ }+ }+ }+ """;++ // Create a stack via CreateChangeSet so the stack exists+ given()+ .contentType("application/x-www-form-urlencoded")+ .formParam("Action", "CreateChangeSet")+ .formParam("StackName", "cs-error-stack")+ .formParam("ChangeSetName", "existing-changeset")+ .formParam("ChangeSetType", "CREATE")+ .formParam("TemplateBody", template)+ .when()+ .post("/")+ .then()+ .statusCode(200);++ // Attempt to delete a changeset that does not exist+ given()+ .contentType("application/x-www-form-urlencoded")+ .formParam("Action", "DeleteChangeSet")+ .formParam("StackName", "cs-error-stack")+ .formParam("ChangeSetName", "nonexistent-changeset")+ .when()+ .post("/")+ .then()+ .statusCode(400)+ .body(containsString("ChangeSetNotFoundException"));+ }}