|
10 | 10 | import com.amazonaws.services.lambda.runtime.Context; |
11 | 11 | import com.amazonaws.services.lambda.runtime.LambdaLogger; |
12 | 12 | import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent; |
| 13 | +import com.amazonaws.services.lambda.runtime.events.APIGatewayV2ProxyRequestEvent; |
13 | 14 | import com.amazonaws.services.lambda.runtime.events.CloudFrontEvent; |
14 | 15 | import com.amazonaws.services.lambda.runtime.events.CloudWatchLogsEvent; |
15 | 16 | import com.amazonaws.services.lambda.runtime.events.CodeCommitEvent; |
@@ -253,6 +254,27 @@ public void testAPIGatewayProxyRequestEvent() { |
253 | 254 | "APIGatewayProxyRequestEventUserARN", span.tags().get("aws.lambda.eventSource.arn")); |
254 | 255 | } |
255 | 256 |
|
| 257 | + @Test |
| 258 | + public void testAPIGatewayV2ProxyRequestEvent() { |
| 259 | + final MyApiGatewayV2ProxyRequestHandler myApiGatewayV2ProxyRequestHandler = |
| 260 | + new MyApiGatewayV2ProxyRequestHandler(); |
| 261 | + |
| 262 | + final APIGatewayV2ProxyRequestEvent apiGatewayV2ProxyRequestEvent = |
| 263 | + new APIGatewayV2ProxyRequestEvent(); |
| 264 | + final APIGatewayV2ProxyRequestEvent.RequestIdentity requestIdentity = |
| 265 | + new APIGatewayV2ProxyRequestEvent.RequestIdentity(); |
| 266 | + requestIdentity.setUserArn("APIGatewayV2ProxyRequestEventUserARN"); |
| 267 | + final APIGatewayV2ProxyRequestEvent.RequestContext proxyRequestContext = |
| 268 | + new APIGatewayV2ProxyRequestEvent.RequestContext(); |
| 269 | + proxyRequestContext.setIdentity(requestIdentity); |
| 270 | + apiGatewayV2ProxyRequestEvent.setRequestContext(proxyRequestContext); |
| 271 | + |
| 272 | + myApiGatewayV2ProxyRequestHandler.handleRequest(apiGatewayV2ProxyRequestEvent, createContext()); |
| 273 | + final MockSpan span = mockTracer.finishedSpans().get(0); |
| 274 | + Assert.assertEquals( |
| 275 | + "APIGatewayV2ProxyRequestEventUserARN", span.tags().get("aws.lambda.eventSource.arn")); |
| 276 | + } |
| 277 | + |
256 | 278 | @Test |
257 | 279 | @Ignore("We would like this but there doesn't seem to be an available arn currently") |
258 | 280 | public void testCloudWatchLogsEvent() { |
@@ -373,6 +395,16 @@ public Object doHandleRequest( |
373 | 395 | } |
374 | 396 | } |
375 | 397 |
|
| 398 | + static class MyApiGatewayV2ProxyRequestHandler |
| 399 | + implements TracingRequestHandler<APIGatewayV2ProxyRequestEvent, Object> { |
| 400 | + |
| 401 | + @Override |
| 402 | + public Object doHandleRequest( |
| 403 | + APIGatewayV2ProxyRequestEvent apiGatewayV2ProxyRequestEvent, Context context) { |
| 404 | + return "null"; |
| 405 | + } |
| 406 | + } |
| 407 | + |
376 | 408 | // Cloud Front |
377 | 409 | static class MyCloudFrontRequestHandler |
378 | 410 | implements TracingRequestHandler<CloudFrontEvent, Object> { |
|
0 commit comments