Skip to content

Commit

Permalink
Merge branch 'master' into feat/CIV-8905
Browse files Browse the repository at this point in the history
  • Loading branch information
manish14836 committed Nov 27, 2023
2 parents 5be0087 + e892ae7 commit de1cda1
Show file tree
Hide file tree
Showing 151 changed files with 4,461 additions and 2,591 deletions.
10 changes: 7 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ sonarqube {
property "sonar.projectKey", "civil-service"
property "sonar.coverage.jacoco.xmlReportPaths", "${jacocoTestReport.reports.xml.destination.path}"
property "sonar.coverage.exclusions", "**/model/**, **/config/**/*Configuration.java, **/testingsupport/**, **/*ExternalTaskListener.java, **/*BaseExternalTaskHandler.java, **/stereotypes/**, **/*Exception.java, **/EventHistoryMapper*.java, **/model/hearingvalues/**, **/enums/hearing/**, **/fees/client/**, **/enums/sdo/**, **/service/PaymentsService.java"
property "sonar.cpd.exclusions", "**/*DocumentManagementService.java, **/*Spec*.java"
property "sonar.cpd.exclusions", "**/*DocumentManagementService.java, **/*Spec*.java, **/*CcdDashboardClaimantClaimMatcher.java"
property "sonar.exclusions", "**/hmc/model/**, **/model/hearingvalues/**"
property "sonar.host.url", "https://sonar.reform.hmcts.net/"
}
Expand Down Expand Up @@ -369,7 +369,7 @@ configurations.all {
}

dependencies {
implementation 'com.github.hmcts:civil-commons:1.0.33'
implementation 'com.github.hmcts:civil-commons:1.0.35'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-aop'
Expand All @@ -396,7 +396,7 @@ dependencies {
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-openfeign'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-openfeign-core'
implementation group: 'uk.gov.hmcts.reform', name: 'properties-volume-spring-boot-starter', version: '0.1.0'
implementation group: 'uk.gov.hmcts.reform', name: 'service-auth-provider-client', version: '4.0.0'
implementation group: 'uk.gov.hmcts.reform', name: 'service-auth-provider-client', version: '4.0.3'

implementation group: 'io.github.openfeign', name: 'feign-httpclient', version: '12.4'
implementation group: 'org.springframework.retry', name: 'spring-retry'
Expand Down Expand Up @@ -496,6 +496,10 @@ dependencies {
integrationTestImplementation sourceSets.main.runtimeClasspath
integrationTestImplementation sourceSets.test.runtimeClasspath

// https://mvnrepository.com/artifact/com.opencsv/opencsv
implementation group: 'com.opencsv', name: 'opencsv', version: '5.8', {
exclude group: 'commons-collections', module: 'commons-collections'
}
}

mainClassName = 'uk.gov.hmcts.reform.civil.Application'
Expand Down
2 changes: 1 addition & 1 deletion charts/civil-service/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
description: A Helm chart for civil-service App
name: civil-service
home: https://github.com/hmcts/civil-service
version: 0.0.52
version: 0.0.53
maintainers:
- name: HMCTS Civil team

Expand Down
1 change: 1 addition & 0 deletions charts/civil-service/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ java:
ASYNC_HANDLER_CORE_POOL_SIZE: 7
ASYNC_HANDLER_MAX_POOL_SIZE: 42
ASYNC_HANDLER_QUEUE_CAPACITY: 10
CIVIL_S2S_AUTHORISED_SERVICES: payment_app,ccd_data,civil_service,civil-citizen-ui

keyVaults:
civil:
Expand Down
4 changes: 4 additions & 0 deletions config/owasp/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,9 @@
<cve>CVE-2023-5072</cve>
<cve>CVE-2023-44487</cve>
</suppress>
<suppress until="2024-04-04">
<cve>CVE-2023-36052</cve>
</suppress>


</suppressions>
Binary file modified docker/docmosis/templates/CV-UNS-GAP-ENG-01070.docx
Binary file not shown.
Binary file modified docker/docmosis/templates/CV-UNS-GAP-ENG-01071.docx
Binary file not shown.
Binary file modified docker/docmosis/templates/CV-UNS-HNO-ENG-01196.docx
Binary file not shown.
Binary file modified docker/docmosis/templates/CV-UNS-HNO-ENG-01197.docx
Binary file not shown.
Binary file modified docker/docmosis/templates/CV-UNS-HNO-ENG-01198.docx
Binary file not shown.
Binary file modified docker/docmosis/templates/CV-UNS-HNO-ENG-01200.docx
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
64 changes: 63 additions & 1 deletion infrastructure/tf-kv-secrets-cmc.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,66 @@ resource "azurerm_key_vault_secret" "civil_db_password__v11_secret" {
depends_on = [
module.key-vault
]
}
}

data "azurerm_key_vault_secret" "db_password_v15_secret" {
key_vault_id = data.azurerm_key_vault.cmc_vault.id
name = "cmc-db-password-v15"
}

resource "azurerm_key_vault_secret" "civil_db_password__v15_secret" {
name = "cmc-db-password-v15"
value = data.azurerm_key_vault_secret.db_password_v15_secret.value
key_vault_id = module.key-vault.key_vault_id

content_type = "secret"
tags = merge(var.common_tags, {
"source" : "Vault ${data.azurerm_key_vault.cmc_vault.name}"
})

depends_on = [
module.key-vault
]
}

data "azurerm_key_vault_secret" "db_username_v15_secret" {
key_vault_id = data.azurerm_key_vault.cmc_vault.id
name = "cmc-db-username-v15"
}

resource "azurerm_key_vault_secret" "civil_db_username__v15_secret" {
name = "cmc-db-username-v15"
value = data.azurerm_key_vault_secret.db_username_v15_secret.value
key_vault_id = module.key-vault.key_vault_id

content_type = "secret"
tags = merge(var.common_tags, {
"source" : "Vault ${data.azurerm_key_vault.cmc_vault.name}"
})

depends_on = [
module.key-vault
]
}

data "azurerm_key_vault_secret" "db_host_v15_secret" {
key_vault_id = data.azurerm_key_vault.cmc_vault.id
name = "cmc-db-host-v15"
}

resource "azurerm_key_vault_secret" "civil_db_host__v15_secret" {
name = "cmc-db-host-v15"
value = data.azurerm_key_vault_secret.db_host_v15_secret.value
key_vault_id = module.key-vault.key_vault_id

content_type = "secret"
tags = merge(var.common_tags, {
"source" : "Vault ${data.azurerm_key_vault.cmc_vault.name}"
})

depends_on = [
module.key-vault
]
}


Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ void setUp() {
@Test
@SneakyThrows
void shouldGeneratePact_whenCaseTakenOffline() {
when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(true);

CaseData caseData = CaseDataBuilder.builder()
.atState(FlowState.Main.TAKEN_OFFLINE_AFTER_CLAIM_NOTIFIED)
.legacyCaseReference("100DC001")
Expand All @@ -110,8 +108,6 @@ void shouldGeneratePact_whenCaseTakenOffline() {
@Test
@SneakyThrows
void shouldGeneratePact_whenCaseDismissed() {
when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(true);

CaseData caseData = CaseDataBuilder.builder()
.atState(FlowState.Main.CLAIM_DISMISSED_PAST_CLAIM_NOTIFICATION_DEADLINE)
.legacyCaseReference("100DC001")
Expand All @@ -131,8 +127,6 @@ void shouldGeneratePact_whenCaseDismissed() {
@Test
@SneakyThrows
void shouldGeneratePact_whenNoticeOfChangeAndCaseTakenOffline() {
when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(true);

CaseData caseData = CaseDataBuilder.builder()
.atState(FlowState.Main.TAKEN_OFFLINE_AFTER_CLAIM_NOTIFIED)
.legacyCaseReference("100DC001")
Expand Down Expand Up @@ -163,8 +157,6 @@ void shouldGeneratePact_whenNoticeOfChangeAndCaseTakenOffline() {
@Test
@SneakyThrows
void shouldGeneratePact_whenNoticeOfChangeAndCaseDismissed() {
when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(true);

CaseData caseData = CaseDataBuilder.builder()
.atState(FlowState.Main.CLAIM_DISMISSED_PAST_CLAIM_NOTIFICATION_DEADLINE)
.legacyCaseReference("100DC001")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,6 @@ void shouldGeneratePact_whenClaimAgainstUnrepresentedDefendantWithMinimalData_wi

@Nested
class UnrepresentedAndUnregisteredDefendant {
@BeforeEach
public void setup() {
when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(true);
}

@Test
@SneakyThrows
Expand All @@ -235,30 +231,6 @@ void shouldGeneratePact_whenClaimAgainstUnrepresentedAndUnregisteredDefendant()

assertEquals(PactVerificationResult.Ok.INSTANCE, result);
}

@Nested
class ToBeRemovedAfterNoc {
@Test
@SneakyThrows
void shouldGeneratePact_whenClaimAgainstUnrepresentedAndUnregisteredDefendant() {
when(featureToggleService.isNoticeOfChangeEnabled()).thenReturn(false);

CaseData caseData = CaseDataBuilder.builder()
.atState(FlowState.Main.TAKEN_OFFLINE_UNREPRESENTED_UNREGISTERED_DEFENDANT)
.respondent1OrganisationPolicy(null)
.respondent2OrganisationPolicy(null)
.legacyCaseReference("000DC047")
.build();
String payload = roboticsDataMapper.toRoboticsCaseData(caseData, BEARER_TOKEN).toJsonString();

assertThat(payload, validateJson());

String description = "Robotics case data for claim against unrepresented and unregistered defendant";
PactVerificationResult result = getPactVerificationResult(payload, description);

assertEquals(PactVerificationResult.Ok.INSTANCE, result);
}
}
}

@Nested
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.ResultActions;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import uk.gov.hmcts.reform.authorisation.ServiceAuthorisationApi;
import uk.gov.hmcts.reform.civil.Application;
import uk.gov.hmcts.reform.civil.TestIdamConfiguration;
import uk.gov.hmcts.reform.civil.service.AuthorisationService;
import uk.gov.hmcts.reform.civil.service.UserService;
import uk.gov.hmcts.reform.idam.client.models.UserInfo;

Expand Down Expand Up @@ -61,6 +63,9 @@ public abstract class BaseIntegrationTest {
.roles(of("caseworker-civil-solicitor"))
.build();

private static final String s2sToken = "s2s AuthToken";
@MockBean
private ServiceAuthorisationApi serviceAuthorisationApi;
@MockBean
protected UserService userService;
@MockBean
Expand All @@ -69,6 +74,8 @@ public abstract class BaseIntegrationTest {
protected SecurityContext securityContext;
@MockBean
protected JwtDecoder jwtDecoder;
@MockBean
public AuthorisationService authorisationService;

@Autowired
protected ObjectMapper objectMapper;
Expand All @@ -78,11 +85,13 @@ public abstract class BaseIntegrationTest {

@BeforeEach
public void setUpBase() {
when(authorisationService.isServiceAuthorized(any())).thenReturn(true);
when(userService.getAccessToken(any(), any())).thenReturn("arbitrary access token");
when(userService.getUserInfo(anyString())).thenReturn(USER_INFO);
when(securityContext.getAuthentication()).thenReturn(authentication);
SecurityContextHolder.setContext(securityContext);
setSecurityAuthorities(authentication);
when(serviceAuthorisationApi.getServiceName(any())).thenReturn("payment_app");
when(jwtDecoder.decode(anyString())).thenReturn(getJwt());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.ResultActions;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
Expand All @@ -22,6 +23,7 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

class ServiceRequestUpdateCallbackControllerTest extends BaseIntegrationTest {
Expand All @@ -31,6 +33,7 @@ class ServiceRequestUpdateCallbackControllerTest extends BaseIntegrationTest {
private static final String PAID = "Paid";
private static final String REFERENCE = "reference";
private static final String ACCOUNT_NUMBER = "123445555";
private static final String s2sToken = "s2s AuthToken";

@MockBean
CoreCaseDataApi coreCaseDataApi;
Expand All @@ -40,6 +43,7 @@ class ServiceRequestUpdateCallbackControllerTest extends BaseIntegrationTest {

@BeforeEach
void bareMinimumToMakeAPositiveRequest() {
when(authorisationService.isServiceAuthorized(any())).thenReturn(true);
CaseData caseData = CaseData.builder().businessProcess(BusinessProcess.builder().processInstanceId("instance").camundaEvent("camunda event").build()).build();
CaseDetails caseDetails = CaseDetails.builder().build();
caseDetails.setData(caseData.toMap(objectMapper));
Expand All @@ -51,6 +55,30 @@ void bareMinimumToMakeAPositiveRequest() {
given(coreCaseDataApi.submitEventForCaseWorker(any(), any(), any(), any(), any(), any(), anyBoolean(), any())).willReturn(caseDetails);
}

@Test
public void whenValidPaymentCallbackIsReceivedReturnSuccess() throws Exception {
doPut(buildServiceDto(), PAYMENT_CALLBACK_URL, "")
.andExpect(status().isOk());
}

@Test
public void whenPaymentCallbackIsReceivedWithoutServiceAuthorisationReturn400() throws Exception {
mockMvc.perform(
MockMvcRequestBuilders.put(PAYMENT_CALLBACK_URL, "")
.contentType(MediaType.APPLICATION_JSON)
.content(toJson(buildServiceDto()))).andExpect(status().is4xxClientError());
}

@Test
public void whenPaymentCallbackIsReceivedWithServiceAuthorisationButreturnsfalseReturn400() throws Exception {
when(authorisationService.isServiceAuthorized(any())).thenReturn(false);
mockMvc.perform(
MockMvcRequestBuilders.put(PAYMENT_CALLBACK_URL, "")
.header("ServiceAuthorization", s2sToken)
.contentType(MediaType.APPLICATION_JSON)
.content(toJson(buildServiceDto()))).andExpect(status().is5xxServerError());
}

@Test
public void whenInvalidTypeOfRequestMade_ReturnMethodNotAllowed() throws Exception {

Expand Down Expand Up @@ -96,6 +124,8 @@ private ServiceRequestUpdateDto buildServiceDto() {
protected <T> ResultActions doPut(T content, String urlTemplate, Object... uriVars) {
return mockMvc.perform(
MockMvcRequestBuilders.put(urlTemplate, uriVars)
.header(HttpHeaders.AUTHORIZATION, BEARER_TOKEN)
.header("ServiceAuthorization", "s2s AuthToken")
.contentType(MediaType.APPLICATION_JSON)
.content(toJson(content)));
}
Expand All @@ -104,6 +134,8 @@ protected <T> ResultActions doPut(T content, String urlTemplate, Object... uriVa
protected <T> ResultActions doPost(T content, String urlTemplate, Object... uriVars) {
return mockMvc.perform(
MockMvcRequestBuilders.post(urlTemplate, uriVars)
.header(HttpHeaders.AUTHORIZATION, BEARER_TOKEN)
.header("ServiceAuthorization", "s2s AuthToken")
.contentType(MediaType.APPLICATION_JSON)
.content(toJson(content)));
}
Expand Down
Loading

0 comments on commit de1cda1

Please sign in to comment.