Skip to content

MockMvc does not correctly initialize the request for non-file mock Part uploads #25602

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

Closed
rstoyanchev opened this issue Aug 17, 2020 · 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

When MockMultipartHttpServletRequestBuilder is initialized with Part (rather than MultipartFile) instances, it correctly creates a MockHttpServletRequest as per its contract. However in order for this to work correctly the request must then be wrapped with StandardMultipartHttpServletRequest which works out which parts are files (and exposed also as MultipartPartFile) and which ones are not files (and must be exposed as request parameters).

Currently MockMultipartHttpServletRequestBuilder does this which ensures that file parts are recognized but it doesn't ensure the rest are exposed as request parameters which can also cause issues for @RequestPart arguments.

Existing tests appear to be using a filename which makes it work but masks the problem.

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