Skip to content

armgit / floci

Public Imported from GitHub
0

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

feat(ec2): return an empty set for DescribeVpnGateways (#1975)

lex003baf4f48496d
diff --git a/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2QueryHandler.java b/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2QueryHandler.java
index 268604a1d7..53eaca02a4 100644
--- a/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2QueryHandler.java
+++ b/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2QueryHandler.java
@@ -111,6 +111,11 @@ public class Ec2QueryHandler {
case "DeleteInternetGateway" -> handleDeleteInternetGateway(params, region);
case "AttachInternetGateway" -> handleAttachInternetGateway(params, region);
case "DetachInternetGateway" -> handleDetachInternetGateway(params, region);
+ // VPN Gateways. There is no VPN gateway model; an empty set is
+ // AWS-accurate for an account without VPN gateways and unblocks the
+ // CDK VPC context provider, which always issues this describe.
+ case "DescribeVpnGateways" -> handleDescribeVpnGateways();
+
// Route Tables
case "CreateRouteTable" -> handleCreateRouteTable(params, region);
case "DescribeRouteTables" -> handleDescribeRouteTables(params, region);
@@ -1435,6 +1440,16 @@ public class Ec2QueryHandler {
return xmlResponse(xml.build());
}
+ private Response handleDescribeVpnGateways() {
+ XmlBuilder xml = new XmlBuilder()
+ .start("DescribeVpnGatewaysResponse", AwsNamespaces.EC2)
+ .elem("requestId", UUID.randomUUID().toString())
+ .start("vpnGatewaySet")
+ .end("vpnGatewaySet")
+ .end("DescribeVpnGatewaysResponse");
+ return xmlResponse(xml.build());
+ }
+
private Response handleDescribeRouteTables(MultivaluedMap<String, String> p, String region) {
List<String> ids = getList(p, "RouteTableId");
Map<String, List<String>> filters = getFilters(p);
diff --git a/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2IntegrationTest.java
index d023bfa316..ee22c5a21a 100644
--- a/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2IntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2IntegrationTest.java
@@ -1,6 +1,8 @@
package io.github.hectorvent.floci.services.ec2;
import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.emptyOrNullString;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.everyItem;
@@ -1304,6 +1306,20 @@ class Ec2IntegrationTest {
.statusCode(200);
}
+ @Test
+ @Order(52)
+ void describeVpnGatewaysReturnsEmptySet() {
+ given()
+ .formParam("Action", "DescribeVpnGateways")
+ .header("Authorization", AUTH_HEADER)
+ .when()
+ .post("/")
+ .then()
+ .statusCode(200)
+ .body("DescribeVpnGatewaysResponse.vpnGatewaySet.item.size()", equalTo(0))
+ .body(not(containsString("UnsupportedOperation")));
+ }
+
@Test
@Order(52)
void describeInternetGateways() {