-
Notifications
You must be signed in to change notification settings - Fork 334
feat: Introduce a way to provide custom headers #1811
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: main
Are you sure you want to change the base?
Conversation
""" | ||
import copy | ||
|
||
PROTECTED_HEADERS = { |
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.
Is there a way to capture this in a more central way? I worry that we are missing some now or may miss some in the future if new ones get added
for example
_METADATA_HEADERS = {_METADATA_FLAVOR_HEADER: _METADATA_FLAVOR_VALUE} |
creds_with_header.before_request(request, "http://example.com", "GET", headers) | ||
assert headers["X-Custom-Header"] == "value1" | ||
assert "authorization" in headers # Ensure base apply logic ran | ||
assert creds_with_header is not credentials |
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.
Not sure what you're trying to test here but as I understand python, this will never be true.
i.e. if you did:
credentials_a = CredentialsImpl()
credentials_b = CredentialsImpl()
assert credentials_a is not credentials_b # success
assert c._use_non_blocking_refresh | ||
|
||
|
||
def test_with_headers(): |
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.
nit: this test is testing multiple scenarios. could you break it up so that we are testing ~1 thing per test?
https://engdoc.corp.google.com/eng/doc/tott/episodes/726.md?cl=head
|
||
self._use_non_blocking_refresh = False | ||
self._refresh_worker = RefreshThreadManager() | ||
self._custom_headers = {} |
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.
This is not used?
For certain scenarios, custom headers are required to be sent to the backend along with usual headers like
authorization
,x-goog-user-project
. Exposing a way for users to specify these custom headers.