-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
APIGW NG implement URI rendering #11140
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 55s ⏱️ - 1h 11m 20s Results for commit f99f8b2. ± Comparison against base commit a358ab8. This pull request removes 2515 tests.
♻️ This comment has been updated with latest results. |
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 PR! Well tested!
I just left a question about how to fail when a path still contains {path}
, but nothing blocking. We can always get back to it when we do the integration.
@@ -66,12 +67,16 @@ def __call__( | |||
body, request_override = self.render_request_template_mapping( | |||
context=context, template=request_template | |||
) | |||
# TODO: log every override that happens afterwards (in a loop on `request_override`) |
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.
Good point. I missed that one!
...ack-core/localstack/services/apigateway/next_gen/execute_api/handlers/integration_request.py
Outdated
Show resolved
Hide resolved
tests/unit/services/apigateway/test_handler_integration_request.py
Outdated
Show resolved
Hide resolved
|
||
|
||
class TestUriInterpolationStageVariables: | ||
@pytest.mark.parametrize( |
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 use of parametrize, really quick and easy to see what is going on!
def test_uri_interpolating_with_no_variable(self): | ||
uri_with_only_braces = "https://test.domain.example/root/${path}" | ||
stage_variables = {} | ||
rendered = render_uri_with_stage_variables( | ||
uri=uri_with_only_braces, stage_variables=stage_variables | ||
) | ||
assert rendered == "https://test.domain.example/root/" |
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 I was wondering if that was the result we would get! 👍
I assume the same happens if you use ${stageVariables.path}
?
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! Good catch! This is actually wrong, this should be the result when using ${stageVariables.path}
, I believe if we were to use ${path}
it might just try to interpolate it as a path param, so if no path param named path
it will leave it to ${path}
, otherwise might render $<path-param>
, I need to try it... oops 😬
f3f7376
to
f02f622
Compare
Motivation
Throughout APIGW invocation, there are several places where you can use stageVariables inside some URI and ARN.
We also need to interpolate path parameters inside the Integration URI
This PR implements 2 utils, to render stage variables following the VTL syntax, and another one to render path parameters, only in curly braces.
The Integration Request handler combines those 2 utils to render the Integration URI.
More informations about stage variables here:
https://docs.aws.amazon.com/apigateway/latest/developerguide/aws-api-gateway-stage-variables-reference.html#stage-variables-in-integration-HTTP-uris
We will also use the utils inside the Integration for the credentials, and in the cognito authorizer to render the UserPool.
Changes
vars