test(compat): validate the endpoint's network interface ids through the Java SDK

Greptile's P2 on #4598. The integration test asserts the wire element over RestAssured,
which is deliberate -- an absent networkInterfaceIdSet and an empty one are different
things and only raw XML can tell them apart. But AGENTS.md's "Management APIs should be
validated with AWS SDK clients, not only handcrafted HTTP requests" sits under AWS Protocol
Rules, not under Compatibility Project, so it is general and "not only" is the operative
phrase. Both, not either.

src/test cannot host it: the main module has no AWS SDK dependency at all. sdk-test-java is
where the repo keeps SDK validation and already had 60 EC2 tests, covering
DescribeVpcEndpointServices but not an endpoint's own interfaces.

What this proves that the XML assertions cannot: that the real Java SDK DESERIALIZES the
element into networkInterfaceIds(). A response can be well-formed XML and still not populate
the model -- a wrong element name or nesting fails silently and leaves an empty list rather
than raising, which is the exact symptom this PR fixes.

Asserted on CreateVpcEndpoint and again on DescribeVpcEndpoints, and that the two agree,
because Terraform reads from one and re-reads from the other between plan and apply.

DeleteVpc moves from @Order(50) to @Order(51) so this runs while the shared VPC still
exists.
This commit is contained in:
Allen Sanborn committed 2026-09-29 10:47:00 -05:00
1 parent 3b0e208d16
commit 1608dc7733
1 file changed
+45
@@ -969,6 +969,51 @@ class Ec2Tests {
@Test
@Order(50)
@DisplayName("DescribeVpcEndpoints - an interface endpoint reports its network interfaces")
void describeVpcEndpointsReportsNetworkInterfaceIds() {
// The wire element is networkInterfaceIdSet, and the point of asserting it HERE
// rather than only over raw XML is that this proves the real Java SDK deserializes
// it into networkInterfaceIds(). A response can be well-formed XML and still not
// populate the SDK model -- a wrong element name or nesting fails silently, leaving
// an empty list rather than an error, which is exactly the symptom being fixed.
String endpointId = null;
try {
CreateVpcEndpointResponse created = ec2.createVpcEndpoint(
CreateVpcEndpointRequest.builder()
.vpcId(vpcId)
.serviceName("com.amazonaws.us-east-1.ec2")
.vpcEndpointType(VpcEndpointType.INTERFACE)
.subnetIds(subnetId)
.build());
endpointId = created.vpcEndpoint().vpcEndpointId();
// Asserted on the CREATE response and again on DESCRIBE, because Terraform
// reads the ids from one and then re-reads them from the other between plan
// and apply; both renderings have to agree.
assertThat(created.vpcEndpoint().networkInterfaceIds())
.as("CreateVpcEndpoint response")
.hasSize(1)
.allMatch(id -> id.matches("eni-[0-9a-f]{17}"));
DescribeVpcEndpointsResponse described = ec2.describeVpcEndpoints(
DescribeVpcEndpointsRequest.builder().vpcEndpointIds(endpointId).build());
VpcEndpoint ep = described.vpcEndpoints().get(0);
assertThat(ep.networkInterfaceIds())
.as("DescribeVpcEndpoints response")
.isEqualTo(created.vpcEndpoint().networkInterfaceIds());
assertThat(ep.groups()).isNotEmpty();
assertThat(ep.dnsEntries()).isNotEmpty();
} finally {
if (endpointId != null) {
ec2.deleteVpcEndpoints(DeleteVpcEndpointsRequest.builder()
.vpcEndpointIds(endpointId).build());
}
}
}
@Test
@Order(51)
@DisplayName("DeleteVpc - delete VPC")
void deleteVpc() {
ec2.deleteVpc(DeleteVpcRequest.builder().vpcId(vpcId).build());