Skip to content

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

Closed
@rstoyanchev

Description

@rstoyanchev

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.

Metadata

Metadata

Assignees

Labels

in: testIssues in the test modulein: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions