-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat(handler): Add custom header to all AWS responses from LocalStack #12769
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
base: master
Are you sure you want to change the base?
Conversation
S3 Image Test Results (AMD64 / ARM64)ββββ2 filesββββ2 suitesβββ9m 7s β±οΈ Results for commit 73ff947. β»οΈ This comment has been updated with latest results. |
Test Results - Preflight, Unit21β635 testsβ +5βββ19β978 β
+5βββ6m 10s β±οΈ -14s Results for commit 73ff947.βΒ± Comparison against base commit 67b3da6. β»οΈ This comment has been updated with latest results. |
Test Results - Alternative Providers988 testsβ +1βββ620 β
+31βββ35m 46s β±οΈ + 6m 22s For more details on these failures, see this check. Results for commit 73ff947.βΒ± Comparison against base commit 67b3da6. β»οΈ This comment has been updated with latest results. |
Test Results (amd64) - Integration, Bootstrapββββ5 filesβ Β±0ββββββ5 suitesβ Β±0βββ2h 26m 10s β±οΈ + 3m 3s For more details on these failures, see this check. Results for commit 73ff947.βΒ± Comparison against base commit 67b3da6. β»οΈ This comment has been updated with latest results. |
LocalStack Community integration with Proββββ2 filesβ Β±0ββββββ2 suitesβ Β±0βββ1h 45m 6s β±οΈ + 1m 39s For more details on these failures, see this check. Results for commit 73ff947.βΒ± Comparison against base commit 67b3da6. β»οΈ This comment has been updated with latest results. |
e3c1dcf
to
0447cfd
Compare
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.
Reviewed and tested env variable in a pairing session.
@@ -1245,6 +1245,9 @@ def use_custom_dns(): | |||
# This flag enables `connect_to` to be in-memory only and not do networking calls | |||
IN_MEMORY_CLIENT = is_env_true("IN_MEMORY_CLIENT") | |||
|
|||
# This flag enables all responses from LocalStack to contain a `x-localstack` HTTP header. |
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.
dismiss: would rephrase this that flag "disables" this header from being set in response. default: True.
just a heads up to add the env var in public docs: https://docs.localstack.cloud/references/configuration/
@@ -107,6 +108,26 @@ def _infrastructure_setup( | |||
return _infrastructure_setup | |||
|
|||
|
|||
@pytest.hookimpl | |||
def pytest_runtest_setup(item): |
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.
would be nice to add a small high-level docstring/comment what this fixture was added for, so one can understand it in the code without having to open the PR where it was introduced for additional context.
e.g: """ fixture that skips header x-localstack
from snapshot evaluation"""
|
||
# Otherwise, dynamically inject a path to the custom header inside all skip_snapshot_verify markers paths. | ||
# If a path parameter is None, it's assumed that all paths are skipped. | ||
for mark in skip_markers: |
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.
question: there are some snapshot tests example where path
parameter is not explicitly set, but just the list with the item is passed. Is that covered by these conditions?
@markers.snapshot.skip_snapshot_verify( [ "$..Invalidation.Status", # In real AWS it can be still in progress "$..Location", # not currently supported ] )
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.
Huh that is a good question π€ Let me see if the kwargs
accounts for this
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.
OK damn. You're correct. This is not accounted for. Nice catch!
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.
Update on this... looks like paths are not skipped when added as args as opposed to kwargs π
That means the test you linked actually skips all paths.
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 and clean, good job @gregfurman ππΌ
I liked the logic for skipping the x-localstack header check from snapshot matching.
Motivation
This PR adds a custom header to all service responses -- allowing us to distinguish whether a request orignates from LocalStack or AWS.
Changes
LOCALSTACK_RESPONSE_HEADER_ENABLED
environment variable that is opt-out by default.LOCALSTACK_RESPONSE_HEADER_ENABLED
is truthy, a handler is added to the response chain that adds ax-localstack: true
header to all responses from LocalStack gateway.