-
Notifications
You must be signed in to change notification settings - Fork 277
Support app-specific user-agents #2612
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
* application user-agent can be set with UpdaterConfig object * Setting will affect the default fetcher only * the application user-agent will be prefixed to the ngclient default user-agent Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
I did not write a test as I couldn't figure out a reasonable way to do it... but I did test this manually: both default and modified user-agent are as expected. |
Pull Request Test Coverage Report for Build 8783571150Details
💛 - Coveralls |
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.
Looks good. The purist in me leans towards option 2 in #2611, but your approach seems reasonable enough, and smaller API is definitely a good argument.
Re testing:
What speaks against adding a small case to test_updater_ng
(or test_fetcher_ng
), which creates updaters (or fetchers) with and without the new setting, does a refresh (or fetch) and checks if the the session headers contains the expected string?
supported_envelopes = [EnvelopeType.METADATA, EnvelopeType.SIMPLE] | ||
if self.config.envelope_type not in supported_envelopes: | ||
raise ValueError( | ||
f"config: envelope_type must be one of {supported_envelopes}, " | ||
f"got '{self.config.envelope_type}'" | ||
) | ||
|
||
# Read trusted local root metadata | ||
data = self._load_local_metadata(Root.type) |
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.
Why was this line moved here?
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.
- it had to be moved below self.config and self._fetcher setting anyway and
- seemed more sensible to handle all of configuration first, then load local metadata
Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
Added the suggested test, that seems reasonable |
Fixes #2611