Fix issue where findAll endpoints would NOT respond (404 result) when a trailing slash was used. Add a single IT which proves it responds the same regardless of trailing slash or not (previously this IT failed)

This commit is contained in:
Tim Donohue
2024-03-20 12:08:45 -05:00
parent fdea0b0c77
commit 9ad6bf5833
2 changed files with 8 additions and 2 deletions

View File

@@ -961,7 +961,8 @@ public class RestResourceController implements InitializingBean {
}
/**
* Find all
* Find all via a GET request to the root endpoint. This method will trigger in cases where the called endpoint
* either includes a trailing slash or not.
*
* @param apiCategory
* @param model
@@ -969,7 +970,7 @@ public class RestResourceController implements InitializingBean {
* @param assembler
* @return
*/
@RequestMapping(method = RequestMethod.GET)
@RequestMapping(method = RequestMethod.GET, value = {"", "/"})
@SuppressWarnings("unchecked")
public <T extends RestAddressableModel> PagedModel<DSpaceResource<T>> findAll(@PathVariable String apiCategory,
@PathVariable String model, Pageable page, PagedResourcesAssembler assembler, HttpServletResponse response,

View File

@@ -51,5 +51,10 @@ public class ConfigurationRestRepositoryIT extends AbstractControllerIntegration
public void getAll() throws Exception {
getClient().perform(get("/api/config/properties/"))
.andExpect(status().isMethodNotAllowed());
// Sanity check - Verify same result with no trailing slash, as DSpace should not care whether this
// findAll endpoint ends in a slash or not.
getClient().perform(get("/api/config/properties"))
.andExpect(status().isMethodNotAllowed());
}
}