fix: make UrlKeyFetcher http.Client injectable for testability#269
Open
fix: make UrlKeyFetcher http.Client injectable for testability#269
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request adds support for a custom http.Client in FirebaseTokenVerifier and its key fetchers. Reviewers identified a resource leak risk where a new client is created but not closed, recommending a fallback to the global http.get. Additionally, the review suggests removing redundant null-coalescing checks and extending the custom client support to the JwksFetcher for consistency.
Coverage Report✅ Coverage 75.13% meets 40% threshold Total Coverage: 75.13% Package Breakdown
Minimum threshold: 40% |
0088819 to
7e3bf65
Compare
Lyokone
requested changes
May 7, 2026
Contributor
Lyokone
left a comment
There was a problem hiding this comment.
Could we have a separate PR for formatting changes so it's easier to review actual changes from this PR? (I guess it's related to a Flutter version bump?)
c585122 to
d37f6b6
Compare
d37f6b6 to
0521042
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes the HTTP client used by
UrlKeyFetcherinjectable so that tests can intercept the Google public key certificate endpoint without making real network calls.This is a prerequisite for the real token verification tests added in the
firebase_functionsSDK (firebase/firebase-functions-dart#91). PreviouslyUrlKeyFetcheralways used a freshly-createdhttp.Client, making it impossible to intercept the certificate fetch in tests.