mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(apigateway): report the published regional hosted zones (#7487)
* fix(apigateway): report the published regional hosted zones A regional custom domain reported the invented Z2FDTNDATAQYL2 everywhere outside GovCloud, so a Route 53 alias built from it pointed at a zone AWS does not have. Vendor the data plane table of the API Gateway General Reference page into region-facts.json, with the GovCloud guide kept as a cross-check. A region with no row keeps the placeholder, now documented as one. Stored domains keep their id. Signed-off-by: Hector Ventura <hectorvent@gmail.com> * test(apigateway): read the regional hosted zone through the SDK clients Create and read the custom domains with ApiGatewayClient and ApiGatewayV2Client, so the test also shows both SDKs parse the zone fields. Signed-off-by: Hector Ventura <hectorvent@gmail.com> --------- Signed-off-by: Hector Ventura <hectorvent@gmail.com>
This commit is contained in:
1 parent
27057e2c00
commit
e46579ec03
10 files changed
+298
-69
No files matched your search
@@ -3,6 +3,7 @@ package io.github.hectorvent.floci.core.common;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -77,13 +78,27 @@ class AwsRegionFactsTest {
|
||||
assertTrue(AwsRegionFacts.cloudFrontDomainSuffix(null).isEmpty());
|
||||
}
|
||||
|
||||
/** The GovCloud guide states the two regional endpoint zones; no source covers another region. */
|
||||
/** The General Reference data plane table; the GovCloud guide states the same two GovCloud zones. */
|
||||
@ParameterizedTest
|
||||
@CsvSource({
|
||||
"us-east-1, Z1UJRXOUMOOFQ8",
|
||||
"eu-west-1, ZLY8HYME6SFDD",
|
||||
"ap-east-2, Z02909591O7FG9Q56HWB1",
|
||||
"us-gov-west-1, Z1K6XKP9SAGWDV",
|
||||
"us-gov-east-1, Z3SE9ATJYCRCZJ"})
|
||||
void apiGatewayRegionalZoneFollowsTheGeneralReference(String region, String zone) {
|
||||
assertEquals(Optional.of(zone), AwsRegionFacts.apiGatewayRegionalHostedZoneId(region));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"ap-southeast-6", "cn-north-1", "cn-northwest-1", "eusc-de-east-1", "us-iso-east-1",
|
||||
"us-isob-east-1", "eu-isoe-west-1", "us-isof-south-1"})
|
||||
void apiGatewayRegionalZoneIsAbsentWhereTheTableHasNoRow(String region) {
|
||||
assertTrue(AwsRegionFacts.apiGatewayRegionalHostedZoneId(region).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void apiGatewayRegionalZoneIsPublishedForGovCloudOnly() {
|
||||
assertEquals(Optional.of("Z1K6XKP9SAGWDV"), AwsRegionFacts.apiGatewayRegionalHostedZoneId("us-gov-west-1"));
|
||||
assertEquals(Optional.of("Z3SE9ATJYCRCZJ"), AwsRegionFacts.apiGatewayRegionalHostedZoneId("us-gov-east-1"));
|
||||
assertTrue(AwsRegionFacts.apiGatewayRegionalHostedZoneId("us-east-1").isEmpty());
|
||||
assertTrue(AwsRegionFacts.apiGatewayRegionalHostedZoneId("cn-north-1").isEmpty());
|
||||
void apiGatewayRegionalZoneIsAbsentWithoutARegion() {
|
||||
assertTrue(AwsRegionFacts.apiGatewayRegionalHostedZoneId(null).isEmpty());
|
||||
}
|
||||
|
||||
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
package io.github.hectorvent.floci.services.apigateway;
|
||||
|
||||
import io.github.hectorvent.floci.testing.AwsTestClients;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import software.amazon.awssdk.regions.Region;
|
||||
import software.amazon.awssdk.services.apigateway.ApiGatewayClient;
|
||||
import software.amazon.awssdk.services.apigateway.model.EndpointType;
|
||||
import software.amazon.awssdk.services.apigatewayv2.ApiGatewayV2Client;
|
||||
import software.amazon.awssdk.services.apigatewayv2.model.DomainNameConfiguration;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* The hosted zone both custom domain APIs give an SDK client for a region whose General Reference
|
||||
* row is not the default region's: {@code regionalHostedZoneId} on REST, {@code hostedZoneId} on HTTP.
|
||||
*/
|
||||
@QuarkusTest
|
||||
class ApiGatewayRegionalHostedZoneIntegrationTest {
|
||||
|
||||
private static final Region REGION = Region.EU_WEST_1;
|
||||
private static final String ZONE = "ZLY8HYME6SFDD";
|
||||
|
||||
@Test
|
||||
void restDomainNameReportsThePublishedZone() {
|
||||
String domain = "v1.regional-zone-it.example.com";
|
||||
try (ApiGatewayClient client = AwsTestClients.create(ApiGatewayClient.builder(), "000000000000", REGION)) {
|
||||
try {
|
||||
String created = client.createDomainName(request -> request.domainName(domain)
|
||||
.endpointConfiguration(endpoint -> endpoint.types(EndpointType.REGIONAL)))
|
||||
.regionalHostedZoneId();
|
||||
String read = client.getDomainName(request -> request.domainName(domain)).regionalHostedZoneId();
|
||||
|
||||
assertEquals(ZONE, created);
|
||||
assertEquals(ZONE, read);
|
||||
} finally {
|
||||
client.deleteDomainName(request -> request.domainName(domain));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void httpDomainNameReportsThePublishedZone() {
|
||||
String domain = "v2.regional-zone-it.example.com";
|
||||
try (ApiGatewayV2Client client = AwsTestClients.create(ApiGatewayV2Client.builder(), "000000000000", REGION)) {
|
||||
try {
|
||||
DomainNameConfiguration created = client.createDomainName(request -> request.domainName(domain)
|
||||
.domainNameConfigurations(configuration -> configuration.endpointType("REGIONAL")))
|
||||
.domainNameConfigurations().get(0);
|
||||
DomainNameConfiguration read = client.getDomainName(request -> request.domainName(domain))
|
||||
.domainNameConfigurations().get(0);
|
||||
|
||||
assertEquals(ZONE, created.hostedZoneId());
|
||||
assertEquals(ZONE, read.hostedZoneId());
|
||||
} finally {
|
||||
client.deleteDomainName(request -> request.domainName(domain));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+17
-9
@@ -9,6 +9,7 @@ import io.github.hectorvent.floci.services.apigateway.model.CustomDomain;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -22,8 +23,8 @@ import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* The Route 53 hosted zone a regional custom domain reports. The GovCloud user guide states it for
|
||||
* its two regions; every other region has no source and keeps the value it always reported.
|
||||
* The Route 53 hosted zone a regional custom domain reports: the General Reference row for its
|
||||
* region, or the invented placeholder in a region the table does not list.
|
||||
*/
|
||||
class ApiGatewayRegionalHostedZoneTest {
|
||||
|
||||
@@ -42,16 +43,23 @@ class ApiGatewayRegionalHostedZoneTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource({
|
||||
"us-east-1, Z1UJRXOUMOOFQ8",
|
||||
"eu-west-1, ZLY8HYME6SFDD",
|
||||
"us-gov-west-1, Z1K6XKP9SAGWDV",
|
||||
"us-gov-east-1, Z3SE9ATJYCRCZJ",
|
||||
"us-east-1, Z2FDTNDATAQYL2",
|
||||
"cn-north-1, Z2FDTNDATAQYL2",
|
||||
"eusc-de-east-1, Z2FDTNDATAQYL2"})
|
||||
"us-gov-east-1, Z3SE9ATJYCRCZJ"})
|
||||
void regionalDomainReportsTheRegionsPublishedZone(String region, String hostedZoneId) {
|
||||
CustomDomain domain = service.createDomainName(region, Map.of(
|
||||
assertEquals(hostedZoneId, createRegionalDomain(region).getRegionalHostedZoneId());
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"ap-southeast-6", "cn-north-1", "eusc-de-east-1", "us-iso-east-1"})
|
||||
void regionalDomainReportsThePlaceholderWhereNoZoneIsPublished(String region) {
|
||||
assertEquals("Z2FDTNDATAQYL2", createRegionalDomain(region).getRegionalHostedZoneId());
|
||||
}
|
||||
|
||||
private CustomDomain createRegionalDomain(String region) {
|
||||
return service.createDomainName(region, Map.of(
|
||||
"domainName", "api." + region + ".example.com",
|
||||
"endpointConfiguration", Map.of("types", List.of("REGIONAL"))));
|
||||
|
||||
assertEquals(hostedZoneId, domain.getRegionalHostedZoneId());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user