Skip to content

Commit

Permalink
ApiGatewayV2CustomAuthorizerV2Request identity_source as optional (#860)
Browse files Browse the repository at this point in the history
  • Loading branch information
HVKukkonen authored Apr 22, 2024
1 parent 46ba8c7 commit aed8295
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lambda-events/src/event/apigw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,8 @@ pub struct ApiGatewayV2CustomAuthorizerV2Request {
/// nolint: stylecheck
#[serde(default)]
pub route_arn: Option<String>,
pub identity_source: Vec<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub identity_source: Option<Vec<String>>,
#[serde(default)]
pub route_key: Option<String>,
#[serde(default)]
Expand Down Expand Up @@ -1008,6 +1009,17 @@ mod test {
assert_eq!(parsed, reparsed);
}

#[test]
#[cfg(feature = "apigw")]
fn example_apigw_v2_custom_authorizer_v2_request_without_identity_source() {
let data =
include_bytes!("../../fixtures/example-apigw-v2-custom-authorizer-v2-request-without-identity-source.json");
let parsed: ApiGatewayV2CustomAuthorizerV2Request = serde_json::from_slice(data).unwrap();
let output: String = serde_json::to_string(&parsed).unwrap();
let reparsed: ApiGatewayV2CustomAuthorizerV2Request = serde_json::from_slice(output.as_bytes()).unwrap();
assert_eq!(parsed, reparsed);
}

#[test]
#[cfg(feature = "apigw")]
fn example_apigw_console_request() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"version": "2.0",
"type": "REQUEST",
"routeArn": "arn:aws:execute-api:us-east-1:123456789012:abcdef123/test/GET/request",
"routeKey": "$default",
"rawPath": "/my/path",
"rawQueryString": "parameter1=value1&parameter1=value2&parameter2=value",
"cookies": ["cookie1", "cookie2"],
"headers": {
"Header1": "value1",
"Header2": "value2"
},
"queryStringParameters": {
"parameter1": "value1,value2",
"parameter2": "value"
},
"requestContext": {
"accountId": "123456789012",
"apiId": "api-id",
"authentication": {
"clientCert": {
"clientCertPem": "CERT_CONTENT",
"subjectDN": "www.example.com",
"issuerDN": "Example issuer",
"serialNumber": "a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1:a1",
"validity": {
"notBefore": "May 28 12:30:02 2019 GMT",
"notAfter": "Aug 5 09:36:04 2021 GMT"
}
}
},
"domainName": "id.execute-api.us-east-1.amazonaws.com",
"domainPrefix": "id",
"http": {
"method": "POST",
"path": "/my/path",
"protocol": "HTTP/1.1",
"sourceIp": "IP",
"userAgent": "agent"
},
"requestId": "id",
"routeKey": "$default",
"stage": "$default",
"time": "12/Mar/2020:19:03:58 +0000",
"timeEpoch": 1583348638390
},
"pathParameters": { "parameter1": "value1" },
"stageVariables": { "stageVariable1": "value1", "stageVariable2": "value2" }
}

0 comments on commit aed8295

Please sign in to comment.