Light, fluffy, and always free - The AWS Local Emulator alternative
fix(elb): return TargetGroupNotFound for missing target groups (#1161)
JonghyeokNam289e1e963059
diff --git a/src/main/java/io/github/hectorvent/floci/services/elbv2/ElbV2Service.java b/src/main/java/io/github/hectorvent/floci/services/elbv2/ElbV2Service.javaindex 3614ad945c..42458dc5ba 100644--- a/src/main/java/io/github/hectorvent/floci/services/elbv2/ElbV2Service.java+++ b/src/main/java/io/github/hectorvent/floci/services/elbv2/ElbV2Service.java@@ -238,13 +238,16 @@ public class ElbV2Service {if (tgArns != null && !tgArns.isEmpty()) {Set<String> arnSet = new HashSet<>(tgArns);result = result.stream().filter(tg -> arnSet.contains(tg.getTargetGroupArn())).collect(Collectors.toList());- if (result.isEmpty()) {+ if (result.size() != arnSet.size()) {throw new AwsException("TargetGroupNotFound", "One or more target groups not found.", 400);}}if (names != null && !names.isEmpty()) {Set<String> nameSet = new HashSet<>(names);result = result.stream().filter(tg -> nameSet.contains(tg.getTargetGroupName())).collect(Collectors.toList());+ if (result.size() != nameSet.size()) {+ throw new AwsException("TargetGroupNotFound", "One or more target groups not found.", 400);+ }}return result;}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.javaindex 7eab92be07..90b3bb72a1 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@@ -246,6 +246,35 @@ class ElbV2IntegrationTest {equalTo("deregistration_delay.timeout_seconds"));}+ @Test+ @Order(14)+ void describeTargetGroupsByMissingNameThrows() {+ given()+ .formParam("Action", "DescribeTargetGroups")+ .formParam("Names.member.1", "target-group-that-does-not-exist")+ .header("Authorization", AUTH)+ .when()+ .post("/")+ .then()+ .statusCode(400)+ .body("ErrorResponse.Error.Code", equalTo("TargetGroupNotFound"));+ }++ @Test+ @Order(15)+ void describeTargetGroupsByMissingArnThrows() {+ given()+ .formParam("Action", "DescribeTargetGroups")+ .formParam("TargetGroupArns.member.1",+ "arn:aws:elasticloadbalancing:us-east-1:000000000000:targetgroup/missing/0123456789abcdef")+ .header("Authorization", AUTH)+ .when()+ .post("/")+ .then()+ .statusCode(400)+ .body("ErrorResponse.Error.Code", equalTo("TargetGroupNotFound"));+ }+// ── Targets ───────────────────────────────────────────────────────────────@Test