mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
fix(cloudformation): reject a non-numeric AuthorizerResultTtlInSeconds (#4055)
ApiGatewayV2CfnProvisioner parsed AuthorizerResultTtlInSeconds with Integer.parseInt and let a non-numeric value throw a raw NumberFormatException (carried over as-is during the monolith extraction). Guard it and throw a CloudFormation ValidationError instead, matching how LambdaCfnProvisioner handles ReservedConcurrentExecutions. Refs #4021
This commit is contained in:
1 parent
60fd65b5b6
commit
eb247a50aa
2 files changed
+21
-1
No files matched your search
+6
-1
@@ -748,7 +748,12 @@ public class ApiGatewayV2CfnProvisioner implements CfnResourceProvisioner {
|
||||
|
||||
String ttl = ctx.resolveOptional(props, "AuthorizerResultTtlInSeconds");
|
||||
if (ttl != null) {
|
||||
req.put("authorizerResultTtlInSeconds", Integer.parseInt(ttl));
|
||||
try {
|
||||
req.put("authorizerResultTtlInSeconds", Integer.parseInt(ttl));
|
||||
} catch (NumberFormatException ignored) {
|
||||
throw new AwsException("ValidationError",
|
||||
"AuthorizerResultTtlInSeconds must be an integer", 400);
|
||||
}
|
||||
}
|
||||
String simpleResponses = ctx.resolveOptional(props, "EnableSimpleResponses");
|
||||
if (simpleResponses != null) {
|
||||
|
||||
+15
@@ -66,6 +66,21 @@ class ApiGatewayV2CfnProvisionerTest {
|
||||
api.getAttributes().get("ExecuteApiArn"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void authorizerWithNonNumericTtlIsRejected() throws Exception {
|
||||
StackResource authorizer = provisioner.provision("MyAuth", "AWS::ApiGatewayV2::Authorizer",
|
||||
mapper.readTree("""
|
||||
{"ApiId": "api-123",
|
||||
"IdentitySource": ["$request.header.Authorization"],
|
||||
"AuthorizerResultTtlInSeconds": "not-a-number"}
|
||||
"""),
|
||||
engine(), REGION, "000000000000", "test-stack", null, Map.of());
|
||||
|
||||
assertEquals("CREATE_FAILED", authorizer.getStatus());
|
||||
assertTrue(authorizer.getStatusReason().contains("AuthorizerResultTtlInSeconds must be an integer"),
|
||||
authorizer.getStatusReason());
|
||||
}
|
||||
|
||||
@Test
|
||||
void restoresExistingRoutesAndCleansPartialReplacementWhenRouteCreationFails() throws Exception {
|
||||
Route oldRoute = route("old-route", "GET /before");
|
||||
|
||||
Reference in new issue
Block a user