diff --git a/aws-serverless-java-container-struts/pom.xml b/aws-serverless-java-container-struts/pom.xml deleted file mode 100644 index 4546f4723..000000000 --- a/aws-serverless-java-container-struts/pom.xml +++ /dev/null @@ -1,195 +0,0 @@ - - - 4.0.0 - - aws-serverless-java-container-struts - AWS Serverless Java container support - Struts implementation - Allows Java applications written for the Struts framework to run in AWS Lambda - https://aws.amazon.com/lambda - 2.1.0-SNAPSHOT - - - com.amazonaws.serverless - aws-serverless-java-container - 2.1.0-SNAPSHOT - - - - 7.0.0-M9 - - - - - - com.amazonaws.serverless - aws-serverless-java-container-core - 2.1.0-SNAPSHOT - - - com.amazonaws.serverless - aws-serverless-java-container-core - 2.1.0-SNAPSHOT - tests - test-jar - test - - - - org.apache.struts - struts2-core - ${struts.version} - - - commons-io - commons-io - - - - - org.apache.struts - struts2-json-plugin - ${struts.version} - test - - - - org.apache.struts - struts2-junit-plugin - ${struts.version} - test - - - junit - junit - - - - - - commons-codec - commons-codec - 1.17.1 - test - - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - - jakarta.el - jakarta.el-api - 5.0.1 - test - - - - jakarta.servlet.jsp - jakarta.servlet.jsp-api - 3.1.0 - test - - - - org.glassfish - jakarta.el - 5.0.0-M1 - test - - - - - - - org.jacoco - jacoco-maven-plugin - - ${basedir}/target/coverage-reports/jacoco-unit.exec - ${basedir}/target/coverage-reports/jacoco-unit.exec - - - - default-prepare-agent - - prepare-agent - - - - jacoco-site - package - - report - - - - jacoco-check - test - - check - - - true - - BUNDLE - - - INSTRUCTION - COVEREDRATIO - ${jacoco.minCoverage} - - - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - false - - - - com.github.spotbugs - spotbugs-maven-plugin - - - - analyze-compile - compile - - check - - - - - - org.owasp - dependency-check-maven - ${dependencyCheck.version} - - true - - ${project.basedir}/../owasp-suppression.xml - - 7 - false - - - - - - - - apache-pre-release - https://repository.apache.org/content/repositories/staging/ - default - - - diff --git a/aws-serverless-java-container-struts/src/main/java/com/amazonaws/serverless/proxy/struts/StrutsLambdaContainerHandler.java b/aws-serverless-java-container-struts/src/main/java/com/amazonaws/serverless/proxy/struts/StrutsLambdaContainerHandler.java deleted file mode 100644 index 257de488c..000000000 --- a/aws-serverless-java-container-struts/src/main/java/com/amazonaws/serverless/proxy/struts/StrutsLambdaContainerHandler.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ -package com.amazonaws.serverless.proxy.struts; - -import com.amazonaws.serverless.exceptions.ContainerInitializationException; -import com.amazonaws.serverless.proxy.AwsHttpApiV2SecurityContextWriter; -import com.amazonaws.serverless.proxy.AwsProxyExceptionHandler; -import com.amazonaws.serverless.proxy.AwsProxySecurityContextWriter; -import com.amazonaws.serverless.proxy.ExceptionHandler; -import com.amazonaws.serverless.proxy.RequestReader; -import com.amazonaws.serverless.proxy.ResponseWriter; -import com.amazonaws.serverless.proxy.SecurityContextWriter; -import com.amazonaws.serverless.proxy.internal.servlet.AwsHttpApiV2HttpServletRequestReader; -import com.amazonaws.serverless.proxy.internal.servlet.AwsHttpServletRequest; -import com.amazonaws.serverless.proxy.internal.servlet.AwsHttpServletResponse; -import com.amazonaws.serverless.proxy.internal.servlet.AwsLambdaServletContainerHandler; -import com.amazonaws.serverless.proxy.internal.servlet.AwsProxyHttpServletRequestReader; -import com.amazonaws.serverless.proxy.internal.servlet.AwsProxyHttpServletResponseWriter; -import com.amazonaws.serverless.proxy.internal.testutils.Timer; -import com.amazonaws.serverless.proxy.model.AwsProxyRequest; -import com.amazonaws.serverless.proxy.model.AwsProxyResponse; -import com.amazonaws.serverless.proxy.model.HttpApiV2ProxyRequest; -import com.amazonaws.services.lambda.runtime.Context; -import org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import jakarta.servlet.DispatcherType; -import jakarta.servlet.FilterRegistration; -import jakarta.servlet.Servlet; -import jakarta.servlet.http.HttpServletRequest; -import java.util.EnumSet; -import java.util.concurrent.CountDownLatch; - -/** - * A Lambda handler to initialize the Struts filter and proxy the requests. - * - * @param request type - * @param response type - */ -public class StrutsLambdaContainerHandler extends AwsLambdaServletContainerHandler { - - private static final Logger log = LoggerFactory.getLogger(StrutsLambdaContainerHandler.class); - - public static final String HEADER_STRUTS_STATUS_CODE = "X-Struts-StatusCode"; - - private static final String TIMER_STRUTS_CONTAINER_CONSTRUCTOR = "STRUTS_CONTAINER_CONSTRUCTOR"; - private static final String TIMER_STRUTS_HANDLE_REQUEST = "STRUTS_HANDLE_REQUEST"; - private static final String TIMER_STRUTS_COLD_START_INIT = "STRUTS_COLD_START_INIT"; - private static final String STRUTS_FILTER_NAME = "StrutsFilter"; - - private boolean initialized; - - public static StrutsLambdaContainerHandler getAwsProxyHandler() { - return new StrutsLambdaContainerHandler( - AwsProxyRequest.class, - AwsProxyResponse.class, - new AwsProxyHttpServletRequestReader(), - new AwsProxyHttpServletResponseWriter(), - new AwsProxySecurityContextWriter(), - new AwsProxyExceptionHandler()); - } - - public static StrutsLambdaContainerHandler getHttpApiV2ProxyHandler() { - return new StrutsLambdaContainerHandler( - HttpApiV2ProxyRequest.class, - AwsProxyResponse.class, - new AwsHttpApiV2HttpServletRequestReader(), - new AwsProxyHttpServletResponseWriter(true), - new AwsHttpApiV2SecurityContextWriter(), - new AwsProxyExceptionHandler()); - } - - public StrutsLambdaContainerHandler(Class requestTypeClass, - Class responseTypeClass, - RequestReader requestReader, - ResponseWriter responseWriter, - SecurityContextWriter securityContextWriter, - ExceptionHandler exceptionHandler) { - - super(requestTypeClass, responseTypeClass, requestReader, responseWriter, securityContextWriter, exceptionHandler); - Timer.start(TIMER_STRUTS_CONTAINER_CONSTRUCTOR); - this.initialized = false; - Timer.stop(TIMER_STRUTS_CONTAINER_CONSTRUCTOR); - } - - @Override - protected AwsHttpServletResponse getContainerResponse(HttpServletRequest request, CountDownLatch latch) { - return new AwsHttpServletResponse(request, latch); - } - - @Override - protected void handleRequest(HttpServletRequest httpServletRequest, - AwsHttpServletResponse httpServletResponse, - Context lambdaContext) throws Exception { - Timer.start(TIMER_STRUTS_HANDLE_REQUEST); - if (!this.initialized) { - initialize(); - } - - if (AwsHttpServletRequest.class.isAssignableFrom(httpServletRequest.getClass())) { - ((AwsHttpServletRequest)httpServletRequest).setServletContext(this.getServletContext()); - } - this.doFilter(httpServletRequest, httpServletResponse, null); - String responseStatusCode = httpServletResponse.getHeader(HEADER_STRUTS_STATUS_CODE); - if (responseStatusCode != null) { - httpServletResponse.setStatus(Integer.parseInt(responseStatusCode)); - } - Timer.stop(TIMER_STRUTS_HANDLE_REQUEST); - } - - @Override - public void initialize() throws ContainerInitializationException { - log.info("Initialize Struts Lambda Application ..."); - Timer.start(TIMER_STRUTS_COLD_START_INIT); - try { - if (this.startupHandler != null) { - this.startupHandler.onStartup(this.getServletContext()); - } - StrutsPrepareAndExecuteFilter filter = new StrutsPrepareAndExecuteFilter(); - FilterRegistration.Dynamic filterRegistration = this.getServletContext() - .addFilter(STRUTS_FILTER_NAME, filter); - filterRegistration.addMappingForUrlPatterns( - EnumSet.of(DispatcherType.REQUEST, DispatcherType.ASYNC, DispatcherType.INCLUDE, DispatcherType.FORWARD), - true, "/*"); - } catch (Exception e) { - throw new ContainerInitializationException("Could not initialize Struts container", e); - } - - this.initialized = true; - Timer.stop(TIMER_STRUTS_COLD_START_INIT); - log.info("... initialize of Struts Lambda Application completed!"); - } - - public Servlet getServlet() { - return null; - } -} diff --git a/aws-serverless-java-container-struts/src/main/java/com/amazonaws/serverless/proxy/struts/StrutsLambdaHandler.java b/aws-serverless-java-container-struts/src/main/java/com/amazonaws/serverless/proxy/struts/StrutsLambdaHandler.java deleted file mode 100644 index 0e1ccfa17..000000000 --- a/aws-serverless-java-container-struts/src/main/java/com/amazonaws/serverless/proxy/struts/StrutsLambdaHandler.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ -package com.amazonaws.serverless.proxy.struts; - -import com.amazonaws.serverless.proxy.model.AwsProxyRequest; -import com.amazonaws.serverless.proxy.model.AwsProxyResponse; -import com.amazonaws.services.lambda.runtime.Context; -import com.amazonaws.services.lambda.runtime.RequestStreamHandler; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -/** - * The lambda handler to handle the requests. - *

- * - * com.amazonaws.serverless.proxy.struts.StrutsLambdaHandler::handleRequest - * - */ -public class StrutsLambdaHandler implements RequestStreamHandler { - - private final StrutsLambdaContainerHandler handler = StrutsLambdaContainerHandler - .getAwsProxyHandler(); - - @Override - public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context) - throws IOException { - handler.proxyStream(inputStream, outputStream, context); - } -} diff --git a/aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts/StrutsAwsProxyTest.java b/aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts/StrutsAwsProxyTest.java deleted file mode 100644 index 6d7e2a37f..000000000 --- a/aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts/StrutsAwsProxyTest.java +++ /dev/null @@ -1,378 +0,0 @@ -/* - * Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ -package com.amazonaws.serverless.proxy.struts; - - -import com.amazonaws.serverless.proxy.internal.testutils.AwsProxyRequestBuilder; -import com.amazonaws.serverless.proxy.internal.testutils.MockLambdaContext; -import com.amazonaws.serverless.proxy.model.AwsProxyRequest; -import com.amazonaws.serverless.proxy.model.AwsProxyResponse; -import com.amazonaws.serverless.proxy.model.HttpApiV2ProxyRequest; -import com.amazonaws.serverless.proxy.struts.echoapp.EchoAction; -import com.amazonaws.services.lambda.runtime.Context; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.commons.codec.binary.Base64; -import org.apache.struts2.junit.StrutsRestTestCase; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.MethodSource; - -import jakarta.ws.rs.core.Response; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; -import static org.junit.jupiter.api.Assumptions.assumeTrue; - -/** - * Unit test class for the Struts2 AWS_PROXY default implementation - */ -public class StrutsAwsProxyTest extends StrutsRestTestCase { - private static final String CUSTOM_HEADER_KEY = "x-custom-header"; - private static final String CUSTOM_HEADER_VALUE = "my-custom-value"; - private static final String AUTHORIZER_PRINCIPAL_ID = "test-principal-" + UUID.randomUUID().toString(); - private static final String HTTP_METHOD_GET = "GET"; - private static final String QUERY_STRING_MODE = "mode"; - private static final String QUERY_STRING_KEY = "message"; - private static final String QUERY_STRING_ENCODED_VALUE = "Hello Struts2"; - private static final String USER_PRINCIPAL = "user1"; - private static final String CONTENT_TYPE_APPLICATION_JSON = "application/json; charset=UTF-8"; - - - private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); - private final StrutsLambdaContainerHandler handler = StrutsLambdaContainerHandler - .getAwsProxyHandler(); - private final StrutsLambdaContainerHandler httpApiHandler = StrutsLambdaContainerHandler - .getHttpApiV2ProxyHandler(); - private final Context lambdaContext = new MockLambdaContext(); - private String type; - - public void initStrutsAwsProxyTest(String reqType) { - type = reqType; - } - - public static Collection data() { - return Arrays.asList(new Object[]{"API_GW", "ALB", "HTTP_API"}); - } - - private AwsProxyResponse executeRequest(AwsProxyRequestBuilder requestBuilder, Context lambdaContext) { - switch (type) { - case "API_GW": - return handler.proxy(requestBuilder.build(), lambdaContext); - case "ALB": - return handler.proxy(requestBuilder.alb().build(), lambdaContext); - case "HTTP_API": - return httpApiHandler.proxy(requestBuilder.toHttpApiV2Request(), lambdaContext); - default: - throw new RuntimeException("Unknown request type: " + type); - } - } - - @MethodSource("data") - @ParameterizedTest - void headers_getHeaders_echo(String reqType) { - initStrutsAwsProxyTest(reqType); - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo-request-info", HTTP_METHOD_GET) - .queryString(QUERY_STRING_MODE, "headers") - .header(CUSTOM_HEADER_KEY, CUSTOM_HEADER_VALUE) - .json(); - - AwsProxyResponse output = executeRequest(request, lambdaContext); - assertEquals(200, output.getStatusCode()); - assertEquals(CONTENT_TYPE_APPLICATION_JSON, output.getMultiValueHeaders().getFirst("Content-Type")); - - validateMapResponseModel(output); - } - - @MethodSource("data") - @ParameterizedTest - void context_servletResponse_setCustomHeader(String reqType) { - initStrutsAwsProxyTest(reqType); - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo", HTTP_METHOD_GET) - .queryString("customHeader", "true") - .json(); - - AwsProxyResponse output = executeRequest(request, lambdaContext); - assertEquals(200, output.getStatusCode()); - assertTrue(output.getMultiValueHeaders().containsKey("XX")); - } - - @MethodSource("data") - @ParameterizedTest - void context_serverInfo_correctContext(String reqType) { - initStrutsAwsProxyTest(reqType); - assumeTrue("API_GW".equals(type)); - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo", HTTP_METHOD_GET) - .queryString(QUERY_STRING_KEY, "Hello Struts2") - .header("Content-Type", "application/json") - .queryString("contentType", "true"); - AwsProxyResponse output = executeRequest(request, lambdaContext); - assertEquals(200, output.getStatusCode()); - assertEquals(CONTENT_TYPE_APPLICATION_JSON, output.getMultiValueHeaders().getFirst("Content-Type")); - - validateSingleValueModel(output, "Hello Struts2"); - } - - @MethodSource("data") - @ParameterizedTest - void queryString_uriInfo_echo(String reqType) { - initStrutsAwsProxyTest(reqType); - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo-request-info", HTTP_METHOD_GET) - .queryString(QUERY_STRING_MODE, "query-string") - .queryString(CUSTOM_HEADER_KEY, CUSTOM_HEADER_VALUE) - .json(); - - - AwsProxyResponse output = executeRequest(request, lambdaContext); - assertEquals(200, output.getStatusCode()); - assertEquals(CONTENT_TYPE_APPLICATION_JSON, output.getMultiValueHeaders().getFirst("Content-Type")); - - validateMapResponseModel(output); - } - - @MethodSource("data") - @ParameterizedTest - void requestScheme_valid_expectHttps(String reqType) { - initStrutsAwsProxyTest(reqType); - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo-request-info", HTTP_METHOD_GET) - .queryString(QUERY_STRING_MODE, "scheme") - .queryString(QUERY_STRING_KEY, QUERY_STRING_ENCODED_VALUE) - .json(); - - AwsProxyResponse output = executeRequest(request, lambdaContext); - assertEquals(200, output.getStatusCode()); - assertEquals(CONTENT_TYPE_APPLICATION_JSON, output.getMultiValueHeaders().getFirst("Content-Type")); - - validateSingleValueModel(output, "https"); - } - - @MethodSource("data") - @ParameterizedTest - void authorizer_securityContext_customPrincipalSuccess(String reqType) { - initStrutsAwsProxyTest(reqType); - assumeTrue("API_GW".equals(type)); - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo-request-info", HTTP_METHOD_GET) - .queryString(QUERY_STRING_MODE, "principal") - .json() - .authorizerPrincipal(AUTHORIZER_PRINCIPAL_ID); - - AwsProxyResponse output = executeRequest(request, lambdaContext); - assertEquals(200, output.getStatusCode()); - assertEquals(CONTENT_TYPE_APPLICATION_JSON, output.getMultiValueHeaders().getFirst("Content-Type")); - - validateSingleValueModel(output, AUTHORIZER_PRINCIPAL_ID); - } - - @MethodSource("data") - @ParameterizedTest - void errors_unknownRoute_expect404(String reqType) { - initStrutsAwsProxyTest(reqType); - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/unknown", HTTP_METHOD_GET); - - AwsProxyResponse output = executeRequest(request, lambdaContext); - assertEquals(404, output.getStatusCode()); - } - - @MethodSource("data") - @ParameterizedTest - void error_contentType_invalidContentType(String reqType) { - initStrutsAwsProxyTest(reqType); - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo-request-info", "POST") - .queryString(QUERY_STRING_MODE, "content-type") - .header("Content-Type", "application/octet-stream") - .body("asdasdasd"); - - AwsProxyResponse output = executeRequest(request, lambdaContext); - assertEquals(415, output.getStatusCode()); - } - - @MethodSource("data") - @ParameterizedTest - void error_statusCode_methodNotAllowed(String reqType) { - initStrutsAwsProxyTest(reqType); - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo-request-info", "POST") - .queryString(QUERY_STRING_MODE, "not-allowed") - .json(); - - AwsProxyResponse output = executeRequest(request, lambdaContext); - assertEquals(405, output.getStatusCode()); - } - - - @MethodSource("data") - @ParameterizedTest - void responseBody_responseWriter_validBody(String reqType) throws JsonProcessingException { - initStrutsAwsProxyTest(reqType); - Map value = new HashMap<>(); - value.put(QUERY_STRING_KEY, CUSTOM_HEADER_VALUE); - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo", "POST") - .json() - .body(OBJECT_MAPPER.writeValueAsString(value)); - - AwsProxyResponse output = executeRequest(request, lambdaContext); - assertEquals(200, output.getStatusCode()); - assertNotNull(output.getBody()); - - validateSingleValueModel(output, "{\"message\":\"my-custom-value\"}"); - } - - @MethodSource("data") - @ParameterizedTest - void statusCode_responseStatusCode_customStatusCode(String reqType) { - initStrutsAwsProxyTest(reqType); - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo-request-info", HTTP_METHOD_GET) - .queryString(QUERY_STRING_MODE, "custom-status-code") - .queryString("status", "201") - .json(); - - AwsProxyResponse output = executeRequest(request, lambdaContext); - assertEquals(201, output.getStatusCode()); - } - - @MethodSource("data") - @ParameterizedTest - void base64_binaryResponse_base64Encoding(String reqType) { - initStrutsAwsProxyTest(reqType); - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo", HTTP_METHOD_GET); - - AwsProxyResponse response = executeRequest(request, lambdaContext); - assertNotNull(response.getBody()); - assertTrue(Base64.isBase64(response.getBody())); - } - - @MethodSource("data") - @ParameterizedTest - void exception_mapException_mapToNotImplemented(String reqType) { - initStrutsAwsProxyTest(reqType); - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo-request-info", "POST") - .queryString(QUERY_STRING_MODE, "not-implemented"); - - AwsProxyResponse response = executeRequest(request, lambdaContext); - assertNotNull(response.getBody()); - assertEquals("null", response.getBody()); - assertEquals(Response.Status.NOT_IMPLEMENTED.getStatusCode(), response.getStatusCode()); - } - - @MethodSource("data") - @ParameterizedTest - void stripBasePath_route_shouldRouteCorrectly(String reqType) { - initStrutsAwsProxyTest(reqType); - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/custompath/echo", HTTP_METHOD_GET) - .json() - .queryString(QUERY_STRING_KEY, "stripped"); - handler.stripBasePath("/custompath"); - AwsProxyResponse output = executeRequest(request, lambdaContext); - assertEquals(200, output.getStatusCode()); - validateSingleValueModel(output, "stripped"); - handler.stripBasePath(""); - } - - @MethodSource("data") - @ParameterizedTest - void stripBasePath_route_shouldReturn404(String reqType) { - initStrutsAwsProxyTest(reqType); - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/custompath/echo/status-code", HTTP_METHOD_GET) - .json() - .queryString("status", "201"); - handler.stripBasePath("/custom"); - AwsProxyResponse output = executeRequest(request, lambdaContext); - assertEquals(404, output.getStatusCode()); - handler.stripBasePath(""); - } - - @MethodSource("data") - @ParameterizedTest - void securityContext_injectPrincipal_expectPrincipalName(String reqType) { - initStrutsAwsProxyTest(reqType); - assumeTrue("API_GW".equals(type)); - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo-request-info", HTTP_METHOD_GET) - .queryString(QUERY_STRING_MODE, "principal") - .authorizerPrincipal(USER_PRINCIPAL); - - AwsProxyResponse resp = executeRequest(request, lambdaContext); - assertEquals(200, resp.getStatusCode()); - validateSingleValueModel(resp, USER_PRINCIPAL); - } - - @MethodSource("data") - @ParameterizedTest - void queryParam_encoding_expectUnencodedParam(String reqType) { - initStrutsAwsProxyTest(reqType); - assumeTrue("API_GW".equals(type)); - String paramValue = "p%2Fz%2B3"; - String decodedParam = ""; - try { - decodedParam = URLDecoder.decode(paramValue, "UTF-8"); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - fail("Could not decode parameter"); - } - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo", HTTP_METHOD_GET).queryString(QUERY_STRING_KEY, decodedParam); - - AwsProxyResponse resp = executeRequest(request, lambdaContext); - assertEquals(200, resp.getStatusCode()); - validateSingleValueModel(resp, decodedParam); - } - - @MethodSource("data") - @ParameterizedTest - void queryParam_encoding_expectEncodedParam(String reqType) { - initStrutsAwsProxyTest(reqType); - assumeTrue("API_GW".equals(type)); - String paramValue = "p%2Fz%2B3"; - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo", HTTP_METHOD_GET).queryString(QUERY_STRING_KEY, paramValue); - - AwsProxyResponse resp = executeRequest(request, lambdaContext); - assertEquals(200, resp.getStatusCode()); - validateSingleValueModel(resp, paramValue); - } - - - private void validateMapResponseModel(AwsProxyResponse output) { - validateMapResponseModel(output, CUSTOM_HEADER_KEY, CUSTOM_HEADER_VALUE); - } - - private void validateMapResponseModel(AwsProxyResponse output, String key, String value) { - try { - TypeReference> typeRef - = new TypeReference>() { - }; - HashMap response = OBJECT_MAPPER.readValue(output.getBody(), typeRef); - assertNotNull(response.get(key)); - assertEquals(value, response.get(key)); - } catch (IOException e) { - e.printStackTrace(); - fail("Exception while parsing response body: " + e.getMessage()); - } - } - - private void validateSingleValueModel(AwsProxyResponse output, String value) { - try { - assertNotNull(output.getBody()); - assertEquals(value, OBJECT_MAPPER.readerFor(String.class).readValue(output.getBody())); - } catch (Exception e) { - e.printStackTrace(); - fail("Exception while parsing response body: " + e.getMessage()); - } - } -} diff --git a/aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts/echoapp/EchoAction.java b/aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts/echoapp/EchoAction.java deleted file mode 100644 index ad6c63180..000000000 --- a/aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts/echoapp/EchoAction.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.amazonaws.serverless.proxy.struts.echoapp; - -import com.opensymphony.xwork2.ActionSupport; -import org.apache.commons.io.IOUtils; -import org.apache.struts2.ServletActionContext; - -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import java.io.IOException; - - -public class EchoAction extends ActionSupport { - - private String message; - - public String execute() throws IOException { - HttpServletRequest request = ServletActionContext.getRequest(); - - if (message == null && requestHasBody(request)) { - message = IOUtils.toString(request.getReader()); - } - - return SUCCESS; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public void setCustomHeader(boolean customHeader) { - if (customHeader) { - HttpServletResponse response = ServletActionContext.getResponse(); - response.setHeader("XX", "FOO"); - } - } - - - public void setContentType(boolean contentType) { - if (contentType) { - HttpServletResponse response = ServletActionContext.getResponse(); - response.setContentType("application/json"); - } - } - - private boolean requestHasBody(HttpServletRequest request) throws IOException { - return ("POST".equalsIgnoreCase(request.getMethod()) || "PUT".equalsIgnoreCase(request.getMethod())) && request.getReader() != null; - } - -} diff --git a/aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts/echoapp/EchoRequestInfoAction.java b/aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts/echoapp/EchoRequestInfoAction.java deleted file mode 100644 index e810f3197..000000000 --- a/aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts/echoapp/EchoRequestInfoAction.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.amazonaws.serverless.proxy.struts.echoapp; - -import com.amazonaws.serverless.proxy.RequestReader; -import com.amazonaws.serverless.proxy.model.AwsProxyRequestContext; -import com.opensymphony.xwork2.ActionSupport; -import org.apache.struts2.ServletActionContext; - -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; - - -public class EchoRequestInfoAction extends ActionSupport { - - private String mode = "principal"; - private Object result = null; - - public String execute() { - - HttpServletRequest request = ServletActionContext.getRequest(); - AwsProxyRequestContext awsProxyRequestContext = - (AwsProxyRequestContext) request - .getAttribute(RequestReader.API_GATEWAY_CONTEXT_PROPERTY); - - switch (mode) { - case "principal": - result = awsProxyRequestContext.getAuthorizer().getPrincipalId(); - break; - case "scheme": - result = request.getScheme(); - break; - case "content-type": - if (request.getContentType().contains("application/octet-stream")) { - ServletActionContext.getResponse().setStatus(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE); - } - result = request.getContentType(); - break; - case "not-allowed": - ServletActionContext.getResponse().setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED); - break; - case "custom-status-code": - ServletActionContext.getResponse().setStatus(HttpServletResponse.SC_CREATED); - break; - case "not-implemented": - ServletActionContext.getResponse().setStatus(HttpServletResponse.SC_NOT_IMPLEMENTED); - break; - case "headers": - Map headers = new HashMap<>(); - - Enumeration headerNames = request.getHeaderNames(); - while (headerNames.hasMoreElements()) { - String headerName = headerNames.nextElement(); - headers.put(headerName, request.getHeader(headerName)); - } - - result = headers; - break; - case "query-string": - Map params = new HashMap<>(); - - Enumeration parameterNames = request.getParameterNames(); - while (parameterNames.hasMoreElements()) { - String parameterName = parameterNames.nextElement(); - params.put(parameterName, request.getParameter(parameterName)); - } - - result = params; - break; - default: - throw new IllegalArgumentException("Invalid mode requested: " + mode); - } - - return SUCCESS; - } - - public Object getResult() { - return result; - } - - public void setMode(String mode) { - this.mode = mode; - } -} diff --git a/aws-serverless-java-container-struts/src/test/resources/log4j2.xml b/aws-serverless-java-container-struts/src/test/resources/log4j2.xml deleted file mode 100644 index 55ed0d21c..000000000 --- a/aws-serverless-java-container-struts/src/test/resources/log4j2.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - %d{yyyy-MM-dd HH:mm:ss} %X{AWSRequestId} %-5p %c{1}:%L - %m%n - - - - - - - - - - - \ No newline at end of file diff --git a/aws-serverless-java-container-struts/src/test/resources/struts.xml b/aws-serverless-java-container-struts/src/test/resources/struts.xml deleted file mode 100644 index 92070be83..000000000 --- a/aws-serverless-java-container-struts/src/test/resources/struts.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - message - - - - - - - - result - - - - - - - \ No newline at end of file diff --git a/aws-serverless-struts-archetype/pom.xml b/aws-serverless-struts-archetype/pom.xml deleted file mode 100644 index 9d6cda35c..000000000 --- a/aws-serverless-struts-archetype/pom.xml +++ /dev/null @@ -1,80 +0,0 @@ - - 4.0.0 - - - com.amazonaws.serverless - aws-serverless-java-container - 2.1.0-SNAPSHOT - - - com.amazonaws.serverless.archetypes - aws-serverless-struts-archetype - 2.1.0-SNAPSHOT - maven-archetype - - - https://github.com/aws/serverless-java-container.git - HEAD - - - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - - - - src/main/resources - true - - archetype-resources/pom.xml - archetype-resources/README.md - - - - src/main/resources - false - - archetype-resources/pom.xml - - - - - - - org.apache.maven.archetype - archetype-packaging - 3.0.1 - - - - - - - org.apache.maven.plugins - maven-resources-plugin - 3.3.1 - - \ - - - - org.apache.maven.plugins - maven-archetype-plugin - 3.0.1 - - - - integration-test - - - - - - - - diff --git a/aws-serverless-struts-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/aws-serverless-struts-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml deleted file mode 100644 index ad8b86248..000000000 --- a/aws-serverless-struts-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - src/main/java - - **/*.java - - - - src/test/java - - **/*.java - - - - src/main/resources - - **/*.properties - **/*.xml - - - - src/main/assembly - - **/*.xml - - - - - - template.yml - README.md - build.gradle - - - - \ No newline at end of file diff --git a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/README.md b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/README.md deleted file mode 100644 index 311c40aee..000000000 --- a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/README.md +++ /dev/null @@ -1,99 +0,0 @@ -#set($resourceName = $artifactId) -#macro(replaceChar $originalName, $char) - #if($originalName.contains($char)) - #set($tokens = $originalName.split($char)) - #set($newResourceName = "") - #foreach($token in $tokens) - #set($newResourceName = $newResourceName + $token.substring(0,1).toUpperCase() + $token.substring(1).toLowerCase()) - #end - ${newResourceName} - #else - #set($newResourceName = $originalName.substring(0,1).toUpperCase() + $originalName.substring(1)) - ${newResourceName} - #end -#end -#set($resourceName = "#replaceChar($resourceName, '-')") -#set($resourceName = "#replaceChar($resourceName, '.')") -#set($resourceName = $resourceName.replaceAll("\n", "").trim()) -# \${artifactId} serverless API -The \${artifactId} project, created with [`aws-serverless-java-container`](https://github.com/aws/serverless-java-container). - -The starter project defines a simple `/ping` resource that can accept `GET` requests with its tests. - -The project folder also includes a `template.yml` file. You can use this [SAM](https://github.com/awslabs/serverless-application-model) file to deploy the project to AWS Lambda and Amazon API Gateway or test in local with the [SAM CLI](https://github.com/awslabs/aws-sam-cli). - -#[[##]]# Pre-requisites -* [AWS CLI](https://aws.amazon.com/cli/) -* [SAM CLI](https://github.com/awslabs/aws-sam-cli) -* [Gradle](https://gradle.org/) or [Maven](https://maven.apache.org/) - -#[[##]]# Building the project -You can use the SAM CLI to quickly build the project -```bash -$ mvn archetype:generate -DartifactId=\${artifactId} -DarchetypeGroupId=com.amazonaws.serverless.archetypes -DarchetypeArtifactId=aws-serverless-jersey-archetype -DarchetypeVersion=${project.version} -DgroupId=\${groupId} -Dversion=\${version} -Dinteractive=false -$ cd \${artifactId} -$ sam build -Building resource '\${resourceName}Function' -Running JavaGradleWorkflow:GradleBuild -Running JavaGradleWorkflow:CopyArtifacts - -Build Succeeded - -Built Artifacts : .aws-sam/build -Built Template : .aws-sam/build/template.yaml - -Commands you can use next -========================= -[*] Invoke Function: sam local invoke -[*] Deploy: sam deploy --guided -``` - -#[[##]]# Testing locally with the SAM CLI - -From the project root folder - where the `template.yml` file is located - start the API with the SAM CLI. - -```bash -$ sam local start-api - -... -Mounting ${groupId}.StreamLambdaHandler::handleRequest (java11) at http://127.0.0.1:3000/{proxy+} [OPTIONS GET HEAD POST PUT DELETE PATCH] -... -``` - -Using a new shell, you can send a test ping request to your API: - -```bash -$ curl -s http://127.0.0.1:3000/ping | python -m json.tool - -{ - "pong": "Hello, World!" -} -``` - -#[[##]]# Deploying to AWS -To deploy the application in your AWS account, you can use the SAM CLI's guided deployment process and follow the instructions on the screen - -``` -$ sam deploy --guided -``` - -Once the deployment is completed, the SAM CLI will print out the stack's outputs, including the new application URL. You can use `curl` or a web browser to make a call to the URL - -``` -... -------------------------------------------------------------------------------------------------------------- -OutputKey-Description OutputValue -------------------------------------------------------------------------------------------------------------- -\${resourceName}Api - URL for application https://xxxxxxxxxx.execute-api.us-west-2.amazonaws.com/Prod/pets -------------------------------------------------------------------------------------------------------------- -``` - -Copy the `OutputValue` into a browser or use curl to test your first request: - -```bash -$ curl -s https://xxxxxxx.execute-api.us-west-2.amazonaws.com/Prod/ping | python -m json.tool - -{ - "pong": "Hello, World!" -} -``` diff --git a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/build.gradle b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/build.gradle deleted file mode 100644 index 4ff9dfc37..000000000 --- a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/build.gradle +++ /dev/null @@ -1,65 +0,0 @@ -apply plugin: 'java' - -repositories { - mavenLocal() - mavenCentral() -} - -configurations { - implementation { - exclude group: 'org.apache.logging.log4j', module: 'log4j-to-slf4j' - } -} - -dependencies { - - implementation ('com.amazonaws.serverless:aws-serverless-java-container-struts:[1.0,)') { - exclude group: 'org.apache.struts', module: 'struts2-core' - exclude group: 'org.apache.logging.log4j', module: 'log4j-api' - exclude group: 'org.apache.logging.log4j', module: 'log4j-to-slf4j' - } - implementation ('org.apache.struts:struts2-convention-plugin:7.0.0-M9') { - exclude group: 'org.apache.struts', module: 'struts2-core' - } - implementation ('org.apache.struts:struts2-rest-plugin:7.0.0-M9') { - exclude group: 'org.apache.struts', module: 'struts2-core' - } - implementation ('org.apache.struts:struts2-bean-validation-plugin:7.0.0-M9') { - exclude group: 'org.apache.struts', module: 'struts2-core' - } - implementation ('com.jgeppert.struts2:struts2-aws-lambda-support-plugin:1.4.3') { - exclude group: 'org.apache.struts', module: 'struts2-core' - } - implementation ('org.apache.struts:struts2-core:7.0.0-M9') { - exclude group: 'org.apache.logging.log4j', module: 'log4j-api' - } - implementation ('org.hibernate.validator:hibernate-validator:6.1.7.Final') - implementation ('com.fasterxml.jackson.core:jackson-databind:2.18.1') - implementation ('com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.18.1') - implementation ('org.apache.logging.log4j:log4j-core:2.24.1') - implementation ('org.apache.logging.log4j:log4j-api:2.24.1') - implementation ('org.apache.logging.log4j:log4j-slf4j-impl:2.24.1') - implementation ('com.amazonaws:aws-lambda-java-log4j2:1.6.0') - - testImplementation("com.amazonaws.serverless:aws-serverless-java-container-core:[2.0-SNAPSHOT,):tests") - testImplementation("org.apache.httpcomponents.client5:httpclient5:5.4.1") - testImplementation(platform("org.junit:junit-bom:5.11.3")) - testImplementation("org.junit.jupiter:junit-jupiter") - testImplementation('org.apache.struts:struts2-junit-plugin:7.0.0-M9') { - exclude group: 'org.apache.struts', module: 'struts2-core' - } -} - -task buildZip(type: Zip) { - from compileJava - from processResources - into('lib') { - from(configurations.compileClasspath) - } -} - -test { - useJUnitPlatform() -} - -build.dependsOn buildZip diff --git a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/pom.xml b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/pom.xml deleted file mode 100644 index f64194a56..000000000 --- a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/pom.xml +++ /dev/null @@ -1,186 +0,0 @@ - - - 4.0.0 - - \${groupId} - \${artifactId} - \${version} - jar - - Serverless Struts API - https://github.com/aws/serverless-java-container - - - 1.8 - 1.8 - 7.0.0-M9 - 2.18.1 - 5.11.3 - 2.24.1 - - - - - com.amazonaws.serverless - aws-serverless-java-container-struts - ${project.version} - - - com.amazonaws.serverless - aws-serverless-java-container-core - ${project.version} - tests - test-jar - test - - - org.apache.httpcomponents.client5 - httpclient5 - 5.4.1 - test - - - - org.apache.struts - struts2-convention-plugin - \${struts.version} - - - - org.apache.struts - struts2-rest-plugin - \${struts.version} - - - - org.apache.struts - struts2-bean-validation-plugin - \${struts.version} - - - - org.apache.struts - struts2-junit-plugin - \${struts.version} - test - - - - - com.jgeppert.struts2 - struts2-aws-lambda-support-plugin - 1.4.3 - - - - - org.hibernate.validator - hibernate-validator - 6.1.7.Final - - - - com.fasterxml.jackson.core - jackson-core - \${jackson.version} - - - com.fasterxml.jackson.core - jackson-annotations - \${jackson.version} - - - com.fasterxml.jackson.core - jackson-databind - \${jackson.version} - - - com.fasterxml.jackson.dataformat - jackson-dataformat-xml - \${jackson.version} - - - - org.apache.logging.log4j - log4j-core - \${log4j.version} - - - - org.apache.logging.log4j - log4j-api - \${log4j.version} - - - - com.amazonaws - aws-lambda-java-log4j2 - 1.6.0 - - - - jakarta.el - jakarta.el-api - 5.0.1 - test - - - org.glassfish - jakarta.el - 5.0.0-M1 - test - - - - org.junit.jupiter - junit-jupiter - test - - - - - - - org.junit - junit-bom - ${junit.version} - import - pom - - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - 3.7.1 - - - src/main/assembly/dist.xml - - - - - lambda - package - - single - - - - - - - - - - apache-pre-release - https://repository.apache.org/content/repositories/staging/ - default - - - diff --git a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/assembly/dist.xml b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/assembly/dist.xml deleted file mode 100644 index 0466b85c5..000000000 --- a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/assembly/dist.xml +++ /dev/null @@ -1,31 +0,0 @@ - - lambda - - zip - - false - - - lib - false - - - - - ${basedir}/src/main/resources - - - * - - - - ${project.build.directory}/classes - - - **/*.class - - - - \ No newline at end of file diff --git a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/java/actions/PingController.java b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/java/actions/PingController.java deleted file mode 100644 index f3763f4de..000000000 --- a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/java/actions/PingController.java +++ /dev/null @@ -1,70 +0,0 @@ -package ${groupId}.actions; - - -import com.opensymphony.xwork2.ModelDriven; -import org.apache.struts2.rest.DefaultHttpHeaders; -import org.apache.struts2.rest.HttpHeaders; -import org.apache.struts2.rest.RestActionSupport; - - -import java.util.Collection; -import java.util.UUID; - - -public class PingController extends RestActionSupport implements ModelDriven { - - private String model = new String(); - private String id; - private Collection list = null; - - - // GET /ping/1 - public HttpHeaders show() { - return new DefaultHttpHeaders("show"); - } - - // GET /ping - public HttpHeaders index() { - this.model = "Hello, World!"; - return new DefaultHttpHeaders("index") - .disableCaching(); - } - - // POST /ping - public HttpHeaders create() { - this.model = UUID.randomUUID().toString(); - return new DefaultHttpHeaders("success") - .setLocationId(model); - - } - - // PUT /ping/1 - public String update() { - //TODO: UPDATE LOGIC - return SUCCESS; - } - - // DELETE /ping/1 - public String destroy() { - //TODO: DELETE LOGIC - return SUCCESS; - } - - public void setId(String id) { - if (id != null) { - this.model = "New model instance"; - } - this.id = id; - } - - public Object getModel() { - if (list != null) { - return list; - } else { - if (model == null) { - model = "Pong"; - } - return model; - } - } -} diff --git a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/resources/application.properties b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/resources/application.properties deleted file mode 100644 index 070e632fe..000000000 --- a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/resources/application.properties +++ /dev/null @@ -1,3 +0,0 @@ -# Reduce logging level to make sure the application works with SAM local -# https://github.com/aws/serverless-java-container/issues/134 -logging.level.root=WARN \ No newline at end of file diff --git a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/resources/log4j2.xml b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/resources/log4j2.xml deleted file mode 100644 index 55ed0d21c..000000000 --- a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/resources/log4j2.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - %d{yyyy-MM-dd HH:mm:ss} %X{AWSRequestId} %-5p %c{1}:%L - %m%n - - - - - - - - - - - \ No newline at end of file diff --git a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/resources/struts.xml b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/resources/struts.xml deleted file mode 100644 index f6975ffd0..000000000 --- a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/resources/struts.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/test/java/StreamLambdaHandlerTest.java b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/test/java/StreamLambdaHandlerTest.java deleted file mode 100644 index 875867778..000000000 --- a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/test/java/StreamLambdaHandlerTest.java +++ /dev/null @@ -1,90 +0,0 @@ -package ${groupId}; - - -import com.amazonaws.serverless.proxy.internal.LambdaContainerHandler; -import com.amazonaws.serverless.proxy.internal.testutils.AwsProxyRequestBuilder; -import com.amazonaws.serverless.proxy.internal.testutils.MockLambdaContext; -import com.amazonaws.serverless.proxy.model.AwsProxyResponse; -import com.amazonaws.services.lambda.runtime.Context; - -import com.amazonaws.serverless.proxy.struts.StrutsLambdaHandler; - -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -import jakarta.ws.rs.HttpMethod; -import jakarta.ws.rs.core.HttpHeaders; -import jakarta.ws.rs.core.MediaType; -import jakarta.ws.rs.core.Response; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; - -import static org.junit.jupiter.api.Assertions.*; - -public class StreamLambdaHandlerTest { - - private static StrutsLambdaHandler handler; - private static Context lambdaContext; - - @BeforeAll - public static void setUp() { - handler = new StrutsLambdaHandler(); - lambdaContext = new MockLambdaContext(); - } - - @Test - public void ping_streamRequest_respondsWithHello() { - InputStream requestStream = new AwsProxyRequestBuilder("/ping", HttpMethod.GET) - .header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON) - .buildStream(); - ByteArrayOutputStream responseStream = new ByteArrayOutputStream(); - - handle(requestStream, responseStream); - - AwsProxyResponse response = readResponse(responseStream); - assertNotNull(response); - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode()); - - assertFalse(response.isBase64Encoded()); - - assertTrue(response.getBody().contains("Hello, World!")); - - assertTrue(response.getMultiValueHeaders().containsKey(HttpHeaders.CONTENT_TYPE)); - assertTrue(response.getMultiValueHeaders().getFirst(HttpHeaders.CONTENT_TYPE).startsWith(MediaType.APPLICATION_JSON)); - } - - @Test - public void invalidResource_streamRequest_responds404() { - InputStream requestStream = new AwsProxyRequestBuilder("/pong", HttpMethod.GET) - .header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON) - .buildStream(); - ByteArrayOutputStream responseStream = new ByteArrayOutputStream(); - - handle(requestStream, responseStream); - - AwsProxyResponse response = readResponse(responseStream); - assertNotNull(response); - assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode()); - } - - private void handle(InputStream is, ByteArrayOutputStream os) { - try { - handler.handleRequest(is, os, lambdaContext); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - private AwsProxyResponse readResponse(ByteArrayOutputStream responseStream) { - try { - return LambdaContainerHandler.getObjectMapper().readValue(responseStream.toByteArray(), AwsProxyResponse.class); - } catch (IOException e) { - e.printStackTrace(); - fail("Error while parsing response: " + e.getMessage()); - } - return null; - } -} diff --git a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/template.yml b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/template.yml deleted file mode 100644 index fe446dedd..000000000 --- a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/template.yml +++ /dev/null @@ -1,52 +0,0 @@ -#set($resourceName = $artifactId) -#macro(replaceChar $originalName, $char) - #if($originalName.contains($char)) - #set($tokens = $originalName.split($char)) - #set($newResourceName = "") - #foreach($token in $tokens) - #set($newResourceName = $newResourceName + $token.substring(0,1).toUpperCase() + $token.substring(1).toLowerCase()) - #end - ${newResourceName} - #else - #set($newResourceName = $originalName.substring(0,1).toUpperCase() + $originalName.substring(1)) - ${newResourceName} - #end -#end -#set($resourceName = "#replaceChar($resourceName, '-')") -#set($resourceName = "#replaceChar($resourceName, '.')") -#set($resourceName = $resourceName.replaceAll("\n", "").trim()) -#macro(regionVar) - AWS::Region -#end -#set($awsRegion = "#regionVar()") -#set($awsRegion = $awsRegion.replaceAll("\n", "").trim()) -AWSTemplateFormatVersion: '2010-09-09' -Transform: AWS::Serverless-2016-10-31 -Description: AWS Serverless Apache Struts API - ${groupId}::${artifactId} -Globals: - Api: - EndpointConfiguration: REGIONAL - -Resources: - ${resourceName}Function: - Type: AWS::Serverless::Function - Properties: - Handler: com.amazonaws.serverless.proxy.struts.StrutsLambdaHandler::handleRequest - Runtime: java11 - CodeUri: . - MemorySize: 512 - Policies: AWSLambdaBasicExecutionRole - Timeout: 30 - Events: - ProxyResource: - Type: Api - Properties: - Path: /{proxy+} - Method: any - -Outputs: - ${resourceName}Api: - Description: URL for application - Value: !Sub 'https://${ServerlessRestApi}.execute-api.${${awsRegion}}.amazonaws.com/Prod/ping' - Export: - Name: ${resourceName}Api diff --git a/aws-serverless-struts-archetype/src/test/resources/projects/base/archetype.properties b/aws-serverless-struts-archetype/src/test/resources/projects/base/archetype.properties deleted file mode 100644 index 80acd0f43..000000000 --- a/aws-serverless-struts-archetype/src/test/resources/projects/base/archetype.properties +++ /dev/null @@ -1,3 +0,0 @@ -groupId=test.service -artifactId=struts-archetype-test -version=1.0-SNAPSHOT diff --git a/aws-serverless-struts-archetype/src/test/resources/projects/base/goal.txt b/aws-serverless-struts-archetype/src/test/resources/projects/base/goal.txt deleted file mode 100644 index 597acc768..000000000 --- a/aws-serverless-struts-archetype/src/test/resources/projects/base/goal.txt +++ /dev/null @@ -1 +0,0 @@ -package \ No newline at end of file diff --git a/samples/struts/pet-store/README.md b/samples/struts/pet-store/README.md deleted file mode 100644 index bc5c047ae..000000000 --- a/samples/struts/pet-store/README.md +++ /dev/null @@ -1,56 +0,0 @@ -# Serverless Struts example -A basic pet store written with the [Apache Struts framework](https://struts.apache.org). The `StrutsLambdaHandler` object provided by the `aws-serverless-java-container-struts` is the main entry point for Lambda. - -The application can be deployed in an AWS account using the [Serverless Application Model](https://github.com/awslabs/serverless-application-model). The `template.yml` file in the root folder contains the application definition - -## Pre-requisites -* [AWS CLI](https://aws.amazon.com/cli/) -* [SAM CLI](https://github.com/awslabs/aws-sam-cli) -* [Gradle](https://gradle.org/) or [Maven](https://maven.apache.org/) - - -## Deployment -In a shell, navigate to the sample's folder and use the SAM CLI to build a deployable package -``` -$ mvn package && sam build -``` - -### Test Local - -``` -$ sam local invoke -e test-event.json -``` - -### Deploy Sample Application - -This command compiles the application and prepares a deployment package in the `.aws-sam` sub-directory. - -To deploy the application in your AWS account, you can use the SAM CLI's guided deployment process and follow the instructions on the screen - -``` -$ sam deploy --guided -``` - -Once the deployment is completed, the SAM CLI will print out the stack's outputs, including the new application URL. You can use `curl` or a web browser to make a call to the URL - -``` -... ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -Outputs ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -Key StrutsPetStoreApi -Description URL for application -Value https://xxxxxxxxxx.execute-api..amazonaws.com/pets ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -``` -## Test - -### JSON Request: -``` -$ curl https://xxxxxxxxxx.execute-api..amazonaws.com/pets.json -``` - -### XML Request -``` -$ curl https://xxxxxxxxxx.execute-api..amazonaws.com/pets.xml -``` \ No newline at end of file diff --git a/samples/struts/pet-store/build.gradle b/samples/struts/pet-store/build.gradle deleted file mode 100644 index ecc765cb7..000000000 --- a/samples/struts/pet-store/build.gradle +++ /dev/null @@ -1,41 +0,0 @@ -apply plugin: 'java' - -repositories { - mavenLocal() - mavenCentral() -} - -configurations { - implementation { - exclude group: 'org.apache.logging.log4j', module: 'log4j-to-slf4j' - } -} - -dependencies { - implementation ( - 'com.amazonaws.serverless:aws-serverless-java-container-struts:[2.0-SNAPSHOT,)', - 'org.apache.struts:struts2-convention-plugin:7.0.0-M9', - 'org.apache.struts:struts2-rest-plugin:7.0.0-M9', - 'org.apache.struts:struts2-bean-validation-plugin:7.0.0-M9', - 'org.apache.struts:struts2-junit-plugin:7.0.0-M9', - 'com.jgeppert.struts2:struts2-aws-lambda-support-plugin:1.4.3', - 'org.hibernate.validator:hibernate-validator:6.1.7.Final', - 'org.glassfish:jakarta.el:5.0.0-M1', - 'jakarta.el:jakarta.el-api:5.0.1', - 'com.fasterxml.jackson.core:jackson-databind:2.18.1', - 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.18.1', - 'org.apache.logging.log4j:log4j-core:2.24.1', - 'org.apache.logging.log4j:log4j-api:2.24.1', - 'com.amazonaws:aws-lambda-java-log4j2:1.6.0', - ) -} - -task buildZip(type: Zip) { - from compileJava - from processResources - into('lib') { - from(configurations.compileClasspath) - } -} - -build.dependsOn buildZip diff --git a/samples/struts/pet-store/pom.xml b/samples/struts/pet-store/pom.xml deleted file mode 100644 index 49c035d4e..000000000 --- a/samples/struts/pet-store/pom.xml +++ /dev/null @@ -1,177 +0,0 @@ - - - 4.0.0 - - com.amazonaws.serverless.sample - serverless-struts-example - 2.0-SNAPSHOT - Struts example for the aws-serverless-java-container library - Simple pet store written with the Apache Struts framework - https://aws.amazon.com/lambda/ - - - https://github.com/aws/serverless-java-container.git - - - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - - 1.8 - 1.8 - 7.0.0-M9 - 2.18.1 - 4.13.2 - 2.24.1 - - - - - com.amazonaws.serverless - aws-serverless-java-container-struts - [2.0.0-SNAPSHOT,) - - - - org.apache.struts - struts2-convention-plugin - ${struts.version} - - - - org.apache.struts - struts2-rest-plugin - ${struts.version} - - - - org.apache.struts - struts2-bean-validation-plugin - ${struts.version} - - - - org.apache.struts - struts2-junit-plugin - ${struts.version} - test - - - - - com.jgeppert.struts2 - struts2-aws-lambda-support-plugin - 1.4.3 - - - - - org.hibernate.validator - hibernate-validator - 6.1.7.Final - - - org.glassfish - jakarta.el - 5.0.0-M1 - - - jakarta.el - jakarta.el-api - 5.0.1 - - - - com.fasterxml.jackson.core - jackson-core - ${jackson.version} - - - com.fasterxml.jackson.core - jackson-annotations - ${jackson.version} - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - com.fasterxml.jackson.dataformat - jackson-dataformat-xml - ${jackson.version} - - - - org.apache.logging.log4j - log4j-core - ${log4j.version} - - - - org.apache.logging.log4j - log4j-api - ${log4j.version} - - - - com.amazonaws - aws-lambda-java-log4j2 - 1.6.0 - - - - junit - junit - ${junit.version} - test - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.8 - 1.8 - - - - org.apache.maven.plugins - maven-assembly-plugin - 3.7.1 - - - src/main/assembly/dist.xml - - - - - lambda - package - - single - - - - - - - - - - apache-pre-release - https://repository.apache.org/content/repositories/staging/ - default - - - diff --git a/samples/struts/pet-store/src/main/assembly/dist.xml b/samples/struts/pet-store/src/main/assembly/dist.xml deleted file mode 100644 index 029ec01c7..000000000 --- a/samples/struts/pet-store/src/main/assembly/dist.xml +++ /dev/null @@ -1,31 +0,0 @@ - - lambda - - zip - - false - - - lib - false - - - - - ${basedir}/src/main/resources - / - - * - - - - ${project.build.directory}/classes - / - - **/*.class - - - - \ No newline at end of file diff --git a/samples/struts/pet-store/src/main/java/com/amazonaws/serverless/sample/struts/actions/PetsController.java b/samples/struts/pet-store/src/main/java/com/amazonaws/serverless/sample/struts/actions/PetsController.java deleted file mode 100644 index bc2ad8bbe..000000000 --- a/samples/struts/pet-store/src/main/java/com/amazonaws/serverless/sample/struts/actions/PetsController.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ -package com.amazonaws.serverless.sample.struts.actions; - -import com.amazonaws.serverless.sample.struts.model.Pet; -import com.amazonaws.serverless.sample.struts.model.PetData; -import com.opensymphony.xwork2.ModelDriven; -import org.apache.struts2.rest.DefaultHttpHeaders; -import org.apache.struts2.rest.HttpHeaders; -import org.apache.struts2.rest.RestActionSupport; - -import java.util.Collection; -import java.util.UUID; -import java.util.stream.Collectors; - - -public class PetsController extends RestActionSupport implements ModelDriven { - - private Pet model = new Pet(); - private String id; - private Collection list = null; - - // GET /pets/1 - public HttpHeaders show() { - return new DefaultHttpHeaders("show"); - } - - // GET /pets - public HttpHeaders index() { - list = PetData.getNames() - .stream() - .map(petName -> new Pet( - UUID.randomUUID() - .toString(), PetData.getRandomBreed(), petName, PetData.getRandomDoB())) - .collect(Collectors.toList()); - return new DefaultHttpHeaders("index") - .disableCaching(); - } - - // POST /pets - public HttpHeaders create() { - if (model.getName() == null || model.getBreed() == null) { - return null; - } - - Pet dbPet = model; - dbPet.setId(UUID.randomUUID().toString()); - return new DefaultHttpHeaders("success") - .setLocationId(model.getId()); - - } - - // PUT /pets/1 - public String update() { - //TODO: UPDATE LOGIC - return SUCCESS; - } - - // DELETE /petsr/1 - public String destroy() { - //TODO: DELETE LOGIC - return SUCCESS; - } - - public void setId(String id) { - if (id != null) { - this.model = new Pet(id, PetData.getRandomBreed(), PetData.getRandomName(), PetData.getRandomDoB()); - } - this.id = id; - } - - public Object getModel() { - if (list != null) { - return list; - } else { - if (model == null) { - model = new Pet(); - } - return model; - } - } -} diff --git a/samples/struts/pet-store/src/main/java/com/amazonaws/serverless/sample/struts/model/Pet.java b/samples/struts/pet-store/src/main/java/com/amazonaws/serverless/sample/struts/model/Pet.java deleted file mode 100644 index c9d420ca8..000000000 --- a/samples/struts/pet-store/src/main/java/com/amazonaws/serverless/sample/struts/model/Pet.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ -package com.amazonaws.serverless.sample.struts.model; - -import org.hibernate.validator.constraints.NotBlank; - -import java.util.Date; - -public class Pet { - - private String id; - private String breed; - - @NotBlank - private String name; - private Date dateOfBirth; - - public Pet() { - } - - public Pet(String id, String breed, String name, Date dateOfBirth) { - this.id = id; - this.breed = breed; - this.name = name; - this.dateOfBirth = dateOfBirth; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getBreed() { - return breed; - } - - public void setBreed(String breed) { - this.breed = breed; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Date getDateOfBirth() { - return dateOfBirth; - } - - public void setDateOfBirth(Date dateOfBirth) { - this.dateOfBirth = dateOfBirth; - } -} diff --git a/samples/struts/pet-store/src/main/java/com/amazonaws/serverless/sample/struts/model/PetData.java b/samples/struts/pet-store/src/main/java/com/amazonaws/serverless/sample/struts/model/PetData.java deleted file mode 100644 index 84be64eab..000000000 --- a/samples/struts/pet-store/src/main/java/com/amazonaws/serverless/sample/struts/model/PetData.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ -package com.amazonaws.serverless.sample.struts.model; - -import java.util.*; -import java.util.concurrent.ThreadLocalRandom; - -public class PetData { - private static List breeds = new ArrayList<>(); - static { - breeds.add("Afghan Hound"); - breeds.add("Beagle"); - breeds.add("Bernese Mountain Dog"); - breeds.add("Bloodhound"); - breeds.add("Dalmatian"); - breeds.add("Jack Russell Terrier"); - breeds.add("Norwegian Elkhound"); - } - - private static List names = new ArrayList<>(); - static { - names.add("Bailey"); - names.add("Bella"); - names.add("Max"); - names.add("Lucy"); - names.add("Charlie"); - names.add("Molly"); - names.add("Buddy"); - names.add("Daisy"); - names.add("Rocky"); - names.add("Maggie"); - names.add("Jake"); - names.add("Sophie"); - names.add("Jack"); - names.add("Sadie"); - names.add("Toby"); - names.add("Chloe"); - names.add("Cody"); - names.add("Bailey"); - names.add("Buster"); - names.add("Lola"); - names.add("Duke"); - names.add("Zoe"); - names.add("Cooper"); - names.add("Abby"); - names.add("Riley"); - names.add("Ginger"); - names.add("Harley"); - names.add("Roxy"); - names.add("Bear"); - names.add("Gracie"); - names.add("Tucker"); - names.add("Coco"); - names.add("Murphy"); - names.add("Sasha"); - names.add("Lucky"); - names.add("Lily"); - names.add("Oliver"); - names.add("Angel"); - names.add("Sam"); - names.add("Princess"); - names.add("Oscar"); - names.add("Emma"); - names.add("Teddy"); - names.add("Annie"); - names.add("Winston"); - names.add("Rosie"); - } - - public static List getBreeds() { - return breeds; - } - - public static List getNames() { - return names; - } - - public static String getRandomBreed() { - return breeds.get(ThreadLocalRandom.current().nextInt(0, breeds.size() - 1)); - } - - public static String getRandomName() { - return names.get(ThreadLocalRandom.current().nextInt(0, names.size() - 1)); - } - - public static Date getRandomDoB() { - GregorianCalendar gc = new GregorianCalendar(); - - int year = ThreadLocalRandom.current().nextInt( - Calendar.getInstance().get(Calendar.YEAR) - 15, - Calendar.getInstance().get(Calendar.YEAR) - ); - - gc.set(Calendar.YEAR, year); - - int dayOfYear = ThreadLocalRandom.current().nextInt(1, gc.getActualMaximum(Calendar.DAY_OF_YEAR)); - - gc.set(Calendar.DAY_OF_YEAR, dayOfYear); - return gc.getTime(); - } -} diff --git a/samples/struts/pet-store/src/main/resources/log4j2.xml b/samples/struts/pet-store/src/main/resources/log4j2.xml deleted file mode 100644 index 55ed0d21c..000000000 --- a/samples/struts/pet-store/src/main/resources/log4j2.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - %d{yyyy-MM-dd HH:mm:ss} %X{AWSRequestId} %-5p %c{1}:%L - %m%n - - - - - - - - - - - \ No newline at end of file diff --git a/samples/struts/pet-store/src/main/resources/struts.xml b/samples/struts/pet-store/src/main/resources/struts.xml deleted file mode 100644 index 3f6724e50..000000000 --- a/samples/struts/pet-store/src/main/resources/struts.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/struts/pet-store/template.yml b/samples/struts/pet-store/template.yml deleted file mode 100644 index 85870c6bd..000000000 --- a/samples/struts/pet-store/template.yml +++ /dev/null @@ -1,32 +0,0 @@ -AWSTemplateFormatVersion: '2010-09-09' -Transform: AWS::Serverless-2016-10-31 -Description: Example Pet Store API written with Apache Struts based on the aws-serverless-java-container library - -Globals: - Api: - # API Gateway regional endpoints - EndpointConfiguration: REGIONAL - -Resources: - PetStoreFunction: - Type: AWS::Serverless::Function - Properties: - Handler: com.amazonaws.serverless.proxy.struts.StrutsLambdaHandler::handleRequest - Runtime: java11 - CodeUri: . - MemorySize: 512 - Policies: AWSLambdaBasicExecutionRole - Timeout: 30 - Events: - HttpApiEvent: - Type: HttpApi - Properties: - TimeoutInMillis: 20000 - PayloadFormatVersion: '1.0' - -Outputs: - StrutsPetStoreApi: - Description: URL for application - Value: !Sub 'https://${ServerlessHttpApi}.execute-api.${AWS::Region}.amazonaws.com/pets' - Export: - Name: StrutsPetStoreApi diff --git a/samples/struts/pet-store/test-event.json b/samples/struts/pet-store/test-event.json deleted file mode 100644 index 5860f3e86..000000000 --- a/samples/struts/pet-store/test-event.json +++ /dev/null @@ -1,123 +0,0 @@ -{ - "body": "eyJ0ZXN0IjoiYm9keSJ9", - "resource": "/{proxy+}", - "path": "/pets.json", - "httpMethod": "GET", - "isBase64Encoded": true, - "queryStringParameters": { - "foo": "bar" - }, - "multiValueQueryStringParameters": { - "foo": [ - "bar" - ] - }, - "pathParameters": { - "proxy": "/path/to/resource" - }, - "stageVariables": { - "baz": "qux" - }, - "headers": { - "Accept": "application/json", - "Accept-Encoding": "gzip, deflate, sdch", - "Accept-Language": "en-US,en;q=0.8", - "Cache-Control": "max-age=0", - "CloudFront-Forwarded-Proto": "https", - "CloudFront-Is-Desktop-Viewer": "true", - "CloudFront-Is-Mobile-Viewer": "false", - "CloudFront-Is-SmartTV-Viewer": "false", - "CloudFront-Is-Tablet-Viewer": "false", - "CloudFront-Viewer-Country": "US", - "Host": "1234567890.execute-api.us-east-1.amazonaws.com", - "Upgrade-Insecure-Requests": "1", - "User-Agent": "Custom User Agent String", - "Via": "1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)", - "X-Amz-Cf-Id": "cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==", - "X-Forwarded-For": "127.0.0.1, 127.0.0.2", - "X-Forwarded-Port": "443", - "X-Forwarded-Proto": "https" - }, - "multiValueHeaders": { - "Accept": [ - "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" - ], - "Accept-Encoding": [ - "gzip, deflate, sdch" - ], - "Accept-Language": [ - "en-US,en;q=0.8" - ], - "Cache-Control": [ - "max-age=0" - ], - "CloudFront-Forwarded-Proto": [ - "https" - ], - "CloudFront-Is-Desktop-Viewer": [ - "true" - ], - "CloudFront-Is-Mobile-Viewer": [ - "false" - ], - "CloudFront-Is-SmartTV-Viewer": [ - "false" - ], - "CloudFront-Is-Tablet-Viewer": [ - "false" - ], - "CloudFront-Viewer-Country": [ - "US" - ], - "Host": [ - "0123456789.execute-api.us-east-1.amazonaws.com" - ], - "Upgrade-Insecure-Requests": [ - "1" - ], - "User-Agent": [ - "Custom User Agent String" - ], - "Via": [ - "1.1 08f323deadbeefa7af34d5feb414ce27.cloudfront.net (CloudFront)" - ], - "X-Amz-Cf-Id": [ - "cDehVQoZnx43VYQb9j2-nvCh-9z396Uhbp027Y2JvkCPNLmGJHqlaA==" - ], - "X-Forwarded-For": [ - "127.0.0.1, 127.0.0.2" - ], - "X-Forwarded-Port": [ - "443" - ], - "X-Forwarded-Proto": [ - "https" - ] - }, - "requestContext": { - "accountId": "123456789012", - "resourceId": "123456", - "stage": "prod", - "requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef", - "requestTime": "09/Apr/2015:12:34:56 +0000", - "requestTimeEpoch": 1428582896000, - "identity": { - "cognitoIdentityPoolId": null, - "accountId": null, - "cognitoIdentityId": null, - "caller": null, - "accessKey": null, - "sourceIp": "127.0.0.1", - "cognitoAuthenticationType": null, - "cognitoAuthenticationProvider": null, - "userArn": null, - "userAgent": "Custom User Agent String", - "user": null - }, - "path": "/pets.json", - "resourcePath": "/{proxy+}", - "httpMethod": "GET", - "apiId": "1234567890", - "protocol": "HTTP/1.1" - } -} \ No newline at end of file