Skip to content

Commit aed8295

Browse files
authored
ApiGatewayV2CustomAuthorizerV2Request identity_source as optional (#860)
1 parent 46ba8c7 commit aed8295

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

lambda-events/src/event/apigw/mod.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,8 @@ pub struct ApiGatewayV2CustomAuthorizerV2Request {
565565
/// nolint: stylecheck
566566
#[serde(default)]
567567
pub route_arn: Option<String>,
568-
pub identity_source: Vec<String>,
568+
#[serde(skip_serializing_if = "Option::is_none")]
569+
pub identity_source: Option<Vec<String>>,
569570
#[serde(default)]
570571
pub route_key: Option<String>,
571572
#[serde(default)]
@@ -1008,6 +1009,17 @@ mod test {
10081009
assert_eq!(parsed, reparsed);
10091010
}
10101011

1012+
#[test]
1013+
#[cfg(feature = "apigw")]
1014+
fn example_apigw_v2_custom_authorizer_v2_request_without_identity_source() {
1015+
let data =
1016+
include_bytes!("../../fixtures/example-apigw-v2-custom-authorizer-v2-request-without-identity-source.json");
1017+
let parsed: ApiGatewayV2CustomAuthorizerV2Request = serde_json::from_slice(data).unwrap();
1018+
let output: String = serde_json::to_string(&parsed).unwrap();
1019+
let reparsed: ApiGatewayV2CustomAuthorizerV2Request = serde_json::from_slice(output.as_bytes()).unwrap();
1020+
assert_eq!(parsed, reparsed);
1021+
}
1022+
10111023
#[test]
10121024
#[cfg(feature = "apigw")]
10131025
fn example_apigw_console_request() {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"version": "2.0",
3+
"type": "REQUEST",
4+
"routeArn": "arn:aws:execute-api:us-east-1:123456789012:abcdef123/test/GET/request",
5+
"routeKey": "$default",
6+
"rawPath": "/my/path",
7+
"rawQueryString": "parameter1=value1&parameter1=value2&parameter2=value",
8+
"cookies": ["cookie1", "cookie2"],
9+
"headers": {
10+
"Header1": "value1",
11+
"Header2": "value2"
12+
},
13+
"queryStringParameters": {
14+
"parameter1": "value1,value2",
15+
"parameter2": "value"
16+
},
17+
"requestContext": {
18+
"accountId": "123456789012",
19+
"apiId": "api-id",
20+
"authentication": {
21+
"clientCert": {
22+
"clientCertPem": "CERT_CONTENT",
23+
"subjectDN": "www.example.com",
24+
"issuerDN": "Example issuer",
25+
"serialNumber": "a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1",
26+
"validity": {
27+
"notBefore": "May 28 12:30:02 2019 GMT",
28+
"notAfter": "Aug 5 09:36:04 2021 GMT"
29+
}
30+
}
31+
},
32+
"domainName": "id.execute-api.us-east-1.amazonaws.com",
33+
"domainPrefix": "id",
34+
"http": {
35+
"method": "POST",
36+
"path": "/my/path",
37+
"protocol": "HTTP/1.1",
38+
"sourceIp": "IP",
39+
"userAgent": "agent"
40+
},
41+
"requestId": "id",
42+
"routeKey": "$default",
43+
"stage": "$default",
44+
"time": "12/Mar/2020:19:03:58 +0000",
45+
"timeEpoch": 1583348638390
46+
},
47+
"pathParameters": { "parameter1": "value1" },
48+
"stageVariables": { "stageVariable1": "value1", "stageVariable2": "value2" }
49+
}
50+

0 commit comments

Comments
 (0)