mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat(route53resolver): implement ListResolverEndpointIpAddresses (#5731)
* feat(route53resolver): implement ListResolverEndpointIpAddresses The Terraform provider lists an endpoint's IP addresses right after CreateResolverEndpoint, so the missing operation (UnknownOperationException) failed every aws_route53_resolver_endpoint create. Built from the IpAddresses recorded at create time: one ATTACHED entry per request with a deterministic rni- IpId. Unknown endpoint ids raise ResourceNotFoundException. Not paginated, like the sibling List operations. * docs(route53resolver): update service matrix operation count * refactor(route53resolver): add endpoint IP addresses with a single addAll * fix(route53resolver): distinct IpIds for repeated entries; fail on missing IP record ListResolverEndpointIpAddresses hashed only the endpoint id and the entry, so two identical entries (two addresses in one subnet, both left for AWS to pick, which IpAddressesRequest allows) shared an IpId. Include the entry's position in the recorded list, which is normalised once at create and so stable across reads. An endpoint whose recorded IP requests are missing returned an empty list beside a nonzero IpAddressCount. Throw the modeled InternalServiceErrorException instead. * test(route53resolver): import List/HashSet instead of fully qualifying (checkstyle NoFqcn) * fix(route53resolver): return InternalServiceErrorException as HTTP 400 The Route 53 Resolver model gives InternalServiceErrorException no httpStatusCode, so clients expect the awsJson default of 400, as with every other Resolver error.
This commit is contained in:
1 parent
5544a119d3
commit
a37c27516a
6 files changed
+161
-2
No files matched your search
+102
@@ -5,10 +5,18 @@ import io.quarkus.test.junit.QuarkusTest;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.everyItem;
|
||||
import static org.hamcrest.Matchers.hasItems;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* Integration tests for Route 53 Resolver DNS Firewall operations
|
||||
@@ -166,6 +174,100 @@ class Route53ResolverIntegrationTest {
|
||||
.body("message", equalTo("IpAddresses is required"));
|
||||
}
|
||||
|
||||
// ── ListResolverEndpointIpAddresses ─────────────────────────────────────────
|
||||
//
|
||||
// The Terraform provider calls this right after CreateResolverEndpoint to read the
|
||||
// endpoint's ip_address set, so an unimplemented operation fails every endpoint create.
|
||||
|
||||
private static String listIpAddresses(String endpointId) {
|
||||
return given()
|
||||
.contentType(CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "Route53Resolver.ListResolverEndpointIpAddresses")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.body("{\"ResolverEndpointId\":\"" + endpointId + "\"}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract().asString();
|
||||
}
|
||||
|
||||
@Test
|
||||
void listResolverEndpointIpAddresses_returnsTheAddressesTheEndpointWasCreatedWith() {
|
||||
String endpointId = given()
|
||||
.contentType(CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "Route53Resolver.CreateResolverEndpoint")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.body("{\"Name\":\"ep-ips\",\"Direction\":\"OUTBOUND\",\"CreatorRequestId\":\"list-ips-1\","
|
||||
+ "\"SecurityGroupIds\":[\"sg-abc123\"],"
|
||||
+ "\"IpAddresses\":[{\"SubnetId\":\"subnet-aaa\",\"Ip\":\"10.0.1.10\"},"
|
||||
+ "{\"SubnetId\":\"subnet-bbb\"}]}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract().path("ResolverEndpoint.Id");
|
||||
|
||||
given()
|
||||
.contentType(CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "Route53Resolver.ListResolverEndpointIpAddresses")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.body("{\"ResolverEndpointId\":\"" + endpointId + "\"}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("IpAddresses.size()", equalTo(2))
|
||||
.body("IpAddresses.SubnetId", containsInAnyOrder("subnet-aaa", "subnet-bbb"))
|
||||
.body("IpAddresses.find { it.SubnetId == 'subnet-aaa' }.Ip", equalTo("10.0.1.10"))
|
||||
.body("IpAddresses.find { it.SubnetId == 'subnet-bbb' }.Ip", nullValue())
|
||||
.body("IpAddresses.Status", everyItem(equalTo("ATTACHED")))
|
||||
.body("IpAddresses.IpId", everyItem(startsWith("rni-")))
|
||||
.body("IpAddresses.CreationTime", everyItem(notNullValue()));
|
||||
|
||||
// IpId is the provider's handle on each address, so it must not change between reads.
|
||||
assertEquals(listIpAddresses(endpointId), listIpAddresses(endpointId));
|
||||
}
|
||||
|
||||
@Test
|
||||
void listResolverEndpointIpAddresses_repeatedEntriesGetDistinctStableIds() {
|
||||
// Two addresses in one subnet, both left for AWS to pick, is a valid request: the
|
||||
// model's IpAddressesRequest is a plain list with no uniqueness constraint. Each is a
|
||||
// separate address, so each needs its own IpId.
|
||||
String endpointId = given()
|
||||
.contentType(CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "Route53Resolver.CreateResolverEndpoint")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.body("{\"Name\":\"ep-dup-ips\",\"Direction\":\"INBOUND\",\"CreatorRequestId\":\"list-ips-dup\","
|
||||
+ "\"SecurityGroupIds\":[\"sg-abc123\"],"
|
||||
+ "\"IpAddresses\":[{\"SubnetId\":\"subnet-aaa\"},{\"SubnetId\":\"subnet-aaa\"}]}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract().path("ResolverEndpoint.Id");
|
||||
|
||||
String first = listIpAddresses(endpointId);
|
||||
List<String> ids = io.restassured.path.json.JsonPath.from(first).getList("IpAddresses.IpId");
|
||||
assertEquals(2, ids.size());
|
||||
assertEquals(2, new HashSet<>(ids).size(), "repeated entries share an IpId: " + ids);
|
||||
assertEquals(first, listIpAddresses(endpointId));
|
||||
}
|
||||
|
||||
@Test
|
||||
void listResolverEndpointIpAddresses_unknownEndpoint_returnsResourceNotFound() {
|
||||
given()
|
||||
.contentType(CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "Route53Resolver.ListResolverEndpointIpAddresses")
|
||||
.header("Authorization", AUTH_HEADER)
|
||||
.body("{\"ResolverEndpointId\":\"rslvr-in-doesnotexist\"}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ResourceNotFoundException"));
|
||||
}
|
||||
|
||||
// ── CreateResolverEndpoint: IpAddresses is min 2 / max 20 ──────────────────
|
||||
//
|
||||
// The request shape models IpAddresses as min 2 / max 20, so a resolver endpoint
|
||||
|
||||
+15
@@ -86,6 +86,21 @@ class Route53ResolverReplayFallbackTest {
|
||||
assertEquals("ResourceExistsException", conflict.jsonType());
|
||||
}
|
||||
|
||||
@Test
|
||||
void listingIpAddressesWithoutARecordFailsInsteadOfReturningEmpty() {
|
||||
// An empty list beside IpAddressCount=2 would be a silent wrong answer; the modeled
|
||||
// InternalServiceErrorException says the state is broken.
|
||||
ObjectNode created = service.createResolverEndpoint(createRequest("tok-list", "10.0.0.5"), REGION, ACCOUNT);
|
||||
String id = created.get("Id").asText();
|
||||
assertEquals(2, service.listResolverEndpointIpAddresses(id).size());
|
||||
|
||||
endpointIpRequests.delete(id);
|
||||
AwsException broken = assertThrows(AwsException.class,
|
||||
() -> service.listResolverEndpointIpAddresses(id));
|
||||
assertEquals("InternalServiceErrorException", broken.jsonType());
|
||||
assertEquals(400, broken.getHttpStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
void anIntactRecordStillReplaysAnIdenticalRequest() {
|
||||
// Guard against over-correcting: the ordinary path must stay idempotent.
|
||||
|
||||
Reference in new issue
Block a user