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 a45102db81..93d2b3f202 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 @@ -245,7 +245,9 @@ public class ElbV2QueryHandler { .start("SetSecurityGroupsResponse", AwsNamespaces.ELB_V2) .start("SetSecurityGroupsResult") .start("SecurityGroupIds"); - for (String sg : sgs) xml.start("member").elem("member", sg).end("member"); + for (String sg : sgs) { + xml.elem("member", sg); + } xml.end("SecurityGroupIds") .end("SetSecurityGroupsResult") .raw(AwsQueryResponse.responseMetadata()) 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 4d54eb2632..106928ffdb 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 @@ -351,6 +351,39 @@ class ElbV2IntegrationTest { hasItems(Ec2Service.defaultSubnetId("us-east-1", "b"), Ec2Service.defaultSubnetId("us-east-1", "c"))); } + @Test + @Order(9) + void setSecurityGroupsReturnsSecurityGroupIdsAsFlatMemberList() { + given() + .formParam("Action", "SetSecurityGroups") + .formParam("LoadBalancerArn", lbArn) + .formParam("SecurityGroups.member.1", "sg-0123456789abcdef0") + .formParam("SecurityGroups.member.2", "sg-0fedcba9876543210") + .header("Authorization", AUTH) + .when() + .post("/") + .then() + .statusCode(200) + .contentType("application/xml") + .body(containsString("sg-0123456789abcdef0" + + "sg-0fedcba9876543210")) + .body(not(containsString(""))) + .body("SetSecurityGroupsResponse.SetSecurityGroupsResult.SecurityGroupIds.member", + contains("sg-0123456789abcdef0", "sg-0fedcba9876543210")) + .body("SetSecurityGroupsResponse.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.SecurityGroups.member", + contains("sg-0123456789abcdef0", "sg-0fedcba9876543210")); + } + @Test @Order(17) void createAndSetSubnetMappingsDriveSubnetsAndVpcId() {