feat(lambda): add missing runtimes, fix handler validation, long path… (#256)

* feat(lambda): add missing runtimes, fix handler validation, long path extraction, and code signing config
* fix: removed unrequired go.sum and package-lock.json from compatibility test
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-04-07 12:40:30 -05:00
1 parent 48b6ca3475
commit 0ef6f87cba
16 files changed
+477 -4026

No files matched your search

@@ -0,0 +1,70 @@
package io.github.hectorvent.floci.services.lambda;
import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.*;
@QuarkusTest
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class LambdaCodeSigningIntegrationTest {
private static final String SIGNING_PATH = "/2020-06-30";
private static final String LAMBDA_PATH = "/2015-03-31";
@Test
@Order(1)
void setUp() {
given()
.contentType("application/json")
.body("""
{
"FunctionName": "signing-test-fn",
"Runtime": "nodejs20.x",
"Role": "arn:aws:iam::000000000000:role/lambda-role",
"Handler": "index.handler"
}
""")
.when()
.post(LAMBDA_PATH + "/functions")
.then()
.statusCode(201);
}
@Test
@Order(2)
void getFunctionCodeSigningConfig_returnsEmptyArnForExistingFunction() {
given()
.when()
.get(SIGNING_PATH + "/functions/signing-test-fn/code-signing-config")
.then()
.statusCode(200)
.body("FunctionName", equalTo("signing-test-fn"))
.body("CodeSigningConfigArn", equalTo(""));
}
@Test
@Order(3)
void getFunctionCodeSigningConfig_returns404ForUnknownFunction() {
given()
.when()
.get(SIGNING_PATH + "/functions/does-not-exist/code-signing-config")
.then()
.statusCode(404)
.body("__type", equalTo("ResourceNotFoundException"));
}
@Test
@Order(4)
void tearDown() {
given()
.when()
.delete(LAMBDA_PATH + "/functions/signing-test-fn")
.then()
.statusCode(204);
}
}
@@ -123,6 +123,42 @@ class LambdaServiceTest {
assertEquals("ResourceNotFoundException", ex.getErrorCode());
}
@Test
void createImageFunctionSucceedsWithoutHandler() {
Map<String, Object> req = new java.util.HashMap<>(Map.of(
"FunctionName", "image-fn",
"Role", "arn:aws:iam::000000000000:role/test-role",
"PackageType", "Image",
"ImageUri", "myrepo/myimage:latest"
));
LambdaFunction fn = service.createFunction(REGION, req);
assertEquals("image-fn", fn.getFunctionName());
assertEquals("Image", fn.getPackageType());
assertNull(fn.getHandler());
}
@Test
void createImageFunctionSucceedsWithHandler() {
Map<String, Object> req = new java.util.HashMap<>(Map.of(
"FunctionName", "image-fn-with-handler",
"Role", "arn:aws:iam::000000000000:role/test-role",
"PackageType", "Image",
"ImageUri", "myrepo/myimage:latest",
"Handler", "com.example.Handler::handleRequest"
));
LambdaFunction fn = service.createFunction(REGION, req);
assertEquals("com.example.Handler::handleRequest", fn.getHandler());
}
@Test
void createZipFunctionFailsWithoutHandler() {
Map<String, Object> req = baseRequest("zip-no-handler");
req.remove("Handler");
AwsException ex = assertThrows(AwsException.class, () -> service.createFunction(REGION, req));
assertEquals("InvalidParameterValueException", ex.getErrorCode());
assertTrue(ex.getMessage().contains("Handler"));
}
@Test
void updateFunctionCodeUpdatesRevision() {
service.createFunction(REGION, baseRequest("update-fn"));
@@ -21,21 +21,34 @@ class ImageResolverTest {
@ParameterizedTest
@CsvSource({
"java25, public.ecr.aws/lambda/java:25",
"java21, public.ecr.aws/lambda/java:21",
"java17, public.ecr.aws/lambda/java:17",
"java11, public.ecr.aws/lambda/java:11",
"java8.al2, public.ecr.aws/lambda/java:8.al2",
"java8, public.ecr.aws/lambda/java:8",
"python3.14, public.ecr.aws/lambda/python:3.14",
"python3.13, public.ecr.aws/lambda/python:3.13",
"python3.12, public.ecr.aws/lambda/python:3.12",
"python3.11, public.ecr.aws/lambda/python:3.11",
"python3.10, public.ecr.aws/lambda/python:3.10",
"python3.9, public.ecr.aws/lambda/python:3.9",
"nodejs24.x, public.ecr.aws/lambda/nodejs:24",
"nodejs22.x, public.ecr.aws/lambda/nodejs:22",
"nodejs20.x, public.ecr.aws/lambda/nodejs:20",
"nodejs18.x, public.ecr.aws/lambda/nodejs:18",
"nodejs16.x, public.ecr.aws/lambda/nodejs:16",
"ruby3.4, public.ecr.aws/lambda/ruby:3.4",
"ruby3.3, public.ecr.aws/lambda/ruby:3.3",
"ruby3.2, public.ecr.aws/lambda/ruby:3.2",
"dotnet10, public.ecr.aws/lambda/dotnet:10",
"dotnet9, public.ecr.aws/lambda/dotnet:9",
"dotnet8, public.ecr.aws/lambda/dotnet:8",
"dotnet6, public.ecr.aws/lambda/dotnet:6",
"go1.x, public.ecr.aws/lambda/go:1",
"provided.al2023, public.ecr.aws/lambda/provided:al2023",
"provided.al2, public.ecr.aws/lambda/provided:al2"
"provided.al2, public.ecr.aws/lambda/provided:al2",
"provided, public.ecr.aws/lambda/provided:latest"
})
void resolvesKnownRuntimes(String runtime, String expectedImage) {
assertEquals(expectedImage, resolver.resolve(runtime));
@@ -43,21 +56,34 @@ class ImageResolverTest {
@ParameterizedTest
@CsvSource({
"java25, my.custom.host/lambda/java:25",
"java21, my.custom.host/lambda/java:21",
"java17, my.custom.host/lambda/java:17",
"java11, my.custom.host/lambda/java:11",
"java8.al2, my.custom.host/lambda/java:8.al2",
"java8, my.custom.host/lambda/java:8",
"python3.14, my.custom.host/lambda/python:3.14",
"python3.13, my.custom.host/lambda/python:3.13",
"python3.12, my.custom.host/lambda/python:3.12",
"python3.11, my.custom.host/lambda/python:3.11",
"python3.10, my.custom.host/lambda/python:3.10",
"python3.9, my.custom.host/lambda/python:3.9",
"nodejs24.x, my.custom.host/lambda/nodejs:24",
"nodejs22.x, my.custom.host/lambda/nodejs:22",
"nodejs20.x, my.custom.host/lambda/nodejs:20",
"nodejs18.x, my.custom.host/lambda/nodejs:18",
"nodejs16.x, my.custom.host/lambda/nodejs:16",
"ruby3.4, my.custom.host/lambda/ruby:3.4",
"ruby3.3, my.custom.host/lambda/ruby:3.3",
"ruby3.2, my.custom.host/lambda/ruby:3.2",
"dotnet10, my.custom.host/lambda/dotnet:10",
"dotnet9, my.custom.host/lambda/dotnet:9",
"dotnet8, my.custom.host/lambda/dotnet:8",
"dotnet6, my.custom.host/lambda/dotnet:6",
"go1.x, my.custom.host/lambda/go:1",
"provided.al2023, my.custom.host/lambda/provided:al2023",
"provided.al2, my.custom.host/lambda/provided:al2"
"provided.al2, my.custom.host/lambda/provided:al2",
"provided, my.custom.host/lambda/provided:latest"
})
void resolvesKnownRuntimesWithHostOverride(String runtime, String expectedImage) {
EmulatorConfig customConfig = mock(EmulatorConfig.class);
@@ -68,21 +94,34 @@ class ImageResolverTest {
@ParameterizedTest
@CsvSource({
"java25, my.custom.host/path/lambda/java:25",
"java21, my.custom.host/path/lambda/java:21",
"java17, my.custom.host/path/lambda/java:17",
"java11, my.custom.host/path/lambda/java:11",
"java8.al2, my.custom.host/path/lambda/java:8.al2",
"java8, my.custom.host/path/lambda/java:8",
"python3.14, my.custom.host/path/lambda/python:3.14",
"python3.13, my.custom.host/path/lambda/python:3.13",
"python3.12, my.custom.host/path/lambda/python:3.12",
"python3.11, my.custom.host/path/lambda/python:3.11",
"python3.10, my.custom.host/path/lambda/python:3.10",
"python3.9, my.custom.host/path/lambda/python:3.9",
"nodejs24.x, my.custom.host/path/lambda/nodejs:24",
"nodejs22.x, my.custom.host/path/lambda/nodejs:22",
"nodejs20.x, my.custom.host/path/lambda/nodejs:20",
"nodejs18.x, my.custom.host/path/lambda/nodejs:18",
"nodejs16.x, my.custom.host/path/lambda/nodejs:16",
"ruby3.4, my.custom.host/path/lambda/ruby:3.4",
"ruby3.3, my.custom.host/path/lambda/ruby:3.3",
"ruby3.2, my.custom.host/path/lambda/ruby:3.2",
"dotnet10, my.custom.host/path/lambda/dotnet:10",
"dotnet9, my.custom.host/path/lambda/dotnet:9",
"dotnet8, my.custom.host/path/lambda/dotnet:8",
"dotnet6, my.custom.host/path/lambda/dotnet:6",
"go1.x, my.custom.host/path/lambda/go:1",
"provided.al2023, my.custom.host/path/lambda/provided:al2023",
"provided.al2, my.custom.host/path/lambda/provided:al2"
"provided.al2, my.custom.host/path/lambda/provided:al2",
"provided, my.custom.host/path/lambda/provided:latest"
})
void resolvesKnownRuntimesWithHostAndPathOverride(String runtime, String expectedImage) {
EmulatorConfig customConfig = mock(EmulatorConfig.class);
@@ -105,7 +144,7 @@ class ImageResolverTest {
@Test
void throwsForUnknownRuntime() {
AwsException ex = assertThrows(AwsException.class, () -> resolver.resolve("dotnet8"));
AwsException ex = assertThrows(AwsException.class, () -> resolver.resolve("dotnet7"));
assertEquals("InvalidParameterValueException", ex.getErrorCode());
}