mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(lambda): resolve partition for layer lookup and principals (#6947)
This commit is contained in:
1 parent
b73f643d3f
commit
b063f7ff8c
4 files changed
+35
-5
No files matched your search
+14
@@ -48,6 +48,20 @@ class LambdaLayerAsyncAccountTest {
|
||||
assertNull(service.resolveLayerByArnForAccount(ownerLayer.getLayerVersionArn(), OWNER, "cn-north-1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void backgroundLookupInUnpublishedRegionUsesDeploymentPartition() {
|
||||
String region = "xx-nowhere-9";
|
||||
AccountAwareStorageBackend<LambdaLayerVersion> storage = AccountAwareStorageBackend.inMemory(DEFAULT_ACCOUNT);
|
||||
LambdaLayerService service = new LambdaLayerService(new LambdaLayerStore(storage), null, null,
|
||||
new RegionResolver("cn-north-1", DEFAULT_ACCOUNT), null);
|
||||
LambdaLayerVersion ownerLayer = layer("arn:aws-cn:lambda:" + region + ":" + OWNER + ":layer:shared:1");
|
||||
storage.putForAccount(OWNER, "layer::" + region + "::shared::1", ownerLayer);
|
||||
|
||||
assertSame(ownerLayer, service.resolveLayerByArnForAccount(ownerLayer.getLayerVersionArn(), OWNER, region));
|
||||
assertNull(service.resolveLayerByArnForAccount(
|
||||
"arn:aws:lambda:" + region + ":" + OWNER + ":layer:shared:1", OWNER, region));
|
||||
}
|
||||
|
||||
@Test
|
||||
void absentLayerOrInvalidOwnerNeverFallsBackToAmbientStorage() {
|
||||
AccountAwareStorageBackend<LambdaLayerVersion> storage = AccountAwareStorageBackend.inMemory(DEFAULT_ACCOUNT);
|
||||
|
||||
@@ -3281,6 +3281,24 @@ class LambdaServiceTest {
|
||||
assertEquals(Map.of("AWS", "arn:aws-cn:iam::111122223333:root"), statement.get("Principal"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void addPermission_accountIdInUnpublishedRegion_usesDeploymentPartition() {
|
||||
String region = "xx-nowhere-9";
|
||||
LambdaFunctionStore store = new LambdaFunctionStore(new InMemoryStorage<String, LambdaFunction>());
|
||||
service = new LambdaService(store, new WarmPool(), new CodeStore(Path.of("target/test-data/lambda-code")),
|
||||
new ZipExtractor(), new RegionResolver("cn-north-1", "000000000000"));
|
||||
Map<String, Object> request = baseRequest("perm-unpublished-principal-fn");
|
||||
request.put("Role", "arn:aws-cn:iam::000000000000:role/test-role");
|
||||
service.createFunction(region, request);
|
||||
|
||||
Map<String, Object> statement = service.addPermission(region, "perm-unpublished-principal-fn", null, Map.of(
|
||||
"StatementId", "cross-account",
|
||||
"Action", "lambda:InvokeFunction",
|
||||
"Principal", "111122223333"));
|
||||
|
||||
assertEquals(Map.of("AWS", "arn:aws-cn:iam::111122223333:root"), statement.get("Principal"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void addPermission_functionUrlAuthTypeOutsideTheEnum_isRejectedAndLeavesNoStatement() {
|
||||
// Catches: an unknown FunctionUrlAuthType stored as a condition no function URL can ever match
|
||||
|
||||
Reference in new issue
Block a user