mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
Add integration test cases for DeleteChangeSet command
This commit is contained in:
1 parent
794939c331
commit
c5c76c64ae
1 file changed
+119
+119
@@ -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;
|
||||
|
||||
@QuarkusTest
|
||||
class 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"));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user