Skip to content

Commit 0f1768c

Browse files
committed
Added unit tests for stage as context on Jersey routing bug (#200)
1 parent 074f9dc commit 0f1768c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

aws-serverless-java-container-jersey/src/test/java/com/amazonaws/serverless/proxy/jersey/JerseyAwsProxyTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
package com.amazonaws.serverless.proxy.jersey;
1414

1515

16+
import com.amazonaws.serverless.proxy.internal.LambdaContainerHandler;
1617
import com.amazonaws.serverless.proxy.model.AwsProxyRequest;
1718
import com.amazonaws.serverless.proxy.model.AwsProxyResponse;
1819
import com.amazonaws.serverless.proxy.internal.servlet.AwsServletContext;
@@ -239,6 +240,21 @@ public void stripBasePath_route_shouldRouteCorrectly() {
239240
handler.stripBasePath("");
240241
}
241242

243+
@Test
244+
public void stripBasePath_route_shouldReturn404WithStageAsContext() {
245+
AwsProxyRequest request = new AwsProxyRequestBuilder("/custompath/echo/status-code", "GET")
246+
.stage("prod")
247+
.json()
248+
.queryString("status", "201")
249+
.build();
250+
handler.stripBasePath("/custompath");
251+
LambdaContainerHandler.getContainerConfig().setUseStageAsServletContext(true);
252+
AwsProxyResponse output = handler.proxy(request, lambdaContext);
253+
assertEquals(404, output.getStatusCode());
254+
handler.stripBasePath("");
255+
LambdaContainerHandler.getContainerConfig().setUseStageAsServletContext(false);
256+
}
257+
242258
@Test
243259
public void stripBasePath_route_shouldReturn404() {
244260
AwsProxyRequest request = new AwsProxyRequestBuilder("/custompath/echo/status-code", "GET")

0 commit comments

Comments
 (0)