Skip to content
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

Spring Boot 3 Upgrade #2479

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6cfd338
Spring Boot 3 Upgrade pt1
lang-ben Sep 27, 2024
a7be58a
Spring boot upgrade part 2
lang-ben Oct 7, 2024
fd326e0
Fix NumberFormatException not getting caught and timeout issue
lang-ben Oct 8, 2024
6979648
Merge branch 'master' of https://github.com/hmcts/ccd-data-store-api …
lang-ben Oct 9, 2024
060d00b
Merge branch 'master' of https://github.com/hmcts/ccd-data-store-api …
lang-ben Oct 9, 2024
83fddb0
Test fixes andd suppressions
lang-ben Oct 10, 2024
4ee6485
Additional SupplementaryDataUserType tests
lang-ben Oct 10, 2024
49cbc05
Fix exception matching for SupplementaryDataUserTypeTest
lang-ben Oct 10, 2024
49947fb
fix whitespace issue
lang-ben Oct 10, 2024
092ba9f
Merge branch 'master' into CCD-5269
lang-ben Oct 10, 2024
03c53cd
Merge branch 'master' into CCD-5269
lang-ben Oct 11, 2024
cd65e83
fix healthcheck diskspace path issue
lang-ben Oct 14, 2024
fa20316
Merge branch 'CCD-5269' of https://github.com/hmcts/ccd-data-store-ap…
lang-ben Oct 14, 2024
e610542
fix case mgmt healthcheck
lang-ben Oct 14, 2024
b0e8133
Merge branch 'master' into CCD-5269
lang-ben Nov 1, 2024
a263a50
Fix tests
lang-ben Nov 2, 2024
40ceff6
Remove version restrictions
lang-ben Nov 2, 2024
385b426
exclude codehaus.groovy
lang-ben Nov 4, 2024
cacec70
Merge branch 'master' of https://github.com/hmcts/ccd-data-store-api …
lang-ben Jan 9, 2025
c1ba893
SpringBoot3.4
lang-ben Jan 21, 2025
d8b42ba
Merge branch 'master' of https://github.com/hmcts/ccd-data-store-api …
lang-ben Jan 21, 2025
17c0b9c
Fix checkstyle
lang-ben Jan 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
427 changes: 145 additions & 282 deletions build.gradle

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyString;
import static org.hamcrest.Matchers.emptyString;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue;
import static uk.gov.hmcts.ccd.datastore.tests.fixture.AATCaseType.CASE_TYPE;
Expand Down Expand Up @@ -46,7 +46,7 @@ void shouldRetrieveWhenExists() {

// Metadata
.body("id", equalTo(CREATE))
.body("event_token", is(not(isEmptyString())))
.body("event_token", is(not(emptyString())))
.body("name", is(CREATE_NAME))
.body("description", is(nullValue()))
.body("case_id", is(nullValue()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"expectedResponse": {
"_extends_": "Common_400_Response",
"body": {
"exception": "javax.validation.ConstraintViolationException",
"exception": "jakarta.validation.ConstraintViolationException",
"message": "createCase.caseTypeId: Case Type Id is invalid",
"path" : "/case-types/BEFTA_%2526%255E%2524%25C2%25A3CASETYPE_2_1/cases",
"details": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"total": "[[ANYTHING_PRESENT]]",
"free": "[[ANYTHING_PRESENT]]",
"threshold": "[[ANYTHING_PRESENT]]",
"path": "[[ANYTHING_PRESENT]]",
"exists": true
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.test.util.ReflectionTestUtils;

import javax.inject.Inject;
import jakarta.inject.Inject;
import java.io.IOException;

@AutoConfigureWireMock(port = 0)
public abstract class WireMockBaseTest {
public abstract class WireMockBaseContractTest {

private static final Logger LOG = LoggerFactory.getLogger(WireMockBaseTest.class);
private static final Logger LOG = LoggerFactory.getLogger(WireMockBaseContractTest.class);

@Value("${wiremock.server.port}")
protected Integer wiremockPort;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import uk.gov.hmcts.ccd.WireMockBaseTest;
import uk.gov.hmcts.ccd.WireMockBaseContractTest;
import uk.gov.hmcts.ccd.auditlog.AuditService;
import uk.gov.hmcts.ccd.data.casedetails.query.UserAuthorisationSecurity;
import uk.gov.hmcts.ccd.domain.model.definition.CaseDetails;
Expand Down Expand Up @@ -55,7 +55,7 @@
@TestPropertySource(locations = "/application.properties")
@ActiveProfiles("SECURITY_MOCK")
@IgnoreNoPactsToVerify
public class CasesControllerProviderTest extends WireMockBaseTest {
public class CasesControllerProviderTest extends WireMockBaseContractTest {

private static final String CASEWORKER_USERNAME = "caseworkerUsername";
private static final String CASEWORKER_PASSWORD = "caseworkerPassword";
Expand All @@ -66,58 +66,41 @@ public class CasesControllerProviderTest extends WireMockBaseTest {

@Autowired
ContractTestSecurityUtils securityUtils;

@MockBean
@MockitoBean
UserAuthorisationSecurity userAuthorisationSecurity;

@Autowired
ContractTestCreateCaseOperation contractTestCreateCaseOperation;

@Autowired
ContractTestGetCaseOperation getCaseOperation;

@Autowired
ContractTestStartEventOperation startEventOperation;

@Autowired
ObjectMapper objectMapper;

@MockBean
@MockitoBean
EventTokenService eventTokenServiceMock;

@MockBean
@MockitoBean
DocumentSanitiser documentSanitiser;

@Autowired
ContractTestCaseDefinitionRepository contractTestCaseDefinitionRepository;

@MockBean
@MockitoBean
AuthorisedCaseSearchOperation elasticsearchCaseSearchOperationMock;

@MockBean
@MockitoBean
AuthorisedSearchOperation authorisedSearchOperation;

@MockBean
@MockitoBean
UserAuthorisation userAuthorisation;

@MockBean
@MockitoBean
AuditService auditService;

@MockBean
@MockitoBean
CaseAccessService caseAccessService;
@MockBean
@MockitoBean
AccessControlService accessControlService;

@MockBean
@MockitoBean
TelemetryClient telemetryClient;

@Autowired
ContractTestCreateEventOperation createEventOperation;

@MockBean
@MockitoBean
CaseDataService caseDataService;

@MockBean
@MockitoBean
MessageService messageService;

@TestTemplate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package uk.gov.hmcts.ccd.v2.external.controller;

import javax.inject.Inject;
import jakarta.inject.Inject;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package uk.gov.hmcts.ccd.v2.external.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter;
import org.springframework.security.web.SecurityFilterChain;

import uk.gov.hmcts.ccd.data.SecurityUtils;
import uk.gov.hmcts.ccd.security.JwtGrantedAuthoritiesConverter;
import uk.gov.hmcts.ccd.security.filters.SecurityLoggingFilter;
Expand All @@ -18,15 +19,14 @@
import java.util.Collection;
import java.util.Optional;
import java.util.function.Function;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import jakarta.inject.Inject;
import jakarta.servlet.http.HttpServletRequest;


@Profile("SECURITY_MOCK")
@Configuration
@EnableWebSecurity
@Order(1)
public class SecurityMockConfiguration extends WebSecurityConfigurerAdapter {
public class SecurityMockConfiguration {


private final ServiceAuthFilter serviceAuthFilter;
Expand All @@ -49,10 +49,9 @@ public SecurityMockConfiguration(final JwtGrantedAuthoritiesConverter jwtGranted
jwtAuthenticationConverter.setJwtGrantedAuthoritiesConverter(jwtGrantedAuthoritiesConverter);
}


@Override
public void configure(WebSecurity web) {
web.ignoring().antMatchers(
@Bean
public WebSecurityCustomizer webSecurityCustomizer() {
return (web) -> web.ignoring().requestMatchers(
"/case-types/**",
"/caseworkers/**",
"/citizens/**",
Expand All @@ -61,14 +60,15 @@ public void configure(WebSecurity web) {
"/");
}

@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers(
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http.authorizeHttpRequests(ahr -> ahr.requestMatchers(
"/case-types/**",
"/caseworkers/**",
"/citizens/**",
"/searchCases/**",
"/cases/**"
).permitAll();
).permitAll());
return http.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public ClientRegistrationRepository clientRegistrationRepository() {

private ClientRegistration clientRegistration() {
return ClientRegistration.withRegistrationId("oidc")
.redirectUriTemplate("{baseUrl}/{action}/oauth2/code/{registrationId}")
.redirectUri("{baseUrl}/{action}/oauth2/code/{registrationId}")
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
.scope("read:user")
.authorizationUri("http://idam/o/authorize")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import uk.gov.hmcts.ccd.ApplicationParams;
import uk.gov.hmcts.ccd.WireMockBaseTest;
import uk.gov.hmcts.ccd.WireMockBaseContractTest;
import uk.gov.hmcts.ccd.data.SecurityUtils;
import uk.gov.hmcts.ccd.domain.model.std.CaseAssignedUserRole;
import uk.gov.hmcts.ccd.domain.service.caseaccess.CaseAccessOperation;
Expand All @@ -41,7 +41,7 @@
@ContextConfiguration(classes = {CaseAssignedUserRolesProviderTestContext.class, TestIdamConfiguration.class})
@IgnoreNoPactsToVerify
@ActiveProfiles("CASE_ASSIGNED")
public class CaseAssignedUserRolesProviderTest extends WireMockBaseTest {
public class CaseAssignedUserRolesProviderTest extends WireMockBaseContractTest {

@Autowired
ApplicationParams applicationParams;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package uk.gov.hmcts.ccd.v2.external.controller.caseassigned;

import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;
import org.springframework.test.context.bean.override.mockito.MockitoBean;

import uk.gov.hmcts.ccd.ApplicationParams;
import uk.gov.hmcts.ccd.data.SecurityUtils;
import uk.gov.hmcts.ccd.domain.service.caseaccess.CaseAccessOperation;
Expand All @@ -16,13 +17,13 @@
@Profile("CASE_ASSIGNED")
public class CaseAssignedUserRolesProviderTestContext {

@MockBean
@MockitoBean
ApplicationParams applicationParams;

@MockBean
@MockitoBean
SecurityUtils securityUtils;

@MockBean
@MockitoBean
CaseAccessOperation caseAccessOperation;

@Primary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@

@Provider("ccd_data_store_api_cases")
@PactBroker(
url = "${PACT_BROKER_FULL_URL:http://localhost:9292}",
host = "${PACT_BROKER_URL:localhost}",
port = "${PACT_BROKER_PORT:9292}",
consumerVersionSelectors = {@VersionSelector(tag = "master")})
@IgnoreNoPactsToVerify
@ExtendWith(SpringExtension.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package uk.gov.hmcts.reform.ccd.pactprovider.cases.controller;

import io.swagger.annotations.ApiParam;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
Expand Down Expand Up @@ -80,17 +80,17 @@ public ResponseEntity<CaseResource> getCase(@PathVariable("caseId") final String
path = "/citizens/{uid}/jurisdictions/{jid}/case-types/{ctid}/cases/{cid}/event-triggers/{etid}/token",
produces = APPLICATION_JSON_VALUE)
public ResponseEntity<StartEventResult> startEventForCitizen(
@ApiParam(value = "Idam user ID", required = true)
@Parameter(name = "Idam user ID", required = true)
@PathVariable("uid") final String uid,
@ApiParam(value = "Jurisdiction ID", required = true)
@Parameter(name = "Jurisdiction ID", required = true)
@PathVariable("jid") final String jurisdictionId,
@ApiParam(value = "Case type ID", required = true)
@Parameter(name = "Case type ID", required = true)
@PathVariable("ctid") final String caseTypeId,
@ApiParam(value = "Case ID", required = true)
@Parameter(name = "Case ID", required = true)
@PathVariable("cid") final String caseId,
@ApiParam(value = "Event ID", required = true)
@Parameter(name = "Event ID", required = true)
@PathVariable("etid") final String eventId,
@ApiParam(value = "Should `AboutToStart` callback warnings be ignored")
@Parameter(name = "Should `AboutToStart` callback warnings be ignored")
@RequestParam(value = "ignore-warning", required = false, defaultValue = "false") final Boolean ignoreWarning) {

StartEventResult startEventResult = startEventOperation.triggerStartForCase(caseId, eventId, ignoreWarning);
Expand All @@ -112,15 +112,15 @@ public ResponseEntity<StartEventResult> startEventForCitizen(
@GetMapping(path = "/citizens/{uid}/jurisdictions/{jid}/case-types/{ctid}/event-triggers/{etid}/token",
produces = APPLICATION_JSON_VALUE)
public ResponseEntity<StartEventResult> startCaseForCitizen(
@ApiParam(value = "Idam user ID", required = true)
@Parameter(name = "Idam user ID", required = true)
@PathVariable("uid") final String uid,
@ApiParam(value = "Jurisdiction ID", required = true)
@Parameter(name = "Jurisdiction ID", required = true)
@PathVariable("jid") final String jurisdictionId,
@ApiParam(value = "Case type ID", required = true)
@Parameter(name = "Case type ID", required = true)
@PathVariable("ctid") final String caseTypeId,
@ApiParam(value = "Event ID", required = true)
@Parameter(name = "Event ID", required = true)
@PathVariable("etid") final String eventId,
@ApiParam(value = "Should `AboutToStart` callback warnings be ignored")
@Parameter(name = "Should `AboutToStart` callback warnings be ignored")
@RequestParam(value = "ignore-warning", required = false, defaultValue = "false") final Boolean ignoreWarning) {

StartEventResult startEventResult = startEventOperation.triggerStartForCaseType(caseTypeId, eventId,
Expand All @@ -143,13 +143,13 @@ public ResponseEntity<StartEventResult> startCaseForCitizen(
@PostMapping(path = "/citizens/{uid}/jurisdictions/{jid}/case-types/{ctid}/cases/{cid}/events",
produces = APPLICATION_JSON_VALUE)
public ResponseEntity<CaseDetails> createCaseEventForCitizen(
@ApiParam(value = "Idam user ID", required = true)
@Parameter(name = "Idam user ID", required = true)
@PathVariable("uid") final String uid,
@ApiParam(value = "Jurisdiction ID", required = true)
@Parameter(name = "Jurisdiction ID", required = true)
@PathVariable("jid") final String jurisdictionId,
@ApiParam(value = "Case type ID", required = true)
@Parameter(name = "Case type ID", required = true)
@PathVariable("ctid") final String caseTypeId,
@ApiParam(value = "Case ID", required = true)
@Parameter(name = "Case ID", required = true)
@PathVariable("cid") final String caseId,
@RequestBody(required = false) final CaseDataContent content) {

Expand All @@ -172,13 +172,13 @@ public ResponseEntity<CaseDetails> createCaseEventForCitizen(
@PostMapping(path = "/citizens/{uid}/jurisdictions/{jid}/case-types/{ctid}/cases",
produces = APPLICATION_JSON_VALUE)
public ResponseEntity<CaseDetails> saveCaseDetailsForCitizen(
@ApiParam(value = "Idam user ID", required = true)
@Parameter(name = "Idam user ID", required = true)
@PathVariable("uid") final String uid,
@ApiParam(value = "Jurisdiction ID", required = true)
@Parameter(name = "Jurisdiction ID", required = true)
@PathVariable("jid") final String jurisdictionId,
@ApiParam(value = "Case type ID", required = true)
@Parameter(name = "Case type ID", required = true)
@PathVariable("ctid") final String caseTypeId,
@ApiParam(value = "Should `AboutToSubmit` callback warnings be ignored")
@Parameter(name = "Should `AboutToSubmit` callback warnings be ignored")
@RequestParam(value = "ignore-warning", required = false, defaultValue = "false") final Boolean ignoreWarning,
@RequestBody(required = false) final CaseDataContent content) {

Expand Down
Loading