Fix : Remove Invalid request error when response-template is not specified (#3885)
* Fix : Remove Invalid request error * Fix test and review commanets * Remove duplicate put_integration_template * API Gateway - Body can be None or empty Co-authored-by: Bert Blommers <info@bertblommers.nl>
This commit is contained in:
parent
85d94ad6ed
commit
0cff5458af
@ -29,7 +29,6 @@ from .exceptions import (
|
|||||||
InvalidIntegrationArn,
|
InvalidIntegrationArn,
|
||||||
InvalidHttpEndpoint,
|
InvalidHttpEndpoint,
|
||||||
InvalidResourcePathException,
|
InvalidResourcePathException,
|
||||||
InvalidRequestInput,
|
|
||||||
AuthorizerNotFoundException,
|
AuthorizerNotFoundException,
|
||||||
StageNotFoundException,
|
StageNotFoundException,
|
||||||
RoleNotSpecified,
|
RoleNotSpecified,
|
||||||
@ -1099,8 +1098,6 @@ class APIGatewayBackend(BaseBackend):
|
|||||||
response_templates,
|
response_templates,
|
||||||
content_handling,
|
content_handling,
|
||||||
):
|
):
|
||||||
if response_templates is None:
|
|
||||||
raise InvalidRequestInput()
|
|
||||||
integration = self.get_integration(function_id, resource_id, method_type)
|
integration = self.get_integration(function_id, resource_id, method_type)
|
||||||
integration_response = integration.create_integration_response(
|
integration_response = integration.create_integration_response(
|
||||||
status_code, selection_pattern, response_templates, content_handling
|
status_code, selection_pattern, response_templates, content_handling
|
||||||
|
@ -19,6 +19,7 @@ from .exceptions import (
|
|||||||
RestAPINotFound,
|
RestAPINotFound,
|
||||||
ModelNotFound,
|
ModelNotFound,
|
||||||
ApiKeyValueMinLength,
|
ApiKeyValueMinLength,
|
||||||
|
InvalidRequestInput,
|
||||||
)
|
)
|
||||||
|
|
||||||
API_KEY_SOURCES = ["AUTHORIZER", "HEADER"]
|
API_KEY_SOURCES = ["AUTHORIZER", "HEADER"]
|
||||||
@ -369,6 +370,9 @@ class APIGatewayResponse(BaseResponse):
|
|||||||
function_id, resource_id, method_type, status_code
|
function_id, resource_id, method_type, status_code
|
||||||
)
|
)
|
||||||
elif self.method == "PUT":
|
elif self.method == "PUT":
|
||||||
|
if not self.body:
|
||||||
|
raise InvalidRequestInput()
|
||||||
|
|
||||||
selection_pattern = self._get_param("selectionPattern")
|
selection_pattern = self._get_param("selectionPattern")
|
||||||
response_templates = self._get_param("responseTemplates")
|
response_templates = self._get_param("responseTemplates")
|
||||||
content_handling = self._get_param("contentHandling")
|
content_handling = self._get_param("contentHandling")
|
||||||
|
@ -1279,6 +1279,7 @@ def test_put_integration_response_requires_responseTemplate():
|
|||||||
)
|
)
|
||||||
ex.value.response["Error"]["Code"].should.equal("BadRequestException")
|
ex.value.response["Error"]["Code"].should.equal("BadRequestException")
|
||||||
ex.value.response["Error"]["Message"].should.equal("Invalid request input")
|
ex.value.response["Error"]["Message"].should.equal("Invalid request input")
|
||||||
|
|
||||||
# Works fine if responseTemplate is defined
|
# Works fine if responseTemplate is defined
|
||||||
client.put_integration_response(
|
client.put_integration_response(
|
||||||
restApiId=api_id,
|
restApiId=api_id,
|
||||||
|
Loading…
Reference in New Issue
Block a user