Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

fix: wrap ELBv2 void query responses in their Result envelope (#1189)

Matt Van Horn189d893803bb
diff --git a/src/main/java/io/github/hectorvent/floci/services/elbv2/ElbV2QueryHandler.java b/src/main/java/io/github/hectorvent/floci/services/elbv2/ElbV2QueryHandler.java
index 45b0dc10a6..e0af962277 100644
--- a/src/main/java/io/github/hectorvent/floci/services/elbv2/ElbV2QueryHandler.java
+++ b/src/main/java/io/github/hectorvent/floci/services/elbv2/ElbV2QueryHandler.java
@@ -1233,8 +1233,12 @@ public class ElbV2QueryHandler {
// ── Misc helpers ─────────────────────────────────────────────────────────
private Response voidResponse(String responseName) {
+ String actionName = responseName.substring(0, responseName.length() - "Response".length());
+ String resultName = actionName + "Result";
String xml = new XmlBuilder()
.start(responseName, AwsNamespaces.ELB_V2)
+ .start(resultName)
+ .end(resultName)
.raw(AwsQueryResponse.responseMetadata())
.end(responseName)
.build();
diff --git a/src/test/java/io/github/hectorvent/floci/services/elbv2/ElbV2IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/elbv2/ElbV2IntegrationTest.java
index 6822eb7ff6..28cf1235fa 100644
--- a/src/test/java/io/github/hectorvent/floci/services/elbv2/ElbV2IntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/elbv2/ElbV2IntegrationTest.java
@@ -20,6 +20,8 @@ class ElbV2IntegrationTest {
"AWS4-HMAC-SHA256 Credential=test/20260427/us-east-1/elasticloadbalancing/aws4_request";
private static final String EC2_AUTH =
"AWS4-HMAC-SHA256 Credential=test/20260427/us-east-1/ec2/aws4_request";
+ private static final String ELB_V2_XMLNS =
+ "https://elasticloadbalancing.amazonaws.com/doc/2015-12-01/";
private static String lbArn;
private static String tgArn;
@@ -223,6 +225,38 @@ class ElbV2IntegrationTest {
equalTo("us-east-1b"));
}
+ @Test
+ @Order(9)
+ void setSubnetsReturnsEmptyResultEnvelope() {
+ given()
+ .formParam("Action", "SetSubnets")
+ .formParam("LoadBalancerArn", lbArn)
+ .formParam("Subnets.member.1", "subnet-default-b")
+ .formParam("Subnets.member.2", "subnet-default-c")
+ .header("Authorization", AUTH)
+ .when()
+ .post("/")
+ .then()
+ .statusCode(200)
+ .contentType("application/xml")
+ .body(containsString("<SetSubnetsResponse xmlns=\"" + ELB_V2_XMLNS + "\">"))
+ .body(containsString("<SetSubnetsResult></SetSubnetsResult>"))
+ .body("SetSubnetsResponse.ResponseMetadata.RequestId", not(emptyOrNullString()));
+
+ given()
+ .formParam("Action", "DescribeLoadBalancers")
+ .formParam("LoadBalancerArns.member.1", lbArn)
+ .header("Authorization", AUTH)
+ .when()
+ .post("/")
+ .then()
+ .statusCode(200)
+ .body("DescribeLoadBalancersResponse.DescribeLoadBalancersResult.LoadBalancers.member.AvailabilityZones.member.SubnetId",
+ hasItems("subnet-default-b", "subnet-default-c"));
+ }
+
+ // ── Target Groups ─────────────────────────────────────────────────────────
+
@Test
@Order(10)
void createLoadBalancerWithSubnetsFromDifferentVpcsThrows() {
@@ -979,7 +1013,11 @@ class ElbV2IntegrationTest {
.when()
.post("/")
.then()
- .statusCode(200);
+ .statusCode(200)
+ .contentType("application/xml")
+ .body(containsString("<DeleteListenerResponse xmlns=\"" + ELB_V2_XMLNS + "\">"))
+ .body(containsString("<DeleteListenerResult></DeleteListenerResult>"))
+ .body("DeleteListenerResponse.ResponseMetadata.RequestId", not(emptyOrNullString()));
given()
.formParam("Action", "DescribeListeners")
@@ -990,6 +1028,20 @@ class ElbV2IntegrationTest {
.then()
.statusCode(200)
.body("DescribeListenersResponse.DescribeListenersResult.Listeners.member.size()", equalTo(0));
+
+ given()
+ .formParam("Action", "DeleteTargetGroup")
+ .formParam("TargetGroupArn", tgArn)
+ .header("Authorization", AUTH)
+ .when()
+ .post("/")
+ .then()
+ .statusCode(200)
+ .contentType("application/xml")
+ .body(containsString("<DeleteTargetGroupResponse xmlns=\"" + ELB_V2_XMLNS + "\">"))
+ .body(containsString("<DeleteTargetGroupResult></DeleteTargetGroupResult>"))
+ .body("DeleteTargetGroupResponse.ResponseMetadata.RequestId", not(emptyOrNullString()));
+ tgArn = null;
}
@Test
@@ -1017,7 +1069,11 @@ class ElbV2IntegrationTest {
.when()
.post("/")
.then()
- .statusCode(200);
+ .statusCode(200)
+ .contentType("application/xml")
+ .body(containsString("<DeleteLoadBalancerResponse xmlns=\"" + ELB_V2_XMLNS + "\">"))
+ .body(containsString("<DeleteLoadBalancerResult></DeleteLoadBalancerResult>"))
+ .body("DeleteLoadBalancerResponse.ResponseMetadata.RequestId", not(emptyOrNullString()));
given()
.formParam("Action", "DescribeLoadBalancers")