test(partition): positive China Lambda layer test, partitions.md gaps, drop AwsRegions.ALL (#5023)

Close-out items of the multi-partition initiative (#4272):

- Lambda layers were only tested across partitions negatively. A layer
  published under a cn-north-1 scope now has its own test: the returned ARN
  is arn:aws-cn:lambda:cn-north-1:..., GetLayerVersionByArn resolves it, and
  a China function attaches it (BL-104).
- partitions.md names FLOCI_PARTITIONS_ALLOW_UNKNOWN_REGIONS under Related and
  lists two more unsourced values: the EKS Pod Identity token audience
  outside the commercial partition, and the exact error AWS WAF returns for
  the CLOUDFRONT scope where the partition has no CloudFront (BL-105).
- AwsRegions.ALL, the commercial advertised list kept as a deprecated alias
  during the partition sweep, had no caller left in src/main. It is removed
  and its three tests call advertised("aws"); the KNOWN_IDS javadoc no longer
  points at it (BL-106).
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-10-03 21:43:28 -04:00
1 parent 6deb0d4d2b
commit 6568700e02
6 files changed
+129 -24

No files matched your search

@@ -485,7 +485,7 @@ class TlsCertificateHostnameTest {
X509Certificate cert = parseCertificate(certFile);
List<String> sans = extractSansFromCertificate(cert);
for (String region : AwsRegions.ALL) {
for (String region : AwsRegions.advertised("aws")) {
String expectedWildcard = "*.dkr.ecr." + region + ".localhost.floci.io";
assertTrue(TlsConfigSource.DEFAULT_SAN_HOSTNAMES.contains(expectedWildcard),
"DEFAULT_SAN_HOSTNAMES missing ECR wildcard for region " + region);
@@ -21,7 +21,7 @@ class AwsRegionsTest {
*/
@Test
void everyAdvertisedRegionIsAKnownRegionId() {
for (String region : AwsRegions.ALL) {
for (String region : AwsRegions.advertised("aws")) {
assertTrue(AwsRegions.KNOWN_IDS.contains(region),
region + " is advertised by DescribeRegions but is not a known region id");
}
@@ -111,8 +111,7 @@ class AwsRegionsTest {
@Test
void advertisedListsArePerPartition() {
assertEquals(AwsRegions.ALL, AwsRegions.advertised("aws"));
assertEquals(34, AwsRegions.ALL.size());
assertEquals(34, AwsRegions.advertised("aws").size());
assertEquals(List.of("cn-north-1", "cn-northwest-1"), AwsRegions.advertised("aws-cn"));
assertTrue(AwsRegions.KNOWN_IDS.contains("eusc-de-east-1"));
assertTrue(AwsRegions.KNOWN_IDS.contains("us-isof-south-1"));
@@ -169,17 +169,17 @@ class EksClusterManagerTest {
@Test
void registriesYamlMirrorsEveryRegionHostnameAndThePathStyleForm() {
String yaml = EksClusterManager.buildRegistriesYaml(
"000000000000", AwsRegions.ALL, 4566, "http://floci:4566");
"000000000000", AwsRegions.advertised("aws"), 4566, "http://floci:4566");
assertTrue(yaml.startsWith("mirrors:\n"));
for (String region : AwsRegions.ALL) {
for (String region : AwsRegions.advertised("aws")) {
assertTrue(yaml.contains("\"000000000000.dkr.ecr." + region + ".localhost:4566\":"),
"should mirror the " + region + " hostname");
}
assertTrue(yaml.contains("\"localhost:4566\":"), "should mirror the path-style form");
assertFalse(yaml.contains("\"*\""), "must not catch-all public registries");
long endpoints = yaml.lines().filter(l -> l.contains("- \"http://floci:4566\"")).count();
assertEquals(AwsRegions.ALL.size() + 1, endpoints,
assertEquals(AwsRegions.advertised("aws").size() + 1, endpoints,
"every mirror should point at Floci's in-network data plane");
}
@@ -197,9 +197,9 @@ class EksClusterManagerTest {
void registriesYamlTlsAliasesPreserveLoopbackMirrorsAndInternalHttpEndpoint() {
String endpoint = "http://host.docker.internal:4577";
String yaml = EksClusterManager.buildRegistriesYaml(
"111122223333", AwsRegions.ALL, 4577, endpoint, true);
"111122223333", AwsRegions.advertised("aws"), 4577, endpoint, true);
for (String region : AwsRegions.ALL) {
for (String region : AwsRegions.advertised("aws")) {
assertTrue(yaml.contains("\"111122223333.dkr.ecr." + region + ".localhost:4577\":"));
assertTrue(yaml.contains("\"111122223333.dkr.ecr." + region + ".localhost.floci.io:4577\":"));
}
@@ -211,7 +211,7 @@ class EksClusterManagerTest {
assertFalse(yaml.contains("ghcr.io"));
assertFalse(yaml.contains("https://"), "internal pulls still use the HTTP data plane");
long endpoints = yaml.lines().filter(line -> line.contains("- \"" + endpoint + "\"")).count();
assertEquals(2L * (AwsRegions.ALL.size() + 1), endpoints);
assertEquals(2L * (AwsRegions.advertised("aws").size() + 1), endpoints);
}
@Test
@@ -0,0 +1,107 @@
package io.github.hectorvent.floci.services.lambda;
import io.github.hectorvent.floci.testing.PartitionCleanup;
import io.github.hectorvent.floci.testing.PartitionMatrix;
import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import java.io.ByteArrayOutputStream;
import java.util.Base64;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.startsWith;
/**
* The positive twin of the cross-partition layer cases: a layer published under a cn-north-1
* scope carries an {@code arn:aws-cn:} ARN, and that ARN resolves for a caller in the same
* partition, both through GetLayerVersionByArn and when a function attaches it.
*/
@QuarkusTest
class LambdaLayerChinaIntegrationTest {
private static final String REGION = "cn-north-1";
private static final String LAYER_NAME = "china-positive-layer";
private static final String FUNCTION_NAME = "china-positive-layer-fn";
@RegisterExtension
final PartitionCleanup cleanup = new PartitionCleanup();
private static String auth() {
return PartitionMatrix.sigV4Auth(REGION, "lambda");
}
private static String zipBase64(String path, String content) throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (ZipOutputStream zos = new ZipOutputStream(baos)) {
zos.putNextEntry(new ZipEntry(path));
zos.write(content.getBytes());
zos.closeEntry();
}
return Base64.getEncoder().encodeToString(baos.toByteArray());
}
@Test
void aLayerPublishedInChinaResolvesByItsChinaArn() throws Exception {
String layerVersionArn = given()
.header("Authorization", auth())
.contentType("application/json")
.body("""
{
"Content": { "ZipFile": "%s" },
"CompatibleRuntimes": ["python3.12"]
}
""".formatted(zipBase64("python/shared.py", "VALUE = 1")))
.when()
.post("/2018-10-31/layers/" + LAYER_NAME + "/versions")
.then()
.statusCode(201)
.body("LayerVersionArn", startsWith("arn:aws-cn:lambda:cn-north-1:000000000000:layer:" + LAYER_NAME + ":"))
.extract().path("LayerVersionArn");
String version = layerVersionArn.substring(layerVersionArn.lastIndexOf(':') + 1);
cleanup.register(() -> given()
.header("Authorization", auth())
.when()
.delete("/2018-10-31/layers/" + LAYER_NAME + "/versions/" + version)
.then()
.statusCode(204));
given()
.header("Authorization", auth())
.queryParam("find", "LayerVersion")
.queryParam("Arn", layerVersionArn)
.when()
.get("/2018-10-31/layers")
.then()
.statusCode(200)
.body("LayerVersionArn", equalTo(layerVersionArn));
given()
.header("Authorization", auth())
.contentType("application/json")
.body("""
{
"FunctionName": "%s",
"Runtime": "python3.12",
"Role": "arn:aws-cn:iam::000000000000:role/r",
"Handler": "handler.handler",
"Code": { "ZipFile": "%s" },
"Layers": ["%s"]
}
""".formatted(FUNCTION_NAME, zipBase64("handler.py", "def handler(e, c): return {}"), layerVersionArn))
.when()
.post("/2015-03-31/functions")
.then()
.statusCode(201)
.body("Layers[0].Arn", equalTo(layerVersionArn));
cleanup.register(() -> given()
.header("Authorization", auth())
.when()
.delete("/2015-03-31/functions/" + FUNCTION_NAME)
.then()
.statusCode(204));
}
}