mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
refactor: check an ARN's service, region and partition through one AwsArnUtils helper (#7109)
Step Functions and Route 53 Resolver each carried the same private check: an ARN of one service, in the request's region and that region's partition. AwsArnUtils.parseIfArnIn now holds it, and both services call it. Signed-off-by: Hector Ventura <hectorvent@gmail.com>
This commit is contained in:
1 parent
de6710ff0e
commit
d2f0455cd9
4 files changed
+38
-20
No files matched your search
@@ -206,6 +206,23 @@ class AwsArnUtilsTest {
|
||||
assertTrue(AwsArnUtils.resourceIfArnFor("arn:aws:s3", "s3").isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void parseIfArnInMatchesOnlyTheServiceInTheRegionAndItsPartition() {
|
||||
String arn = "arn:aws-cn:states:cn-north-1:000000000000:stateMachine:m";
|
||||
assertEquals("stateMachine:m", AwsArnUtils.parseIfArnIn(arn, "states", "cn-north-1").orElseThrow().resource());
|
||||
assertTrue(AwsArnUtils.parseIfArnIn(arn, "states", "cn-northwest-1").isEmpty());
|
||||
assertTrue(AwsArnUtils.parseIfArnIn(arn, "sqs", "cn-north-1").isEmpty());
|
||||
assertTrue(AwsArnUtils.parseIfArnIn("arn:aws:states:cn-north-1:000000000000:stateMachine:m",
|
||||
"states", "cn-north-1").isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void parseIfArnInIsEmptyForNonArns() {
|
||||
assertTrue(AwsArnUtils.parseIfArnIn(null, "states", "us-east-1").isEmpty());
|
||||
assertTrue(AwsArnUtils.parseIfArnIn("m", "states", "us-east-1").isEmpty());
|
||||
assertTrue(AwsArnUtils.parseIfArnIn("arn:aws:states", "states", "us-east-1").isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aPseudoRegionResolvesToItsPartitionWhenMinting() {
|
||||
assertEquals("arn:aws-cn:sqs:aws-cn-global:000000000000:q",
|
||||
|
||||
Reference in new issue
Block a user