Skip to content

Commit

Permalink
DTSSTCI-908: Review and merge renovate PRs for Case API (#1840)
Browse files Browse the repository at this point in the history
  • Loading branch information
rajaram-nagarajan authored Jul 23, 2024
1 parent f111e78 commit 7cea84f
Show file tree
Hide file tree
Showing 18 changed files with 131 additions and 180 deletions.
29 changes: 14 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ plugins {
id 'io.spring.dependency-management' version '1.1.5'
id 'org.springframework.boot' version '3.2.5'
id 'com.github.ben-manes.versions' version '0.50.0'
id 'hmcts.ccd.sdk' version '5.5.2'
id 'hmcts.ccd.sdk' version '5.5.10'
id "au.com.dius.pact" version "4.3.10"
id 'com.github.hmcts.rse-cft-lib' version '0.19.1253'
id 'com.github.hmcts.rse-cft-lib' version '0.19.1307'
}

apply plugin: 'cz.habarta.typescript-generator'
Expand Down Expand Up @@ -393,7 +393,7 @@ dependencyManagement {
}

//CVE-2022-31692, CVE-2022-31690
dependencySet(group: 'org.springframework.security', version: '6.2.2'){
dependencySet(group: 'org.springframework.security', version: '6.2.4'){
entry 'spring-security-core'
entry 'spring-security-acl'
entry 'spring-security-aspects'
Expand All @@ -417,7 +417,7 @@ dependencyManagement {
}

//Override spring-security-rsa version and update org.bouncycastle:bcpkix-jdk18on for CVE-2023-33202
dependency group:'org.springframework.security', name: 'spring-security-rsa', version: '1.1.1'
dependency group:'org.springframework.security', name: 'spring-security-rsa', version: '1.1.3'
dependency group: 'org.bouncycastle', name: 'bcpkix-jdk18on', version: '1.77'
dependency group: 'org.camunda.connect', name: 'camunda-connect-connectors-all', version: '1.6.0'

Expand All @@ -438,7 +438,7 @@ def versions = [
jackson : '2.16.0',
junit : '5.10.3',
junitPlatform : '1.10.3',
lombok : '1.18.32',
lombok : '1.18.34',
pact : '4.1.34',
springBoot : springBoot.class.package.implementationVersion
]
Expand Down Expand Up @@ -470,20 +470,20 @@ dependencies {

implementation 'io.swagger:swagger-annotations:1.6.14'
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'
implementation group: 'org.apache.groovy', name: 'groovy', version: '4.0.21'
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.4.12'
implementation group: 'ch.qos.logback', name: 'logback-core', version: '1.4.12'
implementation group: 'org.apache.groovy', name: 'groovy', version: '4.0.22'
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.5.6'
implementation group: 'ch.qos.logback', name: 'logback-core', version: '1.5.6'
implementation group: 'com.github.hmcts', name: 'ccd-client', version: '4.9.2'
implementation group: 'com.github.hmcts', name:'ccd-case-document-am-client', version: '1.59'
implementation group: 'com.github.hmcts', name: 'idam-java-client', version: '3.0.3'
implementation group: 'com.github.hmcts', name: 'java-logging', version: '6.1.5'
implementation group: 'com.github.hmcts', name: 'service-auth-provider-java-client', version: '5.1.2'
implementation group: 'com.github.hmcts', name: 'service-auth-provider-java-client', version: '5.1.3'
implementation group: 'net.logstash.logback', name: 'logstash-logback-encoder', version: '7.4'
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.22.0'
implementation group: 'org.apache.logging.log4j', name: 'log4j-to-slf4j', version: '2.22.0'
implementation group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: '10.1.24'
implementation group: 'org.apache.tomcat.embed', name: 'tomcat-embed-websocket', version: '10.1.20'
implementation group: 'org.elasticsearch', name: 'elasticsearch' , version: '7.17.6'
implementation group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: '10.1.26'
implementation group: 'org.apache.tomcat.embed', name: 'tomcat-embed-websocket', version: '10.1.23'
implementation group: 'org.elasticsearch', name: 'elasticsearch' , version: '7.17.22'
implementation group: 'org.projectlombok', name: 'lombok', version: versions.lombok
implementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-ui', version: '2.3.0'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web'
Expand All @@ -506,7 +506,7 @@ dependencies {
implementation 'org.camunda.bpm:camunda-external-task-client:7.21.0'

annotationProcessor group: 'org.projectlombok', name: 'lombok', version: versions.lombok
testImplementation 'com.github.hmcts:fortify-client:1.3.0:all'
testImplementation 'com.github.hmcts:fortify-client:1.4.3:all'

testImplementation libraries.junit5
testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test', {
Expand Down Expand Up @@ -548,8 +548,7 @@ dependencies {
functionalTestImplementation group: 'com.github.hmcts', name: 'document-management-client', version: '7.0.1'
functionalTestImplementation group: 'com.github.hmcts', name: 'service-auth-provider-java-client', version: '5.1.2'

contractTestImplementation group: 'au.com.dius.pact.consumer', name: 'junit5', version: '4.1.41'
contractTestImplementation group: 'au.com.dius.pact.consumer', name: 'java8', version: '4.1.43'
contractTestImplementation group: 'au.com.dius.pact.consumer', name: 'junit5', version: '4.6.11'
contractTestImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.10.3'
contractTestRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.10.3'
contractTestImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.10.3'
Expand Down
21 changes: 11 additions & 10 deletions src/contractTest/java/uk.gov.hmcts.sptribs/IdamConsumerTest.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package uk.gov.hmcts.sptribs;

import au.com.dius.pact.consumer.MockServer;
import au.com.dius.pact.consumer.dsl.DslPart;
import au.com.dius.pact.consumer.dsl.PactDslJsonBody;
import au.com.dius.pact.consumer.dsl.PactDslWithProvider;
import au.com.dius.pact.consumer.junit5.PactConsumerTestExt;
import au.com.dius.pact.consumer.junit5.PactTestFor;
import au.com.dius.pact.core.model.RequestResponsePact;
import au.com.dius.pact.core.model.V4Pact;
import au.com.dius.pact.core.model.annotations.Pact;
import au.com.dius.pact.core.model.annotations.PactDirectory;
import io.restassured.RestAssured;
Expand All @@ -19,18 +19,18 @@

import java.util.Map;

import static io.pactfoundation.consumer.dsl.LambdaDsl.newJsonBody;
import static org.springframework.http.HttpMethod.GET;
import static org.springframework.http.HttpStatus.OK;

@ExtendWith(PactConsumerTestExt.class)
@ExtendWith(SpringExtension.class)
@PactDirectory("pacts")
class IdamConsumerTest {

private static final String IDAM_USER_DETAILS = "/details";

@Pact(provider = "idam_user_details", consumer = "sptribs-case-api")
RequestResponsePact executeIdamUserDetailApi(PactDslWithProvider builder) {
V4Pact executeIdamUserDetailApi(PactDslWithProvider builder) {
Map<String, String> responseHeaders = Map.of(HttpHeaders.AUTHORIZATION, "Bearer UserAuthToken");

return builder
Expand All @@ -42,13 +42,12 @@ RequestResponsePact executeIdamUserDetailApi(PactDslWithProvider builder) {
.status(OK.value())
.headers(responseHeaders)
.body(createAuthResponse())
.toPact();
.toPact(V4Pact.class);
}

@Test
@PactTestFor(pactMethod = "executeIdamUserDetailApi")
void shouldReceiveUserDetails(MockServer mockServer) {

String responseBody = RestAssured
.given()
.contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE)
Expand All @@ -65,13 +64,15 @@ void shouldReceiveUserDetails(MockServer mockServer) {
Assertions.assertThat(response).isNotNull();
}

private DslPart createAuthResponse() {
return newJsonBody((o) -> o.stringType("id",
"123432")
private PactDslJsonBody createAuthResponse() {
return new PactDslJsonBody()
.stringType("id", "123432")
.stringType("forename", "Joe")
.stringType("surname", "Bloggs")
.stringType("email", "joe.bloggs@hmcts.net")
.booleanType("active", true)
.array("roles", role -> role.stringType("caseworker").stringType("citizen"))).build();
.minArrayLike("roles", 2)
.stringType("caseworker")
.stringType("citizen");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import java.util.Map;


@Data
@Builder(toBuilder = true)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand All @@ -17,7 +16,6 @@ public class ExtendedCaseDetails {

private Long id;

@JsonProperty("data_classification")
@JsonProperty("dataClassification")
private Map<String, Object> dataClassification;
}

Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public class HearingDate {

@JsonCreator
public HearingDate(@JsonProperty("hearingVenueDate") LocalDate hearingVenueDate,
@JsonProperty("session") HearingSession hearingVenueSession,
@JsonProperty("hearingTime") String hearingVenueTime) {
@JsonProperty("hearingVenueSession") HearingSession hearingVenueSession,
@JsonProperty("hearingVenueTime") String hearingVenueTime) {
this.hearingVenueDate = hearingVenueDate;
this.hearingVenueSession = hearingVenueSession;
this.hearingVenueTime = hearingVenueTime;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
package uk.gov.hmcts.sptribs.common.config.jackson;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import uk.gov.hmcts.ccd.sdk.api.HasRole;
import uk.gov.hmcts.reform.ccd.document.am.healthcheck.InternalHealth;

import static com.fasterxml.jackson.annotation.JsonCreator.Mode.PROPERTIES;
import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
import static com.fasterxml.jackson.core.JsonParser.Feature.INCLUDE_SOURCE_IN_LOCATION;
import static com.fasterxml.jackson.databind.MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS;
import static com.fasterxml.jackson.databind.MapperFeature.INFER_BUILDER_TYPE_BINDINGS;
import static com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer.INSTANCE;

@Configuration
public class JacksonConfiguration {
Expand All @@ -24,7 +27,7 @@ public ObjectMapper getMapper() {
ObjectMapper mapper = JsonMapper.builder()
.configure(ACCEPT_CASE_INSENSITIVE_ENUMS, true)
.enable(INFER_BUILDER_TYPE_BINDINGS)
.serializationInclusion(JsonInclude.Include.NON_NULL)
.serializationInclusion(NON_NULL)
.build();

SimpleModule deserialization = new SimpleModule();
Expand All @@ -33,8 +36,10 @@ public ObjectMapper getMapper() {
mapper.registerModule(deserialization);

JavaTimeModule datetime = new JavaTimeModule();
datetime.addSerializer(LocalDateSerializer.INSTANCE);
datetime.addSerializer(INSTANCE);
mapper.registerModule(datetime);
mapper.registerModule(new ParameterNamesModule(PROPERTIES));
mapper.enable(INCLUDE_SOURCE_IN_LOCATION);

return mapper;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import uk.gov.hmcts.ccd.sdk.api.CaseDetails;
import uk.gov.hmcts.ccd.sdk.api.callback.AboutToStartOrSubmitResponse;
Expand All @@ -25,11 +22,7 @@
import static uk.gov.hmcts.sptribs.testutil.TestConstants.TEST_CASE_ID;
import static uk.gov.hmcts.sptribs.testutil.TestDataHelper.caseData;


@ExtendWith(SpringExtension.class)
@SpringBootTest
@TestPropertySource("classpath:application.yaml")
@ActiveProfiles("test")
class CicCreateCaseEventTest {

@InjectMocks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import uk.gov.hmcts.ccd.sdk.ConfigBuilderImpl;
import uk.gov.hmcts.ccd.sdk.api.CaseDetails;
import uk.gov.hmcts.ccd.sdk.api.Event;
Expand Down Expand Up @@ -65,9 +62,6 @@
import static uk.gov.hmcts.sptribs.testutil.TestFileUtil.loadJson;

@ExtendWith({MockitoExtension.class})
@SpringBootTest
@TestPropertySource("classpath:application.yaml")
@ActiveProfiles("test")
class CicSubmitCaseEventTest {
final ConfigBuilderImpl<CaseData, State, UserRole> configBuilder = createCaseDataConfigBuilder();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import uk.gov.hmcts.ccd.sdk.ConfigBuilderImpl;
import uk.gov.hmcts.ccd.sdk.api.Event;
Expand All @@ -28,9 +25,6 @@
import static uk.gov.hmcts.sptribs.testutil.TestConstants.CASE_DATA_CIC_ID;

@ExtendWith(SpringExtension.class)
@SpringBootTest
@TestPropertySource("classpath:application.yaml")
@ActiveProfiles("test")
class CicUpdateCaseEventTest {
@InjectMocks
private CicUpdateCaseEvent cicUpdateCaseEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import uk.gov.hmcts.sptribs.ciccase.model.CaseData;
import uk.gov.hmcts.sptribs.ciccase.model.DssCaseData;
Expand Down Expand Up @@ -43,9 +41,8 @@
import static uk.gov.hmcts.sptribs.testutil.TestFileUtil.loadJson;

@ExtendWith(SpringExtension.class)
@SpringBootTest
@ActiveProfiles("test")
class CaseManagementControllerTest {

private final ObjectMapper mapper = new ObjectMapper().registerModule(new JavaTimeModule());

@InjectMocks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import uk.gov.hmcts.sptribs.exception.DocumentUploadOrDeleteException;
import uk.gov.hmcts.sptribs.model.DocumentInfo;
Expand Down Expand Up @@ -40,11 +37,7 @@
import static uk.gov.hmcts.sptribs.testutil.TestConstants.TEST_URL;
import static uk.gov.hmcts.sptribs.testutil.TestFileUtil.loadJson;


@ExtendWith(SpringExtension.class)
@SpringBootTest
@TestPropertySource("classpath:application.yaml")
@ActiveProfiles("test")
class DocumentManagementControllerTest {

@InjectMocks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import uk.gov.hmcts.sptribs.ciccase.model.CaseData;
import uk.gov.hmcts.sptribs.ciccase.model.DssCaseData;
Expand All @@ -32,8 +30,6 @@
import static uk.gov.hmcts.sptribs.testutil.TestFileUtil.loadJson;

@ExtendWith(SpringExtension.class)
@SpringBootTest
@ActiveProfiles("test")
class CaseCreateOrUpdateExceptionTest {

private final ObjectMapper mapper = new ObjectMapper().registerModule(new JavaTimeModule());
Expand All @@ -51,7 +47,6 @@ void setUp() {

@Test
void createCaseDataCaseCreateUpdateException() throws IOException {

final String createCaseTestAuth = CASE_TEST_AUTHORIZATION;
final String caseDataJson = loadJson(CASE_DATA_FILE_CIC);
final DssCaseData dssCaseData = mapper.readValue(caseDataJson, DssCaseData.class);
Expand All @@ -69,7 +64,6 @@ void createCaseDataCaseCreateUpdateException() throws IOException {

@Test
void updateCaseDataCaseCreateUpdateException() throws IOException {

final String updateCaseTestAuth = CASE_TEST_AUTHORIZATION;
final String caseDataJson = loadJson(CASE_DATA_FILE_CIC);
final CaseData caseData = mapper.readValue(caseDataJson, CaseData.class);
Expand All @@ -87,7 +81,6 @@ void updateCaseDataCaseCreateUpdateException() throws IOException {

@Test
void fetchCaseDataCaseCreateUpdateException() {

final String fetchCaseTestAuth = CASE_TEST_AUTHORIZATION;

when(caseManagementService.fetchCaseDetails(fetchCaseTestAuth,TEST_CASE_ID))
Expand Down
Loading

0 comments on commit 7cea84f

Please sign in to comment.