diff --git a/src/main/java/io/github/hectorvent/floci/core/common/AwsQueryController.java b/src/main/java/io/github/hectorvent/floci/core/common/AwsQueryController.java index 152ef96aaa..c6f9016222 100644 --- a/src/main/java/io/github/hectorvent/floci/core/common/AwsQueryController.java +++ b/src/main/java/io/github/hectorvent/floci/core/common/AwsQueryController.java @@ -168,7 +168,8 @@ public class AwsQueryController { "DescribeInstanceTypes", "DescribeInstanceTypeOfferings", "CreateLaunchTemplate", "CreateLaunchTemplateVersion", "DescribeLaunchTemplates", "DescribeLaunchTemplateVersions", "ModifyLaunchTemplate", "DeleteLaunchTemplate", - "DescribeNetworkInterfaces" + "DescribeNetworkInterfaces", + "CreateVolume", "DescribeVolumes", "DeleteVolume" ); private final CloudFormationQueryHandler cloudFormationQueryHandler; @@ -240,7 +241,8 @@ public class AwsQueryController { String action = formParams.getFirst("Action"); if (action == null) { - return null; + return xmlErrorResponse("MissingAction", + "The request must contain the parameter Action", 400); } String service = resolveService(authorization, action); diff --git a/src/test/java/io/github/hectorvent/floci/core/common/AwsQueryControllerIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/core/common/AwsQueryControllerIntegrationTest.java new file mode 100644 index 0000000000..c3cea450a5 --- /dev/null +++ b/src/test/java/io/github/hectorvent/floci/core/common/AwsQueryControllerIntegrationTest.java @@ -0,0 +1,38 @@ +package io.github.hectorvent.floci.core.common; + +import io.quarkus.test.junit.QuarkusTest; +import org.junit.jupiter.api.Test; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.greaterThan; + +@QuarkusTest +class AwsQueryControllerIntegrationTest { + + @Test + void missingActionParameterReturns400MissingAction() { + given() + .contentType("application/x-www-form-urlencoded") + .when() + .post("/") + .then() + .statusCode(400) + .contentType("application/xml") + .body("ErrorResponse.Error.Code", equalTo("MissingAction")) + .body("ErrorResponse.Error.Message", equalTo("The request must contain the parameter Action")); + } + + @Test + void ec2ActionFallbackWithoutAuthorizationHeader() { + given() + .contentType("application/x-www-form-urlencoded") + .formParam("Action", "DescribeRegions") + .when() + .post("/") + .then() + .statusCode(200) + .contentType("application/xml") + .body("DescribeRegionsResponse.regionInfo.item.size()", greaterThan(0)); + } +}