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:
usmangani1 2021-05-01 20:15:06 +05:30 committed by GitHub
parent 85d94ad6ed
commit 0cff5458af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 3 deletions

View File

@ -29,7 +29,6 @@ from .exceptions import (
InvalidIntegrationArn,
InvalidHttpEndpoint,
InvalidResourcePathException,
InvalidRequestInput,
AuthorizerNotFoundException,
StageNotFoundException,
RoleNotSpecified,
@ -1099,8 +1098,6 @@ class APIGatewayBackend(BaseBackend):
response_templates,
content_handling,
):
if response_templates is None:
raise InvalidRequestInput()
integration = self.get_integration(function_id, resource_id, method_type)
integration_response = integration.create_integration_response(
status_code, selection_pattern, response_templates, content_handling

View File

@ -19,6 +19,7 @@ from .exceptions import (
RestAPINotFound,
ModelNotFound,
ApiKeyValueMinLength,
InvalidRequestInput,
)
API_KEY_SOURCES = ["AUTHORIZER", "HEADER"]
@ -369,6 +370,9 @@ class APIGatewayResponse(BaseResponse):
function_id, resource_id, method_type, status_code
)
elif self.method == "PUT":
if not self.body:
raise InvalidRequestInput()
selection_pattern = self._get_param("selectionPattern")
response_templates = self._get_param("responseTemplates")
content_handling = self._get_param("contentHandling")

View File

@ -1279,6 +1279,7 @@ def test_put_integration_response_requires_responseTemplate():
)
ex.value.response["Error"]["Code"].should.equal("BadRequestException")
ex.value.response["Error"]["Message"].should.equal("Invalid request input")
# Works fine if responseTemplate is defined
client.put_integration_response(
restApiId=api_id,