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

HtmlUnit / MockMvc integration handles forwarded URLs partially #28722

Closed
rstoyanchev opened this issue Jun 28, 2022 · 0 comments
Closed

HtmlUnit / MockMvc integration handles forwarded URLs partially #28722

rstoyanchev opened this issue Jun 28, 2022 · 0 comments
Assignees
Labels
in: test Issues in the test module in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Milestone

Comments

@rstoyanchev
Copy link
Contributor

rstoyanchev commented Jun 28, 2022

Currently ForwardRequestPostProcessor uses the forwarded URL only to set the servletPath of the mock request, which means requestUri and servletPath are out of sync.

This hasn't been reported as an issue since UrlPathHelper falls back on the servletPath if it doesn't match the requestURI but that's not really correct behavior, and causes issues in more modern setups like parsed patterns where we rely mainly on the requestURI and only check the servletPath if a Servlet prefix mapping can be confirmed with Servlet 4.0.

In the absence of a Servlet container, i.e. with mock request and response, there is actually no good way to take a forwardedUrl and break it down into contextPath, servletPath, and pathInfo. At best, we can assert that the forwarded URL does start with the same contextPath, but otherwise break it down into contextPath + servletPath.

This was uncovered while working on #28607.

@rstoyanchev rstoyanchev added in: test Issues in the test module in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug labels Jun 28, 2022
@rstoyanchev rstoyanchev added this to the 6.0.0-M5 milestone Jun 28, 2022
@rstoyanchev rstoyanchev self-assigned this Jun 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

1 participant