mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(partition): read strict-mode service availability from endpoint rulesets too (#5231)
* fix(partition): read strict-mode service availability from endpoint rulesets too Strict partition mode refused services AWS serves. The per-partition service list came from botocore's endpoints.json alone, which leaves out IAM, Route 53, Budgets and Cost Explorer in aws-eusc and IAM and Cost Explorer in aws-iso-e, although each service's endpoint ruleset has an explicit branch for the partition (iam.eusc-de-east-1.amazonaws.eu). The generator now adds those partitions, for services endpoints.json lists somewhere, and records them under servicesFromRulesets. The execute-api signing name was mapped to Connect Participant only, so IAM-authorized API Gateway invokes were refused in China, EUSC and the ISO partitions. A signing name is now left out of the alias map when a service whose own endpoint prefix is that name is listed nowhere, so strict mode no longer judges execute-api. The docs and config comments no longer say IAM is absent from aws-eusc. * test(partition): assert API Gateway answers the strict-mode execute-api probe The execute-api strict-mode test accepted any response but a 200 that lacked the strict-mode error, so a 500 or an unrelated rejection would also pass. It now requires API Gateway's own answer for a missing API: a 404 NotFoundException with "Invalid API id specified".
This commit is contained in:
1 parent
e1cd6fe6d4
commit
8a1d1ddcd3
12 files changed
+284
-31
No files matched your search
@@ -249,7 +249,7 @@ class AccountContextFilterTest {
|
||||
@Test
|
||||
void strictModeAlsoCoversPresignedCredentials() {
|
||||
strictPartitions = true;
|
||||
ContainerRequestContext ctx = mockContext(null, "AKID/20260617/eusc-de-east-1/iam/aws4_request");
|
||||
ContainerRequestContext ctx = mockContext(null, "AKID/20260617/cn-north-1/lightsail/aws4_request");
|
||||
filter.filter(ctx);
|
||||
ArgumentCaptor<Response> aborted = ArgumentCaptor.forClass(Response.class);
|
||||
verify(ctx).abortWith(aborted.capture());
|
||||
|
||||
@@ -134,12 +134,12 @@ class AwsPartitionsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void serviceAvailabilityFollowsEndpointsJson() {
|
||||
void serviceAvailabilityFollowsThePublishedData() {
|
||||
assertTrue(AwsPartitions.commercial().offers("cloudfront"));
|
||||
assertTrue(AwsPartitions.byId("aws-cn").offers("cloudfront"));
|
||||
assertFalse(AwsPartitions.byId("aws-us-gov").offers("cloudfront"));
|
||||
assertFalse(AwsPartitions.byId("aws-eusc").offers("iam"));
|
||||
assertFalse(AwsPartitions.byId("aws-iso-e").offers("iam"));
|
||||
assertFalse(AwsPartitions.byId("aws-cn").offers("lightsail"));
|
||||
assertTrue(AwsPartitions.byId("aws-eusc").offers("iam"), "IAM's endpoint ruleset names aws-eusc");
|
||||
assertFalse(AwsPartitions.byId("aws-cn").offers("cognito-idp"));
|
||||
assertFalse(AwsPartitions.commercial().offers(null));
|
||||
}
|
||||
@@ -156,7 +156,7 @@ class AwsPartitionsTest {
|
||||
assertTrue(AwsPartitions.byId("aws-cn").offersSigningName("ecr"));
|
||||
assertTrue(AwsPartitions.byId("aws-cn").offersSigningName("sqs"));
|
||||
assertFalse(AwsPartitions.byId("aws-us-gov").offersSigningName("cloudfront"));
|
||||
assertFalse(AwsPartitions.byId("aws-eusc").offersSigningName("iam"));
|
||||
assertFalse(AwsPartitions.byId("aws-cn").offersSigningName("lightsail"));
|
||||
assertFalse(AwsPartitions.commercial().offersSigningName("no-such-service"));
|
||||
assertFalse(AwsPartitions.commercial().offersSigningName(null));
|
||||
|
||||
@@ -167,6 +167,35 @@ class AwsPartitionsTest {
|
||||
assertFalse(AwsPartitions.publishesSomewhere(null));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code endpoints.json} leaves IAM, Route 53, Budgets and Cost Explorer out of {@code aws-eusc},
|
||||
* and IAM and Cost Explorer out of {@code aws-iso-e}, but each service's endpoint ruleset has an
|
||||
* explicit branch for the partition ({@code iam.eusc-de-east-1.amazonaws.eu}).
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@CsvSource({
|
||||
"aws-eusc, iam",
|
||||
"aws-eusc, route53",
|
||||
"aws-eusc, budgets",
|
||||
"aws-eusc, ce",
|
||||
"aws-iso-e, iam",
|
||||
"aws-iso-e, ce",
|
||||
})
|
||||
void partitionsAServiceRulesetNamesExplicitlyOfferIt(String partitionId, String signingName) {
|
||||
assertTrue(AwsPartitions.byId(partitionId).offersSigningName(signingName));
|
||||
}
|
||||
|
||||
/**
|
||||
* API Gateway's invoke endpoints and its WebSocket management API sign {@code execute-api},
|
||||
* as Connect Participant does, and the published data lists the API Gateway side nowhere, so
|
||||
* the name must not be judged by where Connect Participant is offered.
|
||||
*/
|
||||
@Test
|
||||
void executeApiIsNotTiedToConnectParticipant() {
|
||||
assertEquals(Set.of(), AwsPartitions.endpointPrefixes("execute-api"));
|
||||
assertFalse(AwsPartitions.publishesSomewhere("execute-api"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void optInAndWebsiteFormFlagsComeFromTheCdkRules() {
|
||||
AwsPartition aws = AwsPartitions.commercial();
|
||||
|
||||
+40
-6
@@ -15,6 +15,7 @@ import java.util.TreeSet;
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
@@ -44,17 +45,50 @@ class PartitionStrictModeIntegrationTest {
|
||||
.body("message", containsString("cloudfront has no endpoint in partition aws-us-gov"));
|
||||
}
|
||||
|
||||
/** IAM speaks the Query protocol, so the refusal is the Query XML error a Query client parses. */
|
||||
/** Elastic Beanstalk speaks the Query protocol, so the refusal is the Query XML error a Query client parses. */
|
||||
@Test
|
||||
void iamIsRefusedInEuscWithAQueryError() {
|
||||
void elasticBeanstalkIsRefusedInEuscWithAQueryError() {
|
||||
given()
|
||||
.header("Authorization", PartitionMatrix.sigV4Auth("eusc-de-east-1", "iam"))
|
||||
.formParam("Action", "ListRoles")
|
||||
.formParam("Version", "2010-05-08")
|
||||
.header("Authorization", PartitionMatrix.sigV4Auth("eusc-de-east-1", "elasticbeanstalk"))
|
||||
.formParam("Action", "DescribeApplications")
|
||||
.formParam("Version", "2010-12-01")
|
||||
.when().post("/").then().statusCode(404)
|
||||
.contentType(containsString("xml"))
|
||||
.body("ErrorResponse.Error.Code", equalTo("UnknownOperationException"))
|
||||
.body("ErrorResponse.Error.Message", containsString("iam has no endpoint in partition aws-eusc"));
|
||||
.body("ErrorResponse.Error.Message",
|
||||
containsString("elasticbeanstalk has no endpoint in partition aws-eusc"));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code endpoints.json} leaves IAM out of {@code aws-eusc} and {@code aws-iso-e}, but IAM's
|
||||
* endpoint ruleset publishes {@code iam.eusc-de-east-1.amazonaws.eu} and
|
||||
* {@code iam.eu-isoe-west-1.cloud.adc-e.uk}, so a client there reaches IAM.
|
||||
*/
|
||||
@Test
|
||||
void iamIsServedInTheEuscAndIsoEPartitionsItsRulesetNames() {
|
||||
for (String region : new String[] {"eusc-de-east-1", "eu-isoe-west-1"}) {
|
||||
given()
|
||||
.header("Authorization", PartitionMatrix.sigV4Auth(region, "iam"))
|
||||
.formParam("Action", "ListRoles")
|
||||
.formParam("Version", "2010-05-08")
|
||||
.when().post("/").then().statusCode(200);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An IAM-authorized API Gateway invoke signs {@code execute-api}, a name Connect Participant
|
||||
* shares. China offers API Gateway but not Connect Participant, so the invoke must reach API
|
||||
* Gateway, which answers for the missing API itself.
|
||||
*/
|
||||
@Test
|
||||
void executeApiInvokesAreNotRefusedWhereConnectParticipantIsAbsent() {
|
||||
given()
|
||||
.header("Authorization", PartitionMatrix.sigV4Auth("cn-north-1", "execute-api"))
|
||||
.when().get("/execute-api/nosuchapi/prod/items").then()
|
||||
.statusCode(404)
|
||||
.header("X-Amzn-Errortype", not(equalTo("UnknownOperationException")))
|
||||
.body("message", equalTo("Invalid API id specified"))
|
||||
.body(not(containsString("has no endpoint in partition")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user