diff --git a/.github/ci/compat-partition-allowlist-cn-north-1.txt b/.github/ci/compat-partition-allowlist-cn-north-1.txt index c387cab1b8..612deddc43 100644 --- a/.github/ci/compat-partition-allowlist-cn-north-1.txt +++ b/.github/ci/compat-partition-allowlist-cn-north-1.txt @@ -51,21 +51,3 @@ S3VectorsTest#createVectorBucket SecretsManagerTest#rotateSecretStub SesEventPublishingTest# SsoOidcTest#createTokenWithIamUsesAwsSdk - -# The test exercises something that does not exist in China, and Floci answers as AWS -# does there (Marketplace and Lightsail are commercial-only, an eu-central-1 bucket cannot be -# created through a China endpoint, no global STS token version, China interface endpoint -# names, the China SAML sign-on URL). These need a commercial-only guard in the test. -Ec2Tests#describeVpcEndpointServices -IamTest#getAccountSummary -LightsailTest#sdkCanCreateAndManageCoreLightsailResources -MarketplaceAgreementTest#usesAwsSdkWireContract -MarketplaceCatalogTest#usesAwsSdkWireContract -MarketplaceDeploymentTest#usesAwsSdkWireContract -MarketplaceDiscoveryTest#usesAwsSdkWireContract -MarketplaceEntitlementTest#usesAwsSdkWireContract -S3Test#createBucketWithLocationConstraint -S3Test#deleteEuBucket -S3Test#getBucketLocationEuCentral1 -StsTest#assumeRoleWithSaml -StsTest#assumeRoleWithSamlAssumedRoleUser diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/Ec2Tests.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/Ec2Tests.java index c1027864d6..c1dc5102fc 100644 --- a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/Ec2Tests.java +++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/Ec2Tests.java @@ -1,12 +1,15 @@ package com.floci.test; import org.junit.jupiter.api.*; +import software.amazon.awssdk.regions.RegionMetadata; import software.amazon.awssdk.services.ec2.Ec2Client; import software.amazon.awssdk.services.ec2.model.*; import software.amazon.awssdk.services.ec2.model.Tag; import java.nio.charset.StandardCharsets; +import java.util.ArrayList; import java.util.Base64; +import java.util.Collections; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; @@ -947,24 +950,46 @@ class Ec2Tests { DescribeVpcEndpointServicesResponse resp = ec2.describeVpcEndpointServices( DescribeVpcEndpointServicesRequest.builder().build()); - assertThat(resp.serviceNames()).contains("com.amazonaws.us-east-1.s3"); + // The S3 gateway keeps com.amazonaws everywhere. Outside the commercial partition and GovCloud, + // AWS names some interface services under the partition's DNS suffix reversed (cn.com.amazonaws, + // eu.amazonaws, gov.ic.c2s, ...): ecr.api in every China, EUSC and ISO region, S3 only in China, + // where the two S3 offerings therefore split. + String region = TestFixtures.region().id(); + String reversedSuffix = reversedDnsSuffix(); + String s3Gateway = "com.amazonaws." + region + ".s3"; + String s3Interface = ("aws-cn".equals(TestFixtures.partition()) ? reversedSuffix : "com.amazonaws") + + "." + region + ".s3"; + assertThat(resp.serviceNames()).contains(s3Gateway, s3Interface); assertThat(resp.serviceDetails()).isNotEmpty(); - ServiceDetail s3 = resp.serviceDetails().stream() - .filter(d -> d.serviceName().equals("com.amazonaws.us-east-1.s3")) - .findFirst() - .orElseThrow(); - // S3 is the one service offering both endpoint types. - assertThat(s3.serviceType().stream().map(ServiceTypeDetail::serviceTypeAsString).toList()) - .containsExactlyInAnyOrder("Gateway", "Interface"); - assertThat(s3.availabilityZones()).isNotEmpty(); + if (s3Interface.equals(s3Gateway)) { + // S3 is the one service offering both endpoint types. + assertThat(serviceTypes(resp, s3Gateway)).containsExactlyInAnyOrder("Gateway", "Interface"); + } else { + assertThat(serviceTypes(resp, s3Gateway)).containsExactly("Gateway"); + assertThat(serviceTypes(resp, s3Interface)).containsExactly("Interface"); + } + assertThat(serviceDetail(resp, s3Gateway).availabilityZones()).isNotEmpty(); + assertThat(serviceTypes(resp, reversedSuffix + "." + region + ".ecr.api")).containsExactly("Interface"); + } - ServiceDetail ecr = resp.serviceDetails().stream() - .filter(d -> d.serviceName().equals("com.amazonaws.us-east-1.ecr.api")) + private static String reversedDnsSuffix() { + RegionMetadata metadata = TestFixtures.region().metadata(); + List labels = new ArrayList<>(List.of( + (metadata == null ? "amazonaws.com" : metadata.partition().dnsSuffix()).split("\\."))); + Collections.reverse(labels); + return String.join(".", labels); + } + + private static ServiceDetail serviceDetail(DescribeVpcEndpointServicesResponse resp, String name) { + return resp.serviceDetails().stream() + .filter(d -> d.serviceName().equals(name)) .findFirst() .orElseThrow(); - assertThat(ecr.serviceType().stream().map(ServiceTypeDetail::serviceTypeAsString).toList()) - .containsExactly("Interface"); + } + + private static List serviceTypes(DescribeVpcEndpointServicesResponse resp, String name) { + return serviceDetail(resp, name).serviceType().stream().map(ServiceTypeDetail::serviceTypeAsString).toList(); } @Test diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/IamTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/IamTest.java index 3ee946059d..1e569e10f6 100644 --- a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/IamTest.java +++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/IamTest.java @@ -477,7 +477,11 @@ class IamTest { @Order(101) void getAccountSummary() { GetAccountSummaryResponse response = iam.getAccountSummary(); - assertThat(response.summaryMap()).hasSize(34); + // GlobalEndpointTokenVersion reports the global STS endpoint, which only the commercial partition has. + boolean globalSts = "aws".equals(TestFixtures.partition()); + assertThat(response.summaryMap()).hasSize(globalSts ? 34 : 33); + assertThat(response.summaryMap().containsKey(SummaryKeyType.GLOBAL_ENDPOINT_TOKEN_VERSION)) + .isEqualTo(globalSts); assertThat(response.summaryMap().get(SummaryKeyType.USERS_QUOTA)).isEqualTo(5000); assertThat(response.summaryMap().get(SummaryKeyType.GROUPS_QUOTA)).isEqualTo(300); assertThat(response.summaryMap().get(SummaryKeyType.ROLES_QUOTA)).isEqualTo(1000); diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/LightsailTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/LightsailTest.java index f1b6d457c9..18b90dfb84 100644 --- a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/LightsailTest.java +++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/LightsailTest.java @@ -15,6 +15,7 @@ import software.amazon.awssdk.services.lightsail.model.StaticIp; import software.amazon.awssdk.services.lightsail.model.Tag; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assumptions.assumeTrue; class LightsailTest { @@ -29,6 +30,8 @@ class LightsailTest { @Test void sdkCanCreateAndManageCoreLightsailResources() { + assumeTrue("aws".equals(TestFixtures.partition()), + "Lightsail has no region outside the commercial partition"); String instanceName = suffix + "-web"; String diskName = suffix + "-data"; String staticIpName = suffix + "-ip"; diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/MarketplaceAgreementTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/MarketplaceAgreementTest.java index dd08abb28c..42d4813ba2 100644 --- a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/MarketplaceAgreementTest.java +++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/MarketplaceAgreementTest.java @@ -4,12 +4,19 @@ import org.junit.jupiter.api.Test; import software.amazon.awssdk.services.marketplaceagreement.MarketplaceAgreementClient; import software.amazon.awssdk.services.marketplaceagreement.model.SearchAgreementsResponse; +import java.util.List; + import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assumptions.assumeTrue; class MarketplaceAgreementTest { + private static final List REGIONS = List.of("us-east-1"); + @Test void usesAwsSdkWireContract() { + assumeTrue(REGIONS.contains(TestFixtures.region().id()), + "Floci serves AWS Marketplace Agreement only in us-east-1"); try (MarketplaceAgreementClient client = TestFixtures.marketplaceAgreementClient()) { SearchAgreementsResponse response = client.searchAgreements(r -> r.filters( f -> f.name("AgreementType").values("PurchaseAgreement"))); diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/MarketplaceCatalogTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/MarketplaceCatalogTest.java index 61c38cbbc2..23da11eb49 100644 --- a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/MarketplaceCatalogTest.java +++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/MarketplaceCatalogTest.java @@ -4,12 +4,19 @@ import org.junit.jupiter.api.Test; import software.amazon.awssdk.services.marketplacecatalog.MarketplaceCatalogClient; import software.amazon.awssdk.services.marketplacecatalog.model.ListEntitiesResponse; +import java.util.List; + import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assumptions.assumeTrue; class MarketplaceCatalogTest { + private static final List REGIONS = List.of("us-east-1"); + @Test void usesAwsSdkWireContract() { + assumeTrue(REGIONS.contains(TestFixtures.region().id()), + "AWS Marketplace Catalog has no endpoint in this region"); try (MarketplaceCatalogClient client = TestFixtures.marketplaceCatalogClient()) { ListEntitiesResponse response = client.listEntities(r -> r.catalog("AWSMarketplace").entityType("SaaSProduct")); assertNotNull(response.entitySummaryList()); diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/MarketplaceDeploymentTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/MarketplaceDeploymentTest.java index a2dc8be8ab..532dbfe2ea 100644 --- a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/MarketplaceDeploymentTest.java +++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/MarketplaceDeploymentTest.java @@ -4,13 +4,20 @@ import org.junit.jupiter.api.Test; import software.amazon.awssdk.services.marketplacedeployment.MarketplaceDeploymentClient; import software.amazon.awssdk.services.marketplacedeployment.model.PutDeploymentParameterResponse; -import static org.junit.jupiter.api.Assertions.assertNotNull; +import java.util.List; + import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assumptions.assumeTrue; class MarketplaceDeploymentTest { + private static final List REGIONS = List.of("us-east-1"); + @Test void usesAwsSdkWireContract() { + assumeTrue(REGIONS.contains(TestFixtures.region().id()), + "AWS Marketplace Deployment has no endpoint in this region"); try (MarketplaceDeploymentClient client = TestFixtures.marketplaceDeploymentClient()) { PutDeploymentParameterResponse response = client.putDeploymentParameter(r -> r .catalog("AWSMarketplace") diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/MarketplaceDiscoveryTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/MarketplaceDiscoveryTest.java index 01b5887643..0ff4ab4f31 100644 --- a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/MarketplaceDiscoveryTest.java +++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/MarketplaceDiscoveryTest.java @@ -4,13 +4,20 @@ import org.junit.jupiter.api.Test; import software.amazon.awssdk.services.marketplacediscovery.MarketplaceDiscoveryClient; import software.amazon.awssdk.services.marketplacediscovery.model.SearchListingsResponse; +import java.util.List; + import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; class MarketplaceDiscoveryTest { + private static final List REGIONS = List.of("us-east-1", "us-west-2", "eu-west-1"); + @Test void usesAwsSdkWireContract() { + assumeTrue(REGIONS.contains(TestFixtures.region().id()), + "Marketplace Discovery has no endpoint in this region"); try (MarketplaceDiscoveryClient client = TestFixtures.marketplaceDiscoveryClient()) { SearchListingsResponse response = client.searchListings(r -> r.searchText("sdk-compat")); assertTrue(response.totalResults() >= 0); diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/MarketplaceEntitlementTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/MarketplaceEntitlementTest.java index 15f2a8778e..e5b517907f 100644 --- a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/MarketplaceEntitlementTest.java +++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/MarketplaceEntitlementTest.java @@ -4,13 +4,20 @@ import org.junit.jupiter.api.Test; import software.amazon.awssdk.services.marketplaceentitlement.MarketplaceEntitlementClient; import software.amazon.awssdk.services.marketplaceentitlement.model.GetEntitlementsResponse; +import java.util.List; + import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; class MarketplaceEntitlementTest { + private static final List REGIONS = List.of("us-east-1"); + @Test void usesAwsSdkWireContract() { + assumeTrue(REGIONS.contains(TestFixtures.region().id()), + "Floci serves AWS Marketplace Entitlement only in us-east-1"); try (MarketplaceEntitlementClient client = TestFixtures.marketplaceEntitlementClient()) { GetEntitlementsResponse response = client.getEntitlements(r -> r.productCode("product-local")); assertNotNull(response.entitlements()); diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/S3Test.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/S3Test.java index d445dd0c40..0486b5cfbd 100644 --- a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/S3Test.java +++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/S3Test.java @@ -54,7 +54,11 @@ class S3Test { private static S3Client s3; private static final String BUCKET = "sdk-test-bucket"; - private static final String EU_BUCKET = "sdk-test-bucket-eu"; + private static final String LOCATED_BUCKET = "sdk-test-bucket-located"; + // Only the us-east-1 endpoint creates a bucket in another region; any other endpoint takes its own. + private static final BucketLocationConstraint LOCATION = TestFixtures.region().id().equals("us-east-1") + ? BucketLocationConstraint.EU_CENTRAL_1 + : BucketLocationConstraint.fromValue(TestFixtures.region().id()); private static final String KEY = "test-file.txt"; private static final String CONTENT = "Hello from AWS SDK v2!"; @@ -73,7 +77,7 @@ class S3Test { s3.deleteBucket(DeleteBucketRequest.builder().bucket(BUCKET).build()); } catch (Exception ignored) {} try { - s3.deleteBucket(DeleteBucketRequest.builder().bucket(EU_BUCKET).build()); + s3.deleteBucket(DeleteBucketRequest.builder().bucket(LOCATED_BUCKET).build()); } catch (Exception ignored) {} s3.close(); } @@ -89,20 +93,20 @@ class S3Test { @Order(2) void createBucketWithLocationConstraint() { s3.createBucket(CreateBucketRequest.builder() - .bucket(EU_BUCKET) + .bucket(LOCATED_BUCKET) .createBucketConfiguration(CreateBucketConfiguration.builder() - .locationConstraint(BucketLocationConstraint.EU_CENTRAL_1) + .locationConstraint(LOCATION) .build()) .build()); } @Test @Order(3) - void getBucketLocationEuCentral1() { + void getBucketLocationReturnsTheConstraint() { GetBucketLocationResponse response = s3.getBucketLocation( - GetBucketLocationRequest.builder().bucket(EU_BUCKET).build()); + GetBucketLocationRequest.builder().bucket(LOCATED_BUCKET).build()); - assertThat(response.locationConstraint()).isEqualTo(BucketLocationConstraint.EU_CENTRAL_1); + assertThat(response.locationConstraint()).isEqualTo(LOCATION); } @Test @@ -385,8 +389,8 @@ class S3Test { @Test @Order(24) - void deleteEuBucket() { - s3.deleteBucket(DeleteBucketRequest.builder().bucket(EU_BUCKET).build()); + void deleteLocatedBucket() { + s3.deleteBucket(DeleteBucketRequest.builder().bucket(LOCATED_BUCKET).build()); } @Test diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/StsTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/StsTest.java index 9e5cd75950..639cce9e13 100644 --- a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/StsTest.java +++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/StsTest.java @@ -46,6 +46,7 @@ import java.time.Instant; import java.util.Base64; import java.util.Date; import java.util.List; +import java.util.Map; import java.util.UUID; import java.util.function.Function; @@ -61,6 +62,14 @@ class StsTest { private static String allowedRoleArn; private static String allowedRoleName; + // The console sign-on URL a bearer assertion names, per partition (the CDK region facts). A + // partition the CDK lists none for keeps the commercial URL, as Floci does. + private static final Map SAML_SIGN_ON_URLS = Map.of( + "aws", "https://signin.aws.amazon.com/saml", + "aws-cn", "https://signin.amazonaws.cn/saml", + "aws-us-gov", "https://signin.amazonaws-us-gov.com/saml", + "aws-iso", "https://signin.c2shome.ic.gov/saml", + "aws-iso-b", "https://signin.sc2shome.sgov.gov/saml"); private static final String OPEN_TRUST_POLICY = "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":\"sts:AssumeRole\"}]}"; @BeforeAll @@ -433,7 +442,8 @@ class StsTest { String xml = "" + issuer + "sdk-test-subject" - + "" + + "urn:amazon:webservices" @@ -462,4 +472,8 @@ class StsTest { throw new IllegalStateException("Could not create SAML assertion", e); } } + + private static String samlSignOnUrl() { + return SAML_SIGN_ON_URLS.getOrDefault(TestFixtures.partition(), SAML_SIGN_ON_URLS.get("aws")); + } }