Skip to content
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

Support app-specific user-agents #2612

Merged
merged 2 commits into from Apr 22, 2024

Conversation

jku
Copy link
Member

@jku jku commented Apr 19, 2024

  • 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

Fixes #2611

* 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>
@jku
Copy link
Member Author

jku commented Apr 19, 2024

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.

@coveralls
Copy link

coveralls commented Apr 19, 2024

Pull Request Test Coverage Report for Build 8783571150

Details

  • 10 of 10 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.01%) to 97.605%

Totals Coverage Status
Change from base Build 8700988091: 0.01%
Covered Lines: 1473
Relevant Lines: 1498

💛 - Coveralls

Copy link
Member

@lukpueh lukpueh left a 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)
Copy link
Member

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?

Copy link
Member Author

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>
@jku
Copy link
Member Author

jku commented Apr 22, 2024

Added the suggested test, that seems reasonable

@jku jku merged commit 74882c5 into theupdateframework:develop Apr 22, 2024
22 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

provide user-agent customization?
3 participants