-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Apigw ng request template mapping #11138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
LocalStack Community integration with Pro 2 files ± 0 2 suites ±0 23m 34s ⏱️ - 1h 16m 11s Results for commit e9675ef. ± Comparison against base commit 6ea7da3. This pull request removes 2513 tests.
♻️ This comment has been updated with latest results. |
@bentsku We might need more tests in the handler to make sure that both step work good together. I didn't want to test all scenarios for now as I feel most of the edge cases should be tested either in the unit tests for Happy to collaborate and align our testing efforts! 🤘 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow! Impressive set of change! Agreed about the handler, to me it makes lots of sense to do this way. 👍
Just have a comment about the decoding/re-encoding of the body, I believe we could avoid the little dance by always returning bytes
from render_request_template_mapping
.
Great work once again, nice set of tests, this is really taking shape now! I'll hurry to complete the IntegrationResponse
now so that we can continue from there with the VTL templating too.
Also a small comment about the InvocationRequest
in the tests, I wonder if we should just use raw Request
object and parse them directly to simplify our work. 🤔
...ack-core/localstack/services/apigateway/next_gen/execute_api/handlers/integration_request.py
Show resolved
Hide resolved
...ack-core/localstack/services/apigateway/next_gen/execute_api/handlers/integration_request.py
Outdated
Show resolved
Hide resolved
localstack-core/localstack/services/apigateway/next_gen/execute_api/template_mapping.py
Show resolved
Hide resolved
localstack-core/localstack/services/apigateway/next_gen/execute_api/variables.py
Outdated
Show resolved
Hide resolved
tests/unit/services/apigateway/test_handler_integration_request.py
Outdated
Show resolved
Hide resolved
tests/unit/services/apigateway/test_handler_integration_request.py
Outdated
Show resolved
Hide resolved
localstack-core/localstack/services/apigateway/next_gen/execute_api/variables.py
Show resolved
Hide resolved
# AWS doesn't send a body for these methods. Mock needs the body to get the status code | ||
# TODO this might need to be done in the integrations? | ||
if ( | ||
integration_method in [HTTPMethod.GET, HTTPMethod.HEAD, HTTPMethod.OPTIONS] | ||
and not integration_type == IntegrationType.MOCK | ||
): | ||
body = b"" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bentsku I added this section after validating it's behavior against aws.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I answered here too 😄 #11138 (comment)
...ack-core/localstack/services/apigateway/next_gen/execute_api/handlers/integration_request.py
Outdated
Show resolved
Hide resolved
...ack-core/localstack/services/apigateway/next_gen/execute_api/handlers/integration_request.py
Outdated
Show resolved
Hide resolved
multi_value_query_string_parameters={"qs": ["ignored-value", "test-qs-value"]}, | ||
multi_value_headers=header_dict, | ||
body=b"", | ||
request = InvocationRequestParser().create_invocation_request( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, very neat 👌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing the comments! 🚀 very nice changes, I like the parsing of the request in the test, makes it a bit simpler to not juggle with the headers kind, we might be able to simplify at some point... maybe the headers
field of the context is only used in AWS_PROXY
, so we might be able to remove it.
Really nice PR, really neat and well organized! And a lot of added tests! 🚀
Motivation
Adding VTL Template Mapping to our Integration request handler and port
ApiGatewayVtlTemplate
class to NG provider.The request template allows to create a request body based on the provided VTL template. You can also use it to
#set
requests override the path parameters, headers and query strings. See: https://docs.aws.amazon.com/apigateway/latest/developerguide/models-mappings.htmlWhen no templates are found based on content-type, an
UnsupportedMediaTypeError
can be raised depending on the set passthrough behaviour.Changes
ApiGatewayVtlTemplate
, which is ported and simplified from legacytemplates.py
.TODO
What's left to do:
ApiGatewayVtlTemplate
. Port from legacy to prevent regressions as we move forwardIntegrationRequestHandler
. There might be more tests needed as parameters mapping was not tested yet