test: cover redirect userinfo stripping for an IPv6 literal host#89
Merged
Conversation
The redirect step rebuilds a Location URL textually when dropping server-supplied userinfo, appending URI.getHost() verbatim. For an IPv6 literal authority that host is the bracketed form (e.g. [2001:db8::1]), so the rebuild has to carry the brackets through unchanged. That path was previously unexercised: the existing userinfo tests only covered a regular hostname and a percent-encoded path/query. Add a test that follows a redirect to a Location with an IPv6 literal authority carrying userinfo and asserts the reissued request drops the userinfo while preserving the bracketed host, port, path, and query byte-exact.
Capture the reissued response in the IPv6 userinfo-stripping test and assert the redirect was followed exactly once (status 200, two calls) so a regression that skips the reissue fails with a clear message instead of an IndexOutOfBoundsException on fake.requests[1]. Add a sibling test for an IPv6 literal Location with no userinfo, exercising the pass-through (no-rebuild) branch and confirming the bracketed host, port, path, and query survive there too.
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.
Summary
DefaultRedirectStepstrips userinfo (user:pass@) from a redirectLocationwhile rebuilding the URL textually from its raw components. The existing tests cover percent-encoded paths and ordinary hosts, but nothing exercised an IPv6 literal authority, where the host carries its[...]brackets through the JavaURIAPI.Adds a test that follows a redirect to
https://user:pass@[2001:db8::1]:8443/v2/resource?q=1and asserts the re-issued request has the userinfo stripped while the bracketed IPv6 host, port, path, and query are preserved byte-exact.The existing behavior is already correct — this is test coverage only, no source or API change.
Closes #20