APIGateway - add request parameters to integration model (#5224)

This commit is contained in:
Cesar Alvernaz 2022-06-14 11:07:30 +01:00 committed by GitHub
parent 9640ec20d1
commit 1698c52740
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 0 deletions

View File

@ -131,6 +131,7 @@ class Integration(BaseModel, dict):
tls_config=None,
cache_namespace=None,
timeout_in_millis=None,
request_parameters=None,
):
super().__init__()
self["type"] = integration_type
@ -146,6 +147,7 @@ class Integration(BaseModel, dict):
self["tlsConfig"] = tls_config
self["cacheNamespace"] = cache_namespace
self["timeoutInMillis"] = timeout_in_millis
self["requestParameters"] = request_parameters
def create_integration_response(
self, status_code, selection_pattern, response_templates, content_handling
@ -378,6 +380,7 @@ class Resource(CloudFormationModel):
tls_config=None,
cache_namespace=None,
timeout_in_millis=None,
request_parameters=None,
):
integration_method = integration_method or method_type
integration = Integration(
@ -389,6 +392,7 @@ class Resource(CloudFormationModel):
tls_config=tls_config,
cache_namespace=cache_namespace,
timeout_in_millis=timeout_in_millis,
request_parameters=request_parameters,
)
self.resource_methods[method_type]["methodIntegration"] = integration
return integration
@ -1568,6 +1572,7 @@ class APIGatewayBackend(BaseBackend):
tls_config=None,
cache_namespace=None,
timeout_in_millis=None,
request_parameters=None,
):
resource = self.get_resource(function_id, resource_id)
if credentials and not re.match(
@ -1609,6 +1614,7 @@ class APIGatewayBackend(BaseBackend):
tls_config=tls_config,
cache_namespace=cache_namespace,
timeout_in_millis=timeout_in_millis,
request_parameters=request_parameters,
)
return integration

View File

@ -446,6 +446,7 @@ class APIGatewayResponse(BaseResponse):
tls_config = self._get_param("tlsConfig")
cache_namespace = self._get_param("cacheNamespace")
timeout_in_millis = self._get_param("timeoutInMillis")
request_parameters = self._get_param("requestParameters")
self.backend.get_method(function_id, resource_id, method_type)
integration_http_method = self._get_param(
@ -465,6 +466,7 @@ class APIGatewayResponse(BaseResponse):
tls_config=tls_config,
cache_namespace=cache_namespace,
timeout_in_millis=timeout_in_millis,
request_parameters=request_parameters,
)
elif self.method == "DELETE":
integration_response = self.backend.delete_integration(

View File

@ -520,6 +520,7 @@ def test_integrations():
passthroughBehavior="WHEN_NO_TEMPLATES",
uri="http://httpbin.org/robots.txt",
integrationHttpMethod="POST",
requestParameters={"integration.request.header.X-Custom": "'Custom'"},
)
# this is hard to match against, so remove it
response["ResponseMetadata"].pop("HTTPHeaders", None)
@ -532,6 +533,7 @@ def test_integrations():
"uri": "http://httpbin.org/robots.txt",
"passthroughBehavior": "WHEN_NO_TEMPLATES",
"cacheKeyParameters": [],
"requestParameters": {"integration.request.header.X-Custom": "'Custom'"},
}
)
@ -549,6 +551,7 @@ def test_integrations():
"uri": "http://httpbin.org/robots.txt",
"passthroughBehavior": "WHEN_NO_TEMPLATES",
"cacheKeyParameters": [],
"requestParameters": {"integration.request.header.X-Custom": "'Custom'"},
}
)
@ -565,6 +568,7 @@ def test_integrations():
"uri": "http://httpbin.org/robots.txt",
"cacheKeyParameters": [],
"passthroughBehavior": "WHEN_NO_TEMPLATES",
"requestParameters": {"integration.request.header.X-Custom": "'Custom'"},
}
)

View File

@ -41,6 +41,7 @@ def test_http_integration():
type="HTTP",
uri="http://httpbin.org/robots.txt",
integrationHttpMethod="GET",
requestParameters={"integration.request.header.X-Custom": "'Custom'"},
)
stage_name = "staging"