-
Notifications
You must be signed in to change notification settings - Fork 38.9k
Closed
Labels
status: duplicateA duplicate of another issueA duplicate of another issue
Description
Spring boot version: 2.4.1
Test:
@Test
@WithMockUser(roles = "APP_OWNER")
void given_application_owner_then_applicationUpload_should_throw_403() throws Exception {
MockMultipartFile file = new MockMultipartFile("file", "some content".getBytes());
mockMvc.perform(
multipart("/applications/actions/upload").file(file).header("Content-Type", "multipart/form-data"))
.andExpect(status().isForbidden());
}
Controller:
@PostMapping(value = "/actions/upload",
consumes = { MediaType.MULTIPART_FORM_DATA_VALUE, "multipart/form-data;charset=UTF-8" })
@RolesAllowed("ADMIN")
public List<ApplicationUploadStatusDTO> uploadApplications(@RequestParam("file") MultipartFile file) {
// Do something here
}
Expected result: 403 error
Actual result: 400
MockHttpServletResponse:
Status = 400
Error message = Required request part 'file' is not present
Headers = [X-Content-Type-Options:"nosniff", X-XSS-Protection:"1; mode=block", Cache-Control:"no-cache, no-store, max-age=0, must-revalidate", Pragma:"no-cache", Expires:"0", X-Frame-Options:"DENY"]
Content type = null
Body =
Forwarded URL = null
Redirected URL = null
Cookies = []
Same code is working as expected with spring-boot 2.4.0
maxkramer, AlexCzar and MFomichev
Metadata
Metadata
Assignees
Labels
status: duplicateA duplicate of another issueA duplicate of another issue