Skip to content

test: cover redirect userinfo stripping for an IPv6 literal host#89

Merged
OmarAlJarrah merged 2 commits into
mainfrom
test/redirect-userinfo-ipv6
Jun 16, 2026
Merged

test: cover redirect userinfo stripping for an IPv6 literal host#89
OmarAlJarrah merged 2 commits into
mainfrom
test/redirect-userinfo-ipv6

Conversation

@OmarAlJarrah

Copy link
Copy Markdown
Member

Summary

DefaultRedirectStep strips userinfo (user:pass@) from a redirect Location while 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 Java URI API.

Adds a test that follows a redirect to https://user:pass@[2001:db8::1]:8443/v2/resource?q=1 and 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

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.
@OmarAlJarrah OmarAlJarrah merged commit a594c7e into main Jun 16, 2026
1 check 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.

Add a redirect userinfo-stripping test for an IPv6 literal host

1 participant