mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(lambda): preserve code signing ARN partition (#6913)
This commit is contained in:
1 parent
23d815f08b
commit
479595e6ec
3 files changed
+39
-4
No files matched your search
+32
@@ -164,6 +164,38 @@ class LambdaCodeSigningAccountScopeTest {
|
||||
.orElseThrow().getCodeSigningConfigArn());
|
||||
}
|
||||
|
||||
@Test
|
||||
void unpublishedRegionFunctionArnUsesDeploymentPartition(@TempDir Path codePath) {
|
||||
String region = "xx-nowhere-9";
|
||||
String functionArn = "arn:aws-cn:lambda:" + region + ":" + CALLER_ACCOUNT
|
||||
+ ":function:" + FUNCTION_NAME;
|
||||
String configArn = "arn:aws-cn:lambda:" + region + ":" + CALLER_ACCOUNT
|
||||
+ ":code-signing-config:csc-0123456789abcdef0";
|
||||
LambdaFunctionStore store = new LambdaFunctionStore(
|
||||
AccountAwareStorageBackend.inMemory(CALLER_ACCOUNT));
|
||||
LambdaFunction function = function(CALLER_ACCOUNT);
|
||||
function.setFunctionArn(functionArn);
|
||||
store.saveForAccount(CALLER_ACCOUNT, region, function);
|
||||
RegionResolver regions = new RegionResolver("cn-north-1", CALLER_ACCOUNT);
|
||||
LambdaService service = new LambdaService(store, new WarmPool(), new CodeStore(codePath),
|
||||
new ZipExtractor(), regions);
|
||||
|
||||
service.putFunctionCodeSigningConfig(region, functionArn, configArn);
|
||||
assertEquals(configArn, service.getFunctionForCodeSigningConfig(region, functionArn)
|
||||
.getCodeSigningConfigArn());
|
||||
|
||||
String foreignArn = functionArn.replace("arn:aws-cn:", "arn:aws:");
|
||||
AwsException error = assertThrows(AwsException.class,
|
||||
() -> service.putFunctionCodeSigningConfig(region, foreignArn, configArn));
|
||||
assertEquals("ResourceNotFoundException", error.getErrorCode());
|
||||
assertEquals(configArn, store.getForAccount(CALLER_ACCOUNT, region, FUNCTION_NAME)
|
||||
.orElseThrow().getCodeSigningConfigArn());
|
||||
|
||||
service.deleteFunctionCodeSigningConfig(region, functionArn);
|
||||
assertNull(store.getForAccount(CALLER_ACCOUNT, region, FUNCTION_NAME)
|
||||
.orElseThrow().getCodeSigningConfigArn());
|
||||
}
|
||||
|
||||
@Test
|
||||
void foreignPartialRegionAndAccountReferencesCannotMutateCallerFunction(@TempDir Path codePath) {
|
||||
LambdaFunctionStore store = new LambdaFunctionStore(
|
||||
|
||||
Reference in new issue
Block a user