diff --git a/src/main/java/uk/gov/companieshouse/pscdataapi/config/WebSecurityConfig.java b/src/main/java/uk/gov/companieshouse/pscdataapi/config/WebSecurityConfig.java index 65d2775f..f4c9cdf9 100644 --- a/src/main/java/uk/gov/companieshouse/pscdataapi/config/WebSecurityConfig.java +++ b/src/main/java/uk/gov/companieshouse/pscdataapi/config/WebSecurityConfig.java @@ -10,6 +10,7 @@ import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.csrf.CsrfFilter; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import uk.gov.companieshouse.api.filter.CustomCorsFilter; @@ -26,6 +27,11 @@ public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(userAuthenticationInterceptor()); } + @Override + public void configurePathMatch(PathMatchConfigurer configurer) { + configurer.setUseTrailingSlashMatch(true); + } + @Bean public InternalUserInterceptor internalUserInterceptor() { return new InternalUserInterceptor(); diff --git a/src/test/java/uk/gov/companieshouse/pscdataapi/controller/CompanyPscControllerTest.java b/src/test/java/uk/gov/companieshouse/pscdataapi/controller/CompanyPscControllerTest.java index 06d7ec16..2a2f5a07 100644 --- a/src/test/java/uk/gov/companieshouse/pscdataapi/controller/CompanyPscControllerTest.java +++ b/src/test/java/uk/gov/companieshouse/pscdataapi/controller/CompanyPscControllerTest.java @@ -753,6 +753,25 @@ void callPscListGetRequestWithParams() throws Exception { .andExpect(status().isOk()); } + @Test + void callPscListGetRequestWithTrailingSlash() throws Exception { + when(companyPscService.retrievePscListSummaryFromDb(MOCK_COMPANY_NUMBER, 2, false, 5)) + .thenReturn(new PscList()); + + mockMvc.perform(MockMvcRequestBuilders + .get(GET_List_Summary_URL+"/") + .contentType(MediaType.APPLICATION_JSON) + .header("ERIC-Identity", ERIC_IDENTITY) + .header("ERIC-Identity-Type", ERIC_IDENTITY_TYPE) + .contentType(APPLICATION_JSON) + .header("x-request-id", X_REQUEST_ID) + .header("ERIC-Authorised-Key-Roles", ERIC_PRIVILEGES) + .header("ERIC-Authorised-Key-Privileges", ERIC_AUTH) + .header("items_per_page", 5) + .header("start_index", 2)) + .andExpect(status().isOk()); + } + @Test void callPscListGetRequestWithRegisterView() throws Exception { when(companyPscService.retrievePscListSummaryFromDb(MOCK_COMPANY_NUMBER, 2, true, 5))