mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(core): use the deployment region where Floci fell back to us-east-1 (#4974)
Seventeen code paths fell back to a hardcoded us-east-1 when the region was missing, each escaped as a partition-literal follow-up. In a GovCloud, China, ISO or EUSC deployment they minted ARNs, sent Cognito verification mail and SMS, named MWAA containers, answered IMDS, polled Pipes sources and invoked Scheduler targets in the commercial partition. Each now takes the region from the resource itself (its ARN or stored region) and otherwise from the deployment default: - AppSync and Cost Explorer read RegionResolver's default region. - Cognito sends verification messages from the pool's own region. - Control Catalog takes the request region from RegionResolver. - EKS takes the cluster region into the token-webhook path and VPC route programming, and mints pod identity association ARNs (and checks role partitions) from the cluster ARN with the deployment default otherwise. - MWAA, Pipes and Scheduler default to the configured region. - The IMDS identity document reports the configured availability zone, as the placement/availability-zone path already did. - CloudHSM and DynamoDB drop fallbacks their callers never reach: the request region and the table ARN are always present. Two literals stay, escaped with their real reason: the pricing snapshot file Floci bundles, and EKS's last-resort region that only a test constructor without a resolver or config reaches. No partition-literal follow-up remains.
This commit is contained in:
1 parent
ddfea8b161
commit
0bae2f0e35
32 files changed
+305
-119
No files matched your search
+17
@@ -2,12 +2,14 @@ package io.github.hectorvent.floci.services.appsync.graphql;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.common.RequestContext;
|
||||
import io.github.hectorvent.floci.services.appsync.AppSyncService;
|
||||
import io.github.hectorvent.floci.services.appsync.GraphqlSidecarClient;
|
||||
import io.github.hectorvent.floci.services.appsync.graphql.auth.AppSyncAuth;
|
||||
import io.github.hectorvent.floci.services.appsync.graphql.auth.AppSyncAuthContext;
|
||||
import io.github.hectorvent.floci.services.appsync.graphql.auth.AuthMiddleware;
|
||||
import io.github.hectorvent.floci.services.appsync.graphql.auth.AuthRequestInfo;
|
||||
import io.github.hectorvent.floci.core.common.docker.ContainerReachableEndpoint;
|
||||
import io.github.hectorvent.floci.services.appsync.graphql.auth.SidecarFieldAuthorizationPlanner;
|
||||
import io.github.hectorvent.floci.services.appsync.graphql.resolver.AppSyncResolverError;
|
||||
@@ -80,6 +82,7 @@ class AppSyncExecutionControllerTest {
|
||||
new ObjectMapper(),
|
||||
authMiddleware,
|
||||
requestContext,
|
||||
new RegionResolver("cn-north-1", "000000000000"),
|
||||
resolverExecutor,
|
||||
callbackSessions,
|
||||
reachableEndpoint);
|
||||
@@ -163,6 +166,20 @@ class AppSyncExecutionControllerTest {
|
||||
assertEquals("InternalFailure", error.get("message"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aRequestWithoutARegionAuthorizesInTheDeploymentDefaultRegion() {
|
||||
GraphqlApi api = new GraphqlApi();
|
||||
api.setApiId("api-1");
|
||||
when(appSyncService.getGraphqlApi("api-1")).thenReturn(api);
|
||||
when(authMiddleware.authenticate(any(), any(), any())).thenThrow(AppSyncAuth.unauthorized());
|
||||
|
||||
controller.execute("api-1", jsonHeaders, "{\"query\":\"{ hello }\"}");
|
||||
|
||||
ArgumentCaptor<AuthRequestInfo> info = ArgumentCaptor.forClass(AuthRequestInfo.class);
|
||||
verify(authMiddleware).authenticate(any(), any(), info.capture());
|
||||
assertEquals("cn-north-1", info.getValue().region());
|
||||
}
|
||||
|
||||
@Test
|
||||
void authFailureReturns401WithoutCallingSidecar() {
|
||||
GraphqlApi api = new GraphqlApi();
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package io.github.hectorvent.floci.services.ce.enumerator;
|
||||
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.common.UsageLine;
|
||||
import io.github.hectorvent.floci.services.s3.S3Service;
|
||||
import io.github.hectorvent.floci.services.s3.model.Bucket;
|
||||
import io.github.hectorvent.floci.services.s3.model.S3Object;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class S3UsageEnumeratorTest {
|
||||
|
||||
private static final Instant START = Instant.parse("2026-09-01T00:00:00Z");
|
||||
private static final Instant END = Instant.parse("2026-10-01T00:00:00Z");
|
||||
|
||||
@Test
|
||||
void aBucketWithoutAStoredRegionIsBilledToTheDeploymentDefaultRegion() {
|
||||
S3Service s3 = mock(S3Service.class);
|
||||
when(s3.listBuckets()).thenReturn(List.of(new Bucket("legacy-bucket")));
|
||||
S3Object object = new S3Object();
|
||||
object.setSize(1_073_741_824L);
|
||||
when(s3.listObjects(eq("legacy-bucket"), any(), any(), anyInt())).thenReturn(List.of(object));
|
||||
S3UsageEnumerator enumerator = new S3UsageEnumerator(s3, new RegionResolver("cn-north-1", "000000000000"));
|
||||
|
||||
List<UsageLine> lines = enumerator.enumerate(START, END, "cn-north-1").toList();
|
||||
|
||||
UsageLine bucketLine = lines.stream().filter(line -> line.resourceId() != null).findFirst().orElseThrow();
|
||||
assertEquals("cn-north-1", bucketLine.region());
|
||||
assertEquals("arn:aws-cn:s3:::legacy-bucket", bucketLine.resourceId());
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -92,7 +92,7 @@ class CognitoLambdaTriggersTest {
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
|
||||
"http://localhost:4566", regionResolver, lambdaService, mock(AcmService.class),
|
||||
verificationCodeService, new CognitoMessageDispatcher(ses, sns),
|
||||
verificationCodeService, new CognitoMessageDispatcher(ses, sns, "us-east-1"),
|
||||
mock(TlsCertificateManager.class));
|
||||
}
|
||||
|
||||
|
||||
+24
-1
@@ -34,7 +34,7 @@ class CognitoMessageDispatcherTest {
|
||||
void setUp() {
|
||||
ses = mock(SesService.class);
|
||||
sns = mock(SnsService.class);
|
||||
dispatcher = new CognitoMessageDispatcher(ses, sns);
|
||||
dispatcher = new CognitoMessageDispatcher(ses, sns, "us-east-1");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -183,6 +183,29 @@ class CognitoMessageDispatcherTest {
|
||||
verifyNoInteractions(ses);
|
||||
}
|
||||
|
||||
@Test
|
||||
void dispatch_sendsFromThePoolsOwnRegion() {
|
||||
UserPool pool = pool(Map.of());
|
||||
pool.setArn("arn:aws-cn:cognito-idp:cn-north-1:000000000000:userpool/cn-north-1_AbCdEfGhI");
|
||||
|
||||
dispatcher.dispatch(pool, user("alice@example.com", "+5215551234567"),
|
||||
VerificationCode.Purpose.SIGNUP_CONFIRMATION, "123456", List.of("EMAIL", "SMS"));
|
||||
|
||||
assertEquals("cn-north-1", sentEmail().region());
|
||||
verify(sns).publish(isNull(), isNull(), eq("+5215551234567"), anyString(), isNull(), isNull(),
|
||||
eq("cn-north-1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void dispatch_poolWithoutAnArnSendsFromTheDeploymentDefaultRegion() {
|
||||
CognitoMessageDispatcher china = new CognitoMessageDispatcher(ses, sns, "cn-northwest-1");
|
||||
|
||||
china.dispatch(pool(Map.of()), user("alice@example.com", null),
|
||||
VerificationCode.Purpose.SIGNUP_CONFIRMATION, "123456", List.of("EMAIL"));
|
||||
|
||||
assertEquals("cn-northwest-1", sentEmail().region());
|
||||
}
|
||||
|
||||
private SendEmailRequest sentEmail() {
|
||||
ArgumentCaptor<SendEmailRequest> captor = ArgumentCaptor.forClass(SendEmailRequest.class);
|
||||
verify(ses).sendEmail(captor.capture());
|
||||
|
||||
@@ -80,14 +80,24 @@ class Ec2MetadataServerTest {
|
||||
instance.setPrivateIpAddress("10.0.0.10");
|
||||
instance.setRegion("us-west-2");
|
||||
|
||||
assertTrue(Ec2MetadataServer.instanceIdentityDocument(instance, "000000000000")
|
||||
assertTrue(Ec2MetadataServer.instanceIdentityDocument(instance, "000000000000", "us-west-2a")
|
||||
.contains("\"architecture\":\"arm64\""));
|
||||
|
||||
instance.setArchitecture(null);
|
||||
assertTrue(Ec2MetadataServer.instanceIdentityDocument(instance, "000000000000")
|
||||
assertTrue(Ec2MetadataServer.instanceIdentityDocument(instance, "000000000000", "us-west-2a")
|
||||
.contains("\"architecture\":\"x86_64\""));
|
||||
}
|
||||
|
||||
@Test
|
||||
void identityDocumentOfAnInstanceWithoutPlacementReportsTheConfiguredZone() {
|
||||
Instance instance = new Instance();
|
||||
instance.setInstanceId("i-china");
|
||||
instance.setRegion("cn-north-1");
|
||||
|
||||
assertTrue(Ec2MetadataServer.instanceIdentityDocument(instance, "000000000000", "cn-north-1b")
|
||||
.contains("\"availabilityZone\":\"cn-north-1b\""));
|
||||
}
|
||||
|
||||
@Test
|
||||
void staleContainerUnregisterDoesNotRemoveCurrentRegistration() {
|
||||
Ec2MetadataServer server = new Ec2MetadataServer(null, null, null);
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.github.hectorvent.floci.services.eks;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.storage.InMemoryStorage;
|
||||
import io.github.hectorvent.floci.services.eks.model.Addon;
|
||||
import io.github.hectorvent.floci.services.eks.model.AddonInfo;
|
||||
@@ -648,7 +649,8 @@ class EksAddonServiceTest {
|
||||
InMemoryStorage<String, EksAddonService.StoredAddon> storage = new InMemoryStorage<>();
|
||||
InMemoryStorage<String, EksAddonService.StoredUpdate> updatesStorage = new InMemoryStorage<>();
|
||||
InMemoryStorage<String, EksPodIdentityAssociationService.StoredAssociation> assocStorage = new InMemoryStorage<>();
|
||||
EksPodIdentityAssociationService podIdentityAssociations = new EksPodIdentityAssociationService(assocStorage, iam);
|
||||
EksPodIdentityAssociationService podIdentityAssociations = new EksPodIdentityAssociationService(
|
||||
assocStorage, iam, new RegionResolver("us-east-1", "000000000000"));
|
||||
EksAddonService service = new EksAddonService(storage, updatesStorage, catalog, iam, podIdentityAssociations);
|
||||
|
||||
return new Fixture(cluster, iam, role, storage, updatesStorage, catalog, podIdentityAssociations, service);
|
||||
|
||||
@@ -104,16 +104,17 @@ class EksClusterManagerTest {
|
||||
cluster.setArn("arn:aws:eks:us-west-2:123456789012:cluster/demo");
|
||||
cluster.setCreatedAt(Instant.parse("2026-09-17T00:00:00Z"));
|
||||
assertEquals("/_floci/eks/clusters/demo/token-webhook/scope/123456789012"
|
||||
+ "/us-west-2/2026-09-17T00:00:00Z", EksClusterManager.webhookPath(cluster));
|
||||
+ "/us-west-2/2026-09-17T00:00:00Z", EksClusterManager.webhookPath(cluster, "cn-north-1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void webhookPathHandlesMissingArnOrCreatedAtGracefully() {
|
||||
// Without an ARN the region is the deployment default the caller passes, not us-east-1.
|
||||
Cluster cluster = new Cluster();
|
||||
cluster.setName("demo");
|
||||
cluster.setAccountId("123456789012");
|
||||
assertEquals("/_floci/eks/clusters/demo/token-webhook/scope/123456789012"
|
||||
+ "/us-east-1/1970-01-01T00:00:00Z", EksClusterManager.webhookPath(cluster));
|
||||
+ "/cn-north-1/1970-01-01T00:00:00Z", EksClusterManager.webhookPath(cluster, "cn-north-1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+23
-1
@@ -2,6 +2,7 @@ package io.github.hectorvent.floci.services.eks;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.storage.InMemoryStorage;
|
||||
import io.github.hectorvent.floci.services.eks.model.Cluster;
|
||||
import io.github.hectorvent.floci.services.eks.model.ClusterStatus;
|
||||
@@ -265,6 +266,26 @@ class EksPodIdentityAssociationServiceTest {
|
||||
assertEquals(created.associationId(), found.get().associationId());
|
||||
}
|
||||
|
||||
@Test
|
||||
void anAssociationOnAClusterWithoutAnArnLivesInTheDeploymentRegionAndPartition() {
|
||||
Cluster cluster = new Cluster();
|
||||
cluster.setName("cn-cluster");
|
||||
cluster.setAccountId("123456789012");
|
||||
cluster.setStatus(ClusterStatus.ACTIVE);
|
||||
String chinaRole = "arn:aws-cn:iam::123456789012:role/pod-role";
|
||||
IamService iam = mock(IamService.class);
|
||||
when(iam.findRole("123456789012", "pod-role"))
|
||||
.thenReturn(Optional.of(new IamRole("AROA-pod", "pod-role", "/", chinaRole, "{}")));
|
||||
EksPodIdentityAssociationService service = new EksPodIdentityAssociationService(new InMemoryStorage<>(), iam,
|
||||
new RegionResolver("cn-north-1", "000000000000"));
|
||||
|
||||
PodIdentityAssociation created = service.create(cluster, new CreatePodIdentityAssociationRequest(
|
||||
cluster.getName(), NAMESPACE, SERVICE_ACCOUNT, chinaRole, "token-cn", Map.of(), null, false, null));
|
||||
|
||||
assertEquals("arn:aws-cn:eks:cn-north-1:123456789012:podidentityassociation/cn-cluster/"
|
||||
+ created.associationId(), created.associationArn());
|
||||
}
|
||||
|
||||
private static Fixture fixture() {
|
||||
Cluster cluster = new Cluster();
|
||||
cluster.setName("test-cluster");
|
||||
@@ -277,7 +298,8 @@ class EksPodIdentityAssociationServiceTest {
|
||||
when(iam.findRole("123456789012", "pod-role")).thenReturn(Optional.of(role));
|
||||
|
||||
InMemoryStorage<String, EksPodIdentityAssociationService.StoredAssociation> storage = new InMemoryStorage<>();
|
||||
return new Fixture(cluster, iam, role, storage, new EksPodIdentityAssociationService(storage, iam));
|
||||
return new Fixture(cluster, iam, role, storage, new EksPodIdentityAssociationService(storage, iam,
|
||||
new RegionResolver("us-east-1", "000000000000")));
|
||||
}
|
||||
|
||||
private record Fixture(Cluster cluster, IamService iam, IamRole role,
|
||||
|
||||
+27
-6
@@ -26,6 +26,7 @@ import static org.mockito.ArgumentMatchers.anyList;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class EksVpcRouteProgrammingTest {
|
||||
@@ -224,13 +225,33 @@ class EksVpcRouteProgrammingTest {
|
||||
rt.setRoutes(List.of(r1, r2, rDefault, rPrefix, rIgw, rPcx));
|
||||
|
||||
List<EksVpcRouteProgramming.VpcRouteEntry> entries =
|
||||
EksVpcRouteProgramming.resolveProgrammableRoutes(cluster, List.of(rt), ec2);
|
||||
EksVpcRouteProgramming.resolveProgrammableRoutes(cluster, "us-east-1", List.of(rt), ec2);
|
||||
|
||||
assertEquals(2, entries.size());
|
||||
assertTrue(entries.stream().anyMatch(e -> "10.100.0.0/16".equals(e.destinationCidrBlock()) && "172.18.0.10".equals(e.gatewayIp())));
|
||||
assertTrue(entries.stream().anyMatch(e -> "10.200.0.0/16".equals(e.destinationCidrBlock()) && "172.18.0.20".equals(e.gatewayIp())));
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveProgrammableRoutesLooksEnisUpInTheRegionItIsGiven() {
|
||||
Ec2Service ec2 = mock(Ec2Service.class);
|
||||
Cluster cluster = new Cluster();
|
||||
cluster.setName("test-cluster");
|
||||
cluster.setAccountId("123456789012");
|
||||
when(ec2.describeNetworkInterfaces(anyString(), anyString(), anyList(), any()))
|
||||
.thenReturn(new NetworkInterfaceListResult(List.of(), null));
|
||||
|
||||
RouteTable rt = new RouteTable();
|
||||
rt.setRouteTableId("rtb-1");
|
||||
Route rEni = new Route("10.200.0.0/16", null, "CreateRoute");
|
||||
rEni.setNetworkInterfaceId("eni-1");
|
||||
rt.setRoutes(List.of(rEni));
|
||||
|
||||
EksVpcRouteProgramming.resolveProgrammableRoutes(cluster, "cn-north-1", List.of(rt), ec2);
|
||||
|
||||
verify(ec2).describeNetworkInterfaces(eq("123456789012"), eq("cn-north-1"), eq(List.of("eni-1")), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveProgrammableRoutesSkipsUnattachedEni() {
|
||||
Ec2Service ec2 = mock(Ec2Service.class);
|
||||
@@ -254,7 +275,7 @@ class EksVpcRouteProgrammingTest {
|
||||
rt.setRoutes(List.of(rEni));
|
||||
|
||||
List<EksVpcRouteProgramming.VpcRouteEntry> entries =
|
||||
EksVpcRouteProgramming.resolveProgrammableRoutes(cluster, List.of(rt), ec2);
|
||||
EksVpcRouteProgramming.resolveProgrammableRoutes(cluster, "us-east-1", List.of(rt), ec2);
|
||||
|
||||
assertTrue(entries.isEmpty(), "Unattached ENI must not be resolved as a route gateway");
|
||||
}
|
||||
@@ -284,7 +305,7 @@ class EksVpcRouteProgrammingTest {
|
||||
rt.setRoutes(List.of(rMissing, rValid));
|
||||
|
||||
List<EksVpcRouteProgramming.VpcRouteEntry> entries =
|
||||
EksVpcRouteProgramming.resolveProgrammableRoutes(cluster, List.of(rt), ec2);
|
||||
EksVpcRouteProgramming.resolveProgrammableRoutes(cluster, "us-east-1", List.of(rt), ec2);
|
||||
|
||||
assertEquals(1, entries.size(), "Valid instance route must still resolve despite missing ENI");
|
||||
assertEquals("10.201.0.0/16", entries.get(0).destinationCidrBlock());
|
||||
@@ -324,7 +345,7 @@ class EksVpcRouteProgrammingTest {
|
||||
rt.setRoutes(List.of(rEni));
|
||||
|
||||
List<EksVpcRouteProgramming.VpcRouteEntry> entries =
|
||||
EksVpcRouteProgramming.resolveProgrammableRoutes(cluster, List.of(rt), ec2);
|
||||
EksVpcRouteProgramming.resolveProgrammableRoutes(cluster, "us-east-1", List.of(rt), ec2);
|
||||
|
||||
assertEquals(1, entries.size());
|
||||
assertEquals("10.0.1.20", entries.get(0).gatewayIp());
|
||||
@@ -363,7 +384,7 @@ class EksVpcRouteProgrammingTest {
|
||||
rt.setRoutes(List.of(rEni));
|
||||
|
||||
List<EksVpcRouteProgramming.VpcRouteEntry> entries =
|
||||
EksVpcRouteProgramming.resolveProgrammableRoutes(cluster, List.of(rt), ec2);
|
||||
EksVpcRouteProgramming.resolveProgrammableRoutes(cluster, "us-east-1", List.of(rt), ec2);
|
||||
|
||||
assertEquals(1, entries.size());
|
||||
assertEquals("172.18.0.20", entries.get(0).gatewayIp(),
|
||||
@@ -402,7 +423,7 @@ class EksVpcRouteProgrammingTest {
|
||||
rt.setRoutes(List.of(rEni));
|
||||
|
||||
List<EksVpcRouteProgramming.VpcRouteEntry> entries =
|
||||
EksVpcRouteProgramming.resolveProgrammableRoutes(cluster, List.of(rt), ec2);
|
||||
EksVpcRouteProgramming.resolveProgrammableRoutes(cluster, "us-east-1", List.of(rt), ec2);
|
||||
|
||||
assertEquals(1, entries.size());
|
||||
assertEquals("172.17.0.5", entries.get(0).gatewayIp(),
|
||||
|
||||
+19
@@ -325,6 +325,25 @@ class MwaaEnvironmentManagerTest {
|
||||
MwaaEnvironmentManager.airflowContainerName(namespacedConfig, environment));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anEnvironmentWithoutAnArnIsNamedInTheConfiguredDefaultRegion() {
|
||||
EmulatorConfig.DockerConfig dockerConfig = Mockito.mock(EmulatorConfig.DockerConfig.class);
|
||||
when(dockerConfig.resourceNamespace()).thenReturn(Optional.empty());
|
||||
EmulatorConfig chinaConfig = Mockito.mock(EmulatorConfig.class);
|
||||
when(chinaConfig.docker()).thenReturn(dockerConfig);
|
||||
when(chinaConfig.defaultRegion()).thenReturn("cn-north-1");
|
||||
|
||||
Environment environment = new Environment();
|
||||
environment.setName("my-env");
|
||||
environment.setAccountId("000000000000");
|
||||
|
||||
assertEquals("floci-aws-mwaa-000000000000.cn-north-1.my-env-db",
|
||||
MwaaEnvironmentManager.dbContainerName(chinaConfig, environment));
|
||||
assertEquals("cn-north-1", MwaaEnvironmentManager.environmentRegion(environment, "cn-north-1"));
|
||||
environment.setArn("arn:aws:airflow:eu-west-1:000000000000:environment/my-env");
|
||||
assertEquals("eu-west-1", MwaaEnvironmentManager.environmentRegion(environment, "cn-north-1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void scopedContainerNamesDifferForSameNameEnvironments() {
|
||||
Environment eastEnvironment = new Environment();
|
||||
|
||||
@@ -120,10 +120,10 @@ class MwaaServiceTest {
|
||||
createRequest("arn:aws:s3:::west-bucket", "dags"));
|
||||
String westToken = (String) mwaaService.createCliToken("shared-name").get("CliToken");
|
||||
|
||||
assertTrue(mwaaService.isValidCliToken(MwaaService.environmentIdentity(westEnvironment), westToken));
|
||||
assertFalse(mwaaService.isValidCliToken(MwaaService.environmentIdentity(westEnvironment), eastToken));
|
||||
assertTrue(mwaaService.isValidCliToken(MwaaService.environmentIdentity(eastEnvironment), eastToken));
|
||||
assertFalse(mwaaService.isValidCliToken(MwaaService.environmentIdentity(eastEnvironment), westToken));
|
||||
assertTrue(mwaaService.isValidCliToken(mwaaService.environmentIdentity(westEnvironment), westToken));
|
||||
assertFalse(mwaaService.isValidCliToken(mwaaService.environmentIdentity(westEnvironment), eastToken));
|
||||
assertTrue(mwaaService.isValidCliToken(mwaaService.environmentIdentity(eastEnvironment), eastToken));
|
||||
assertFalse(mwaaService.isValidCliToken(mwaaService.environmentIdentity(eastEnvironment), westToken));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -535,9 +535,9 @@ class MwaaServiceTest {
|
||||
Map<String, Object> response = mwaaService.createCliToken("cli-token-env");
|
||||
String token = (String) response.get("CliToken");
|
||||
assertNotNull(token);
|
||||
assertTrue(mwaaService.isValidCliToken(MwaaService.environmentIdentity(
|
||||
assertTrue(mwaaService.isValidCliToken(mwaaService.environmentIdentity(
|
||||
mwaaService.getEnvironment("cli-token-env")), token));
|
||||
assertFalse(mwaaService.isValidCliToken(MwaaService.environmentIdentity(
|
||||
assertFalse(mwaaService.isValidCliToken(mwaaService.environmentIdentity(
|
||||
mwaaService.getEnvironment("cli-token-env")), "not-a-real-token"));
|
||||
assertFalse(mwaaService.isValidCliToken("other-env", token));
|
||||
}
|
||||
@@ -637,7 +637,7 @@ class MwaaServiceTest {
|
||||
assertEquals(EnvironmentStatus.CREATE_FAILED, environment.getStatus());
|
||||
verify(portAllocator).release(8701);
|
||||
verify(environmentManager).stopEnvironment(environment);
|
||||
verify(proxyManager).stopProxy(MwaaService.environmentIdentity(environment));
|
||||
verify(proxyManager).stopProxy(mwaaService.environmentIdentity(environment));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -129,6 +129,15 @@ class PipesPollerTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void aSourceWithoutAnArnRegionPollsInTheDeploymentDefaultRegion() {
|
||||
when(config.defaultRegion()).thenReturn("cn-north-1");
|
||||
PipesPoller chinaPoller = pollerOver(streams);
|
||||
|
||||
assertEquals("cn-north-1", chinaPoller.extractRegionFromArn("smk://broker.internal:9092"));
|
||||
assertEquals("eu-west-1", chinaPoller.extractRegionFromArn("arn:aws:sqs:eu-west-1:000000000000:orders"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void asEventArrayWrapsSingleObjectInBatchArray() throws Exception {
|
||||
// Pipes delivers events to a target as a batch array; a single-object enrichment response
|
||||
|
||||
@@ -90,6 +90,15 @@ class ScheduleInvokerTest {
|
||||
return schedule;
|
||||
}
|
||||
|
||||
@Test
|
||||
void aScheduleWithoutAnArnLivesInTheDeploymentDefaultRegion() {
|
||||
Schedule schedule = new Schedule();
|
||||
assertEquals("cn-north-1", ScheduleInvoker.regionOf(schedule, "cn-north-1"));
|
||||
|
||||
schedule.setArn("arn:aws:scheduler:eu-west-1:000000000000:schedule/default/nightly");
|
||||
assertEquals("eu-west-1", ScheduleInvoker.regionOf(schedule, "cn-north-1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void universalSnsPublishForwardsMessageAttributes() {
|
||||
Target target = new Target();
|
||||
|
||||
Reference in new issue
Block a user