mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat(core): vendor the per-region hosted zones, SAML URLs and VPC endpoint prefixes (#4545)
* feat(core): vendor the per-region hosted zones, SAML URLs and VPC endpoint prefixes tools/aws/regen_region_facts.py transcribes the per-region and per-partition constants AWS publishes only as prose tables into src/main/resources/aws/region-facts.json: the Terraform provider's load balancer and S3 website hosted-zone maps, the CloudFront hosted zone per partition (cross-checked against the CDK), and the CDK's SAML sign-on URLs and VPC endpoint service-name exceptions. AwsRegionFacts serves them, as Optionals where a partition publishes nothing (the ISO and EUSC partitions have no hosted zones). make aws-data-check regenerates and compares where the local reference checkouts exist, and verifies the file's shape where they do not. Behaviour this changes: network load balancers report their own hosted zone per region instead of the Application one, Classic and Application load balancers report their region's zone, API Gateway EDGE domains carry the CloudFront zone of their partition, SAML assertions are checked against the sign-on URL of the provider's partition, and the AWS-managed S3 and DynamoDB prefix lists carry the partition's service-name prefix. Also carries the follow-ups from the #4494 review: bucketRegionForCreate cites the S3 model for the us-east-1 rules, docs/services/s3.md gains a Bucket Regions section, and the Marketplace files are gated per line with stated reasons instead of being allowlisted by path, so a new region literal there is caught. Part of #4272 * fix(core): harden the region facts against restarts, partitions without CloudFront, and CI without sources The source-free data check rejected real twelve-character hosted zone ids such as ap-southeast-1's NLB zone ZKVM4W9LS7TM, which failed the vendored-data job. It now accepts Route 53's id length range and checks substance: every partition has an entry whose VPC endpoint prefix is its reversed DNS suffix, every region is published in partitions.json, SAML URLs are https sign-on URLs, and unknown fields are refused. Load balancers restored from storage take the hosted zone of their region and type again, so balancers stored before the per-region lookup stop reporting the old fixed zone. An EDGE API Gateway custom domain is refused where the partition has no CloudFront, since it would have no distribution zone to alias to. A customer prefix list may not take the prefix of the AWS-managed lists its region carries, cn.com.amazonaws. in China. The partitions doc now says which ISO hosted zones exist. * fix(core): hold only a changed endpoint type to the partition, and name malformed region facts UpdateDomainName checked the partition for EDGE on every patch, so an EDGE custom domain stored in GovCloud before the rule could no longer take a certificate or security-policy update; only a patch that changes the endpoint type is held to the partition now. The source-free region-facts check reports a partition or region entry that is not an object by name instead of failing with a traceback, and its test asserts on computed results rather than on calls that write the fixture. * fix(core): keep gateway endpoint names on com.amazonaws, allow EDGE only in the commercial partition, and keep SAML working where no sign-on URL is published The AWS-managed prefix lists belong to the S3 and DynamoDB gateway endpoints, which the CDK names com.amazonaws.<region>.<service> in every partition (GatewayVpcEndpointAwsService); the reversed-suffix table applies to interface endpoints only. The managed lists are back to that name and the cn.com.amazonaws. reservation is gone; DescribeVpcEndpointServices now names the interface services through the table instead, keeping the S3 gateway entry on com.amazonaws. Edge-optimized API Gateway exists only in the commercial partition: China has CloudFront but no edge-optimized APIs or domains (its API Gateway documentation says so), so EDGE custom domains are refused everywhere else. Where the CDK publishes no SAML sign-on URL (aws-iso-e, aws-iso-f, aws-eusc) assertions keep being checked against the commercial URL, as every partition was before, instead of all being refused. applyEndpointType has its javadoc back.
This commit is contained in:
1 parent
0a786207d6
commit
833a43bfa7
33 files changed
+1738
-68
No files matched your search
@@ -0,0 +1,77 @@
|
||||
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 java.util.Optional;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/** The vendored per-region tables, pinned against the Terraform and CDK rows they came from. */
|
||||
class AwsRegionFactsTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource({
|
||||
"us-east-1, Z35SXDOTRQ7X7K, Z26RNL4JYFTOTI, Z3AQBSTGFYJSTF",
|
||||
"cn-north-1, Z1GDH35T77C1KE, Z3QFB96KMJ7ED6, Z5CN8UMXT92WN",
|
||||
"us-gov-west-1, Z33AYJ8TM3BH4J, ZMG1MZ2THAWF1, Z31GFT0UA1I2HV",
|
||||
"af-south-1, Z268VQBMOI5EKX, Z203XCE67M25HM, Z83WF9RJE8B12",
|
||||
"mx-central-1, Z023552324OKD1BB28BH5, Z02031231H3ID6HYJ9A7U, Z057606446ZNVQJJ8WOP"})
|
||||
void loadBalancerAndWebsiteZonesFollowTheTerraformTables(String region, String alb, String nlb, String website) {
|
||||
assertEquals(Optional.of(alb), AwsRegionFacts.albHostedZoneId(region));
|
||||
assertEquals(Optional.of(alb), AwsRegionFacts.classicElbHostedZoneId(region), "classic shares the ALB zone");
|
||||
assertEquals(Optional.of(nlb), AwsRegionFacts.nlbHostedZoneId(region));
|
||||
assertEquals(Optional.of(website), AwsRegionFacts.s3WebsiteHostedZoneId(region));
|
||||
}
|
||||
|
||||
/** The ISO-F website zones exist only in the CDK table; the ISO load balancer zones nowhere. */
|
||||
@Test
|
||||
void isoRegionsHaveOnlyWhatIsPublished() {
|
||||
assertEquals(Optional.of("Z03376072I8GXC2DXUFXI"), AwsRegionFacts.s3WebsiteHostedZoneId("us-isof-south-1"));
|
||||
assertTrue(AwsRegionFacts.albHostedZoneId("us-isof-south-1").isEmpty());
|
||||
assertTrue(AwsRegionFacts.nlbHostedZoneId("us-iso-east-1").isEmpty());
|
||||
assertTrue(AwsRegionFacts.s3WebsiteHostedZoneId("eusc-de-east-1").isEmpty());
|
||||
assertTrue(AwsRegionFacts.albHostedZoneId("xx-nowhere-9").isEmpty());
|
||||
assertTrue(AwsRegionFacts.albHostedZoneId(null).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void cloudFrontZoneAndSamlUrlArePerPartition() {
|
||||
assertEquals(Optional.of("Z2FDTNDATAQYW2"), AwsRegionFacts.cloudFrontHostedZoneId("aws"));
|
||||
assertEquals(Optional.of("Z3RFFRIM2A3IF5"), AwsRegionFacts.cloudFrontHostedZoneId("aws-cn"));
|
||||
assertTrue(AwsRegionFacts.cloudFrontHostedZoneId("aws-us-gov").isEmpty());
|
||||
assertEquals(Optional.of("https://signin.aws.amazon.com/saml"), AwsRegionFacts.samlSignOnUrl("aws"));
|
||||
assertEquals(Optional.of("https://signin.amazonaws.cn/saml"), AwsRegionFacts.samlSignOnUrl("aws-cn"));
|
||||
assertEquals(Optional.of("https://signin.amazonaws-us-gov.com/saml"), AwsRegionFacts.samlSignOnUrl("aws-us-gov"));
|
||||
assertEquals(Optional.of("https://signin.sc2shome.sgov.gov/saml"), AwsRegionFacts.samlSignOnUrl("aws-iso-b"));
|
||||
assertTrue(AwsRegionFacts.samlSignOnUrl("aws-eusc").isEmpty());
|
||||
assertTrue(AwsRegionFacts.samlSignOnUrl(null).isEmpty());
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource({
|
||||
"us-east-1, s3, com.amazonaws.us-east-1.s3",
|
||||
"us-gov-west-1, s3, com.amazonaws.us-gov-west-1.s3",
|
||||
"cn-north-1, s3, cn.com.amazonaws.cn-north-1.s3",
|
||||
"cn-north-1, dynamodb, com.amazonaws.cn-north-1.dynamodb",
|
||||
"cn-northwest-1, transcribe, cn.com.amazonaws.cn-northwest-1.transcribe.cn",
|
||||
"us-iso-east-1, ecr.api, gov.ic.c2s.us-iso-east-1.ecr.api",
|
||||
"us-iso-east-1, s3, com.amazonaws.us-iso-east-1.s3",
|
||||
"eusc-de-east-1, execute-api, eu.amazonaws.eusc-de-east-1.execute-api",
|
||||
"us-isof-south-1, ebs, gov.ic.hci.csp.us-isof-south-1.ebs"})
|
||||
void vpcEndpointServiceNamesReverseTheSuffixOnlyForTheListedPairs(String region, String service, String expected) {
|
||||
assertEquals(expected, AwsRegionFacts.vpcEndpointServiceName(region, service));
|
||||
}
|
||||
|
||||
@Test
|
||||
void vpcEndpointServiceNamePrefixIsTheReversedSuffix() {
|
||||
assertEquals(Optional.of("com.amazonaws.vpce"), AwsRegionFacts.vpcEndpointServiceNamePrefix("aws"));
|
||||
assertEquals(Optional.of("com.amazonaws.vpce"), AwsRegionFacts.vpcEndpointServiceNamePrefix("aws-us-gov"));
|
||||
assertEquals(Optional.of("cn.com.amazonaws.vpce"), AwsRegionFacts.vpcEndpointServiceNamePrefix("aws-cn"));
|
||||
assertEquals(Optional.of("gov.sgov.sc2s.vpce"), AwsRegionFacts.vpcEndpointServiceNamePrefix("aws-iso-b"));
|
||||
assertEquals(52, AwsRegionFacts.vpcEndpointPrefixServices("cn-north-1").size());
|
||||
assertTrue(AwsRegionFacts.vpcEndpointPrefixServices("us-east-1").isEmpty());
|
||||
}
|
||||
}
|
||||
+62
@@ -9,6 +9,8 @@ import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
@@ -64,6 +66,40 @@ class PartitionRegionGatesIntegrationTest {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Edge-optimized domains exist only in the commercial partition: GovCloud has no CloudFront, and
|
||||
* China has CloudFront but no edge-optimized API Gateway. A regional domain needs neither.
|
||||
*/
|
||||
@Test
|
||||
void edgeCustomDomainsAreRejectedOutsideTheCommercialPartition() {
|
||||
String suffix = Long.toString(System.nanoTime(), 36);
|
||||
for (String region : List.of("us-gov-west-1", "cn-north-1")) {
|
||||
String partition = AwsRegions.partitionFor(region);
|
||||
given()
|
||||
.header("Authorization", PartitionMatrix.sigV4Auth(region, "apigateway"))
|
||||
.contentType("application/json")
|
||||
.body("{\"domainName\":\"edge-" + suffix + "." + region + ".example.com\","
|
||||
+ "\"certificateArn\":\"arn:" + partition + ":acm:" + region + ":000000000000:certificate/edge\","
|
||||
+ "\"endpointConfiguration\":{\"types\":[\"EDGE\"]}}")
|
||||
.when().post("/domainnames")
|
||||
.then().statusCode(400)
|
||||
.body(containsString("not available in partition " + partition));
|
||||
}
|
||||
|
||||
String regional = "regional-" + suffix + ".example.com";
|
||||
given()
|
||||
.header("Authorization", PartitionMatrix.sigV4Auth("us-gov-west-1", "apigateway"))
|
||||
.contentType("application/json")
|
||||
.body("{\"domainName\":\"" + regional + "\","
|
||||
+ "\"regionalCertificateArn\":\"arn:aws-us-gov:acm:us-gov-west-1:000000000000:certificate/regional\","
|
||||
+ "\"endpointConfiguration\":{\"types\":[\"REGIONAL\"]}}")
|
||||
.when().post("/domainnames")
|
||||
.then().statusCode(201);
|
||||
cleanup.register(() -> given()
|
||||
.header("Authorization", PartitionMatrix.sigV4Auth("us-gov-west-1", "apigateway"))
|
||||
.when().delete("/domainnames/" + regional));
|
||||
}
|
||||
|
||||
@Test
|
||||
void cloudFrontScopeLivesInThePartitionsImplicitGlobalRegion() {
|
||||
String name = "cn-" + Long.toString(System.nanoTime(), 36);
|
||||
@@ -81,6 +117,32 @@ class PartitionRegionGatesIntegrationTest {
|
||||
assertTrue(arn.startsWith("arn:aws-cn:wafv2:cn-northwest-1:000000000000:global/ipset/" + name + "/"), arn);
|
||||
}
|
||||
|
||||
/**
|
||||
* The AWS-managed prefix lists belong to the S3 and DynamoDB gateway endpoints, which keep
|
||||
* {@code com.amazonaws} in every partition; only interface endpoint names take the reversed
|
||||
* suffix China lists.
|
||||
*/
|
||||
@Test
|
||||
void gatewayPrefixListsKeepComAmazonawsWhileChinaInterfaceNamesReverseTheSuffix() {
|
||||
List<String> names = given()
|
||||
.header("Authorization", PartitionMatrix.sigV4Auth("cn-north-1", "ec2"))
|
||||
.formParam("Action", "DescribeManagedPrefixLists")
|
||||
.formParam("Version", "2016-11-15")
|
||||
.when().post("/").then().statusCode(200)
|
||||
.extract().xmlPath().getList("DescribeManagedPrefixListsResponse.prefixListSet.item.prefixListName");
|
||||
assertTrue(names.contains("com.amazonaws.cn-north-1.s3"), names.toString());
|
||||
assertTrue(names.contains("com.amazonaws.cn-north-1.dynamodb"), names.toString());
|
||||
|
||||
List<String> services = given()
|
||||
.header("Authorization", PartitionMatrix.sigV4Auth("cn-north-1", "ec2"))
|
||||
.formParam("Action", "DescribeVpcEndpointServices")
|
||||
.formParam("Version", "2016-11-15")
|
||||
.when().post("/").then().statusCode(200)
|
||||
.extract().xmlPath().getList("DescribeVpcEndpointServicesResponse.serviceNameSet.item");
|
||||
assertTrue(services.contains("cn.com.amazonaws.cn-north-1.lambda"), services.toString());
|
||||
assertTrue(services.contains("com.amazonaws.cn-north-1.s3"), services.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
void lightsailRegionsAreEmptyOutsideTheCommercialPartition() {
|
||||
given()
|
||||
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
package io.github.hectorvent.floci.services.apigateway;
|
||||
|
||||
import io.github.hectorvent.floci.config.EmulatorConfig;
|
||||
import io.github.hectorvent.floci.config.TlsCertificateManager;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
import io.github.hectorvent.floci.services.apigateway.model.CustomDomain;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* An edge-optimized custom domain exists only in the commercial partition, so it cannot be created
|
||||
* or switched to elsewhere. A domain stored before that rule still has to take updates
|
||||
* that leave its endpoint type alone.
|
||||
*/
|
||||
class ApiGatewayEdgeDomainPartitionTest {
|
||||
|
||||
private static final String GOV_REGION = "us-gov-west-1";
|
||||
|
||||
private final Map<String, AccountAwareStorageBackend<?>> stores = new HashMap<>();
|
||||
private ApiGatewayService service;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
StorageFactory storageFactory = mock(StorageFactory.class);
|
||||
when(storageFactory.create(anyString(), anyString(), any())).thenAnswer(invocation ->
|
||||
stores.computeIfAbsent(invocation.getArgument(1, String.class),
|
||||
ignored -> AccountAwareStorageBackend.inMemory("000000000000")));
|
||||
EmulatorConfig config = mock(EmulatorConfig.class, RETURNS_DEEP_STUBS);
|
||||
when(config.services().cloudfront().domainSuffix()).thenReturn("cloudfront.net");
|
||||
service = new ApiGatewayService(storageFactory, config, mock(TlsCertificateManager.class));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private AccountAwareStorageBackend<CustomDomain> domainStore() {
|
||||
return (AccountAwareStorageBackend<CustomDomain>) stores.get("apigateway-domains.json");
|
||||
}
|
||||
|
||||
@Test
|
||||
void aStoredEdgeDomainTakesUpdatesThatLeaveItsTypeAlone() {
|
||||
CustomDomain legacy = new CustomDomain();
|
||||
legacy.setDomainName("legacy.example.com");
|
||||
legacy.setEndpointConfigurationType("EDGE");
|
||||
legacy.setCertificateArn("arn:aws-us-gov:acm:us-gov-west-1:000000000000:certificate/old");
|
||||
domainStore().put(GOV_REGION + "::legacy.example.com", legacy);
|
||||
|
||||
CustomDomain updated = service.updateDomainName(GOV_REGION, "legacy.example.com",
|
||||
List.of(Map.of("op", "replace", "path", "/certificateArn",
|
||||
"value", "arn:aws-us-gov:acm:us-gov-west-1:000000000000:certificate/new")));
|
||||
|
||||
assertEquals("arn:aws-us-gov:acm:us-gov-west-1:000000000000:certificate/new", updated.getCertificateArn());
|
||||
assertEquals("EDGE", updated.getEndpointConfigurationType());
|
||||
}
|
||||
|
||||
@Test
|
||||
void switchingADomainToEdgeIsRefusedWhereThePartitionHasNoCloudFront() {
|
||||
service.createDomainName(GOV_REGION, Map.of("domainName", "regional.example.com",
|
||||
"regionalCertificateArn", "arn:aws-us-gov:acm:us-gov-west-1:000000000000:certificate/r",
|
||||
"endpointConfiguration", Map.of("types", List.of("REGIONAL"))));
|
||||
|
||||
AwsException error = assertThrows(AwsException.class, () -> service.updateDomainName(GOV_REGION,
|
||||
"regional.example.com", List.of(Map.of("op", "replace",
|
||||
"path", "/endpointConfiguration/types/REGIONAL", "value", "EDGE"))));
|
||||
|
||||
assertEquals("BadRequestException", error.getErrorCode());
|
||||
}
|
||||
|
||||
/** China has CloudFront but no edge-optimized API Gateway. */
|
||||
@Test
|
||||
void anEdgeDomainIsRefusedInChina() {
|
||||
AwsException error = assertThrows(AwsException.class, () -> service.createDomainName("cn-north-1",
|
||||
Map.of("domainName", "edge.example.cn",
|
||||
"certificateArn", "arn:aws-cn:acm:cn-north-1:000000000000:certificate/e",
|
||||
"endpointConfiguration", Map.of("types", List.of("EDGE")))));
|
||||
|
||||
assertEquals("BadRequestException", error.getErrorCode());
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.github.hectorvent.floci.services.elb;
|
||||
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.AwsRegionFacts;
|
||||
import io.github.hectorvent.floci.services.ec2.Ec2Service;
|
||||
import io.github.hectorvent.floci.services.ec2.model.SecurityGroup;
|
||||
import io.github.hectorvent.floci.services.ec2.model.Subnet;
|
||||
@@ -255,4 +256,17 @@ class ElbClassicServiceTest {
|
||||
service.createLoadBalancerListeners(REGION, "my-elb", List.of(httpListener()));
|
||||
assertEquals(1, lb.getListeners().size());
|
||||
}
|
||||
|
||||
/** A balancer stored before the zone was looked up per region carries the old fixed zone. */
|
||||
@Test
|
||||
void aRestoredBalancerTakesTheHostedZoneOfItsRegion() {
|
||||
create("stored-elb").setCanonicalHostedZoneNameId("Z35SXDOTRQ7X7K");
|
||||
assertEquals("Z35SXDOTRQ7X7K",
|
||||
service.describeLoadBalancers(REGION, List.of("stored-elb")).getFirst().getCanonicalHostedZoneNameId());
|
||||
|
||||
service.restorePersistedRuntime();
|
||||
|
||||
assertEquals(AwsRegionFacts.classicElbHostedZoneId(REGION).orElseThrow(),
|
||||
service.describeLoadBalancers(REGION, List.of("stored-elb")).getFirst().getCanonicalHostedZoneNameId());
|
||||
}
|
||||
}
|
||||
+26
@@ -1,6 +1,7 @@
|
||||
package io.github.hectorvent.floci.services.elbv2;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasItem;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
@@ -64,6 +65,31 @@ class ElbV2DefaultAttributesIntegrationTest {
|
||||
.extract().path("CreateLoadBalancerResponse.CreateLoadBalancerResult.LoadBalancers.member.LoadBalancerArn");
|
||||
}
|
||||
|
||||
/**
|
||||
* Network load balancers have their own hosted zone per region (the ELB table in the AWS
|
||||
* General Reference, as the Terraform provider transcribes it); floci reported the ALB zone
|
||||
* for every type before the per-region facts landed.
|
||||
*/
|
||||
@Test
|
||||
void eachLoadBalancerTypeReportsItsOwnHostedZone() {
|
||||
String albArn = createLoadBalancer("zone-alb", "application", "10.101.");
|
||||
String nlbArn = createLoadBalancer("zone-nlb", "network", "10.102.");
|
||||
|
||||
assertEquals("Z35SXDOTRQ7X7K", canonicalHostedZoneId(albArn));
|
||||
assertEquals("Z26RNL4JYFTOTI", canonicalHostedZoneId(nlbArn));
|
||||
}
|
||||
|
||||
private String canonicalHostedZoneId(String arn) {
|
||||
return given()
|
||||
.formParam("Action", "DescribeLoadBalancers")
|
||||
.formParam("Version", "2015-12-01")
|
||||
.formParam("LoadBalancerArns.member.1", arn)
|
||||
.header("Authorization", AUTH)
|
||||
.when().post("/")
|
||||
.then().statusCode(200)
|
||||
.extract().path("DescribeLoadBalancersResponse.DescribeLoadBalancersResult.LoadBalancers.member.CanonicalHostedZoneId");
|
||||
}
|
||||
|
||||
@Test
|
||||
void aFreshApplicationLoadBalancerReportsTheDocumentedDefaults() {
|
||||
String arn = createLoadBalancer("attrs-alb", "application", "10.95.");
|
||||
|
||||
@@ -3,6 +3,7 @@ package io.github.hectorvent.floci.services.elbv2;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.github.hectorvent.floci.config.EmulatorConfig;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.AwsRegionFacts;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.storage.InMemoryStorage;
|
||||
import io.github.hectorvent.floci.core.storage.StorageBackend;
|
||||
@@ -480,4 +481,30 @@ class ElbV2ServiceTest {
|
||||
return (AccountAwareStorageBackend<V>) stores.computeIfAbsent(fileName, ignored -> AccountAwareStorageBackend.inMemory("000000000000"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A balancer stored before the zone was looked up per region and type carries the one fixed
|
||||
* zone every balancer used to report; a restart gives it the zone of its region and type back.
|
||||
*/
|
||||
@Test
|
||||
void aRestoredNetworkLoadBalancerTakesTheHostedZoneOfItsRegionAndType() {
|
||||
SharedStorageFactory storageFactory = new SharedStorageFactory();
|
||||
ElbV2Service first = serviceWithStorage(storageFactory, mock(ElbV2DataPlane.class),
|
||||
mock(ElbV2HealthChecker.class));
|
||||
first.createLoadBalancer(REGION, "stored-nlb", "internal", "network", "ipv4",
|
||||
ALB_SUBNETS, List.of(), Map.of());
|
||||
first.describeLoadBalancers(REGION, null, List.of("stored-nlb"), null, null).getFirst()
|
||||
.setCanonicalHostedZoneId("Z35SXDOTRQ7X7K");
|
||||
|
||||
ElbV2Service reloaded = serviceWithStorage(storageFactory, mock(ElbV2DataPlane.class),
|
||||
mock(ElbV2HealthChecker.class));
|
||||
assertEquals("Z35SXDOTRQ7X7K", reloaded.describeLoadBalancers(REGION, null, List.of("stored-nlb"), null, null)
|
||||
.getFirst().getCanonicalHostedZoneId());
|
||||
|
||||
reloaded.restorePersistedRuntime();
|
||||
|
||||
assertEquals(AwsRegionFacts.nlbHostedZoneId(REGION).orElseThrow(),
|
||||
reloaded.describeLoadBalancers(REGION, null, List.of("stored-nlb"), null, null)
|
||||
.getFirst().getCanonicalHostedZoneId());
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package io.github.hectorvent.floci.services.iam;
|
||||
|
||||
import io.github.hectorvent.floci.services.iam.model.SAMLProvider;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* A bearer assertion names the console sign-on URL of the provider's partition. Where the CDK
|
||||
* publishes none (ISO-E, ISO-F, EUSC) the commercial URL is kept, as before the per-partition
|
||||
* table, instead of refusing every assertion.
|
||||
*/
|
||||
class SAMLAssertionVerifierRecipientTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource({
|
||||
"aws, https://signin.aws.amazon.com/saml",
|
||||
"aws-cn, https://signin.amazonaws.cn/saml",
|
||||
"aws-iso, https://signin.c2shome.ic.gov/saml",
|
||||
"aws-iso-e, https://signin.aws.amazon.com/saml",
|
||||
"aws-iso-f, https://signin.aws.amazon.com/saml",
|
||||
"aws-eusc, https://signin.aws.amazon.com/saml"
|
||||
})
|
||||
void theRecipientIsThePartitionsSignOnUrlOrTheCommercialOne(String partition, String expected) {
|
||||
SAMLProvider provider = new SAMLProvider();
|
||||
provider.setArn("arn:" + partition + ":iam::000000000000:saml-provider/idp");
|
||||
|
||||
assertEquals(expected, SAMLAssertionVerifier.expectedRecipient(provider));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user