Skip to content

Commit

Permalink
Fix the RemoteAddressTest in the TCK by providing a resolved IP addre…
Browse files Browse the repository at this point in the history
…ss (#1637)

The test gets the IP address, and this is null if the InetAddress is unresolveable

Co-authored-by: Sergio del Amo <sergio.delamo@softamo.com>
  • Loading branch information
timyates and sdelamo authored Mar 8, 2023
1 parent 6a5c203 commit cb02ba1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.amazonaws.serverless.exceptions.ContainerInitializationException;
import com.amazonaws.serverless.proxy.internal.testutils.MockLambdaContext;
import com.amazonaws.serverless.proxy.model.ApiGatewayRequestIdentity;
import com.amazonaws.serverless.proxy.model.AwsProxyRequest;
import com.amazonaws.serverless.proxy.model.AwsProxyRequestContext;
import com.amazonaws.serverless.proxy.model.AwsProxyResponse;
Expand Down Expand Up @@ -68,7 +69,15 @@ private <I> AwsProxyRequest adaptRequest(HttpRequest<I> request) throws Unsuppor
AwsProxyRequest input = new AwsProxyRequest();
input.setHttpMethod(request.getMethodName());
input.setRequestContext(new AwsProxyRequestContext() {

@Override
public ApiGatewayRequestIdentity getIdentity() {
return new ApiGatewayRequestIdentity() {
@Override
public String getSourceIp() {
return "127.0.0.1";
}
};
}
});
input.setPath(request.getPath());
for (String headerName : request.getHeaders().names()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
@SelectPackages("io.micronaut.http.server.tck.tests")
@SuiteDisplayName("HTTP Server TCK for Function AWS API Proxy")
@ExcludeClassNamePatterns({
"io.micronaut.http.server.tck.tests.RemoteAddressTest", // CaptureRemoteAddressFiter throws NPE getting the address
"io.micronaut.http.server.tck.tests.filter.ClientRequestFilterTest",
"|io.micronaut.http.server.tck.tests.ErrorHandlerTest", // 2 tests Fail as CORs headers are not added to the response after deserialization fails
"io.micronaut.http.server.tck.tests.BodyTest", // Fails with a multi-value publisher as the body type
Expand Down

0 comments on commit cb02ba1

Please sign in to comment.