Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into task/CIV-0000-addSe…
Browse files Browse the repository at this point in the history
…rviceAuth

# Conflicts:
#	src/main/java/uk/gov/hmcts/reform/civil/config/SecurityConfiguration.java
  • Loading branch information
sampankumar committed Nov 24, 2023
2 parents 0dd38c2 + dbbbd1f commit 165a12e
Show file tree
Hide file tree
Showing 72 changed files with 903 additions and 1,922 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ sonarqube {
property "sonar.projectName", "CIVIL :: service"
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.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, **/RetriggerCases*.java"
property "sonar.cpd.exclusions", "**/*DocumentManagementService.java, **/*Spec*.java"
property "sonar.exclusions", "**/hmc/model/**, **/model/hearingvalues/**"
property "sonar.host.url", "https://sonar.reform.hmcts.net/"
Expand Down
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.
2 changes: 1 addition & 1 deletion infrastructure/tf-kv-secrets-cmc.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ data "azurerm_key_vault_secret" "db_password_v15_secret" {
}

resource "azurerm_key_vault_secret" "civil_db_password__v15_secret" {
name = "cmc-db-username-v15"
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

Expand Down
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 @@ -94,6 +94,8 @@ public enum CaseEvent {
GENERATE_TRIAL_READY_DOCUMENT_RESPONDENT1(USER),
GENERATE_TRIAL_READY_DOCUMENT_RESPONDENT2(USER),
LIP_CLAIM_SETTLED(USER),
DEFENDANT_SIGN_SETTLEMENT_AGREEMENT(USER),
TRIGGER_TASK_RECONFIG(USER),
NOTIFY_FORMER_SOLICITOR(CAMUNDA),
NOTIFY_OTHER_SOLICITOR_1(CAMUNDA),
NOTIFY_OTHER_SOLICITOR_2(CAMUNDA),
Expand Down Expand Up @@ -300,8 +302,10 @@ public enum CaseEvent {
NOTIFY_LIP_RESPONDENT_CLAIMANT_CONFIRM_TO_PROCEED(CAMUNDA),
NOTIFY_LIP_APPLICANT_CLAIMANT_CONFIRM_TO_PROCEED(CAMUNDA),
NOTIFY_APPLICANT1_FOR_REQUEST_JUDGEMENT_BY_ADMISSION_LIP_CLAIMANT(CAMUNDA),
NOTIFY_RESPONDENT1_FOR_REQUEST_JUDGEMENT_BY_ADMISSION_LIP_CLAIMANT(CAMUNDA);
NOTIFY_RESPONDENT1_FOR_REQUEST_JUDGEMENT_BY_ADMISSION_LIP_CLAIMANT(CAMUNDA),
TRIGGER_TASK_RECONFIG_GA(CAMUNDA),

RETRIGGER_CASES(CAMUNDA);
private final UserType userType;

public boolean isCamundaEvent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
"/",
"/loggers/**",
"/assignment/**",
"/case/document/**",
"/service-request-update",
"/service-request-update-claim-issued"
"/service-request-update-claim-issued",
"/case/document/downloadDocument/**"
};

@Value("${spring.security.oauth2.client.provider.oidc.issuer-uri}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,6 @@ public ResponseEntity<FeatureToggleInfo> checkFeatureToggle(
return new ResponseEntity<>(featureToggleInfo, HttpStatus.OK);
}

@GetMapping("/testing-support/feature-toggle/noc")
@Operation(summary = "Check if noc feature toggle is enabled")
public ResponseEntity<FeatureToggleInfo> checkNoCToggleEnabled() {
boolean featureEnabled = featureToggleService.isNoticeOfChangeEnabled();
FeatureToggleInfo featureToggleInfo = new FeatureToggleInfo(featureEnabled);
return new ResponseEntity<>(featureToggleInfo, HttpStatus.OK);
}

@GetMapping("/testing-support/feature-toggle/isCertificateOfServiceEnabled")
@Operation(summary = "Check if access profiles feature toggle is enabled")
public ResponseEntity<FeatureToggleInfo> checkCertificateOfServiceEnabled() {
boolean featureEnabled = featureToggleService.isCertificateOfServiceEnabled();
FeatureToggleInfo featureToggleInfo = new FeatureToggleInfo(featureEnabled);
return new ResponseEntity<>(featureToggleInfo, HttpStatus.OK);
}

@Data
private static class BusinessProcessInfo {
private BusinessProcess businessProcess;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ public enum PersonalInjuryType {
PUBLIC_LIABILITY,
HOLIDAY_ILLNESS,
DISEASE_CLAIM,
NOISE_INDUCED_HEARING_LOSS,
PERSONAL_INJURY_OTHER
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

public enum UnrepresentedOrUnregisteredScenario {
UNREPRESENTED,
UNREGISTERED,
UNREGISTERED_NOTICE_OF_CHANGE;
UNREGISTERED;

public static List<String> getDefendantNames(UnrepresentedOrUnregisteredScenario scenario, CaseData caseData) {
List<String> defendantNames = new ArrayList<>();
Expand All @@ -24,20 +23,6 @@ public static List<String> getDefendantNames(UnrepresentedOrUnregisteredScenario
}
break;
case UNREGISTERED:
if (caseData.getRespondent1OrgRegistered() != YES
&& caseData.getRespondent1OrganisationPolicy() == null
&& caseData.getRespondent1Represented() == YES) {
defendantNames.add(caseData.getRespondent1().getPartyName());
}
if (caseData.getRespondent2OrgRegistered() != YES
&& caseData.getRespondent2Represented() == YES
&& caseData.getRespondent2OrganisationPolicy() == null
&& caseData.getRespondent2() != null) {
defendantNames.add(caseData.getRespondent2().getPartyName());
}
break;
//this should be removed during removal of notice of change flag
case UNREGISTERED_NOTICE_OF_CHANGE:
if (caseData.getRespondent1OrgRegistered() != YES
&& caseData.getRespondent1OrganisationPolicy() != null
&& caseData.getRespondent1OrganisationPolicy().getOrganisation() == null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,49 +23,44 @@
import java.util.function.Predicate;
import java.util.stream.Collectors;

import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_RPA_ON_CONTINUOUS_FEED;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_RPA_ON_CASE_HANDED_OFFLINE;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.RETRIGGER_CASES;

@Slf4j
@RequiredArgsConstructor
@Component
public class ResendNotifyRPAEventsHandler implements BaseExternalTaskHandler {
public class RetriggerCasesEventHandler implements BaseExternalTaskHandler {

private final CoreCaseDataService coreCaseDataService;

@Override
public void handleTask(ExternalTask externalTask) {
log.info("User authentication successful.");
var caseIdForNotifyRpaOnCaseHandedOffline = readCaseIds("/caseIdForNotifyRpaOnCaseHandedOffline.txt");
updateCaseByEvent(caseIdForNotifyRpaOnCaseHandedOffline, NOTIFY_RPA_ON_CASE_HANDED_OFFLINE);

var caseIdForNotifyRpaOnContinuousFeed = readCaseIds("/caseIdForNotifyRpaOnContinuousFeed.txt");
updateCaseByEvent(caseIdForNotifyRpaOnContinuousFeed, NOTIFY_RPA_ON_CONTINUOUS_FEED);

var caseIdForNotifyRpaOnCaseHandedOffline = readCaseIds("/caseIdForRetrigger.txt");
updateCaseByEvent(caseIdForNotifyRpaOnCaseHandedOffline, RETRIGGER_CASES);
}

private void updateCaseByEvent(List<String> caseIdList, CaseEvent caseEvent) {
if (caseIdList != null && !caseIdList.isEmpty()) {
log.info("Resend notify RPA started for event: {}", caseEvent);
log.info("Retrigger cases started for event: {}", caseEvent);
caseIdList.forEach(caseId -> {
try {
log.info("Resend CaseId: {} started", caseId);
log.info("Retrigger CaseId: {} started", caseId);
var startEventResponse = coreCaseDataService.startUpdate(caseId, caseEvent);

Map<String, Object> caseDataMap = coreCaseDataService.getCase(Long.valueOf(caseId)).getData();

coreCaseDataService.submitUpdate(caseId, caseDataContent(startEventResponse, caseDataMap));
log.info("Resend CaseId: {} finished", caseId);
log.info("Retrigger CaseId: {} finished", caseId);

} catch (FeignException e) {
log.error("ERROR Resend CaseId: {}", caseId);
log.error("ERROR Retrigger CaseId: {}", caseId);
log.error(String.format("Updating case data failed: %s", e.contentUTF8()));
throw e;
} catch (Exception e) {
log.error("ERROR Resend CaseId: {}", caseId);
log.error("ERROR Retrigger CaseId: {}", caseId);
log.error(String.format("Updating case data failed: %s", e.getMessage()));
}
log.info("Resend notify RPA Finished for event: {}", caseEvent);
log.info("Retrigger cases Finished for event: {}", caseEvent);
});
} else {
log.info("List id empty for: {}", caseEvent);
Expand All @@ -84,7 +79,7 @@ private CaseDataContent caseDataContent(StartEventResponse startEventResponse, M
.build();
}

private List<String> readCaseIds(String file) {
public List<String> readCaseIds(String file) {

String data = readString(file);
return Arrays.stream(data.split("[\r\n]+"))
Expand All @@ -99,7 +94,7 @@ private String readString(String resourcePath) {
}

private byte[] readBytes(String resourcePath) {
try (InputStream inputStream = ResendNotifyRPAEventsHandler.class.getResourceAsStream(resourcePath)) {
try (InputStream inputStream = RetriggerCasesEventHandler.class.getResourceAsStream(resourcePath)) {
return IOUtils.toByteArray(inputStream);
} catch (IOException e) {
throw new IllegalStateException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@
import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIGGER_LOCATION_UPDATE;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIGGER_UPDATE_GA_LOCATION;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIGGER_TASK_RECONFIG;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIGGER_TASK_RECONFIG_GA;

@Slf4j
@Service
@RequiredArgsConstructor
public class TriggerGenAppLocationUpdateCallbackHandler extends CallbackHandler {

private static final List<CaseEvent> EVENTS = List.of(TRIGGER_UPDATE_GA_LOCATION);
private static final List<CaseEvent> EVENTS = List.of(TRIGGER_UPDATE_GA_LOCATION,
TRIGGER_TASK_RECONFIG_GA);

private final GenAppStateHelperService helperService;
private final ObjectMapper objectMapper;
Expand All @@ -49,7 +52,11 @@ private CallbackResponse triggerGaEvent(CallbackParams callbackParams) {
try {
if (caseData.getGeneralApplications() != null && !caseData.getGeneralApplications().isEmpty()) {
caseData = helperService.updateApplicationLocationDetailsInClaim(caseData, authToken);
helperService.triggerEvent(caseData, TRIGGER_LOCATION_UPDATE);
if (callbackParams.getRequest().getEventId().equals(TRIGGER_UPDATE_GA_LOCATION.name())) {
helperService.triggerEvent(caseData, TRIGGER_LOCATION_UPDATE);
} else if (callbackParams.getRequest().getEventId().equals(TRIGGER_TASK_RECONFIG_GA.name())) {
helperService.triggerEvent(caseData, TRIGGER_TASK_RECONFIG);
}
}
} catch (Exception e) {
String errorMessage = "Could not trigger event to update location on application under case: "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private CallbackResponse generateClaimForm(CallbackParams callbackParams) {
);
assignCategoryId.assignCategoryIdToCaseDocument(sealedClaim, "detailsOfClaim");

if (featureToggleService.isNoticeOfChangeEnabled() && stitchEnabled
if (stitchEnabled
&& (YesOrNo.NO.equals(caseData.getRespondent1Represented())
|| YesOrNo.NO.equals(caseData.getRespondent2Represented()))) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private List<DocumentMetaData> fetchDocumentsFromCaseData(CaseData caseData, Cas
LocalDate.now().toString()));

//LiP Claim form guidance needs be sent as the 2nd doc to go on the back of the claim form
if (toggleService.isNoticeOfChangeEnabled() && stitchEnabled) {
if (stitchEnabled) {
if (YesOrNo.NO.equals(caseData.getSpecRespondent1Represented())
|| YesOrNo.NO.equals(caseData.getSpecRespondent2Represented())) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ public List<CaseEvent> handledEvents() {

private CallbackResponse notifyApplicantSolicitorForClaimContinuingOnline(CallbackParams callbackParams) {
CaseData caseData = callbackParams.getCaseData();
boolean isCosEnabled = featureToggleService.isCertificateOfServiceEnabled();
String emailTemplateID = isCosEnabled != true
? notificationsProperties.getClaimantSolicitorClaimContinuingOnline()
: notificationsProperties.getClaimantSolicitorClaimContinuingOnlineCos();
String emailTemplateID = notificationsProperties.getClaimantSolicitorClaimContinuingOnlineCos();

notificationService.sendMail(
caseData.getApplicantSolicitor1UserDetails().getEmail(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,10 +482,8 @@ private CallbackResponse submitClaim(CallbackParams callbackParams) {

handleCourtLocationData(caseData, dataBuilder, callbackParams);

if (toggleService.isNoticeOfChangeEnabled()) {
// LiP are not represented or registered
OrgPolicyUtils.addMissingOrgPolicies(dataBuilder);
}
// LiP are not represented or registered
OrgPolicyUtils.addMissingOrgPolicies(dataBuilder);

// temporarily default to yes for CIV-2659
if (YES.equals(caseData.getRespondent1Represented()) && caseData.getRespondent1OrgRegistered() == null) {
Expand All @@ -510,20 +508,17 @@ private CallbackResponse submitClaim(CallbackParams callbackParams) {
log.info("Case management equals: " + caseData.getCaseManagementCategory());
log.info("CaseName equals: " + caseData.getCaseNameHmctsInternal());

//Adding variables for feature Certificate of Service
if (toggleService.isCertificateOfServiceEnabled()) {
if (caseData.getRespondent1Represented().equals(NO)) {
dataBuilder.defendant1LIPAtClaimIssued(YES);
} else {
dataBuilder.defendant1LIPAtClaimIssued(NO);
}
if (caseData.getRespondent1Represented().equals(NO)) {
dataBuilder.defendant1LIPAtClaimIssued(YES);
} else {
dataBuilder.defendant1LIPAtClaimIssued(NO);
}

if (YES.equals(caseData.getAddRespondent2())) {
if (caseData.getRespondent2Represented() == NO) {
dataBuilder.defendant2LIPAtClaimIssued(YES);
} else {
dataBuilder.defendant2LIPAtClaimIssued(NO);
}
if (YES.equals(caseData.getAddRespondent2())) {
if (caseData.getRespondent2Represented() == NO) {
dataBuilder.defendant2LIPAtClaimIssued(YES);
} else {
dataBuilder.defendant2LIPAtClaimIssued(NO);
}
}
//assign category ids to documents uploaded as part of particulars of claim
Expand Down Expand Up @@ -606,18 +601,11 @@ private boolean isSecondRespondentLitigantInPerson(CaseData caseData) {
private String getBody(CaseData caseData) {
return areRespondentsRepresentedAndRegistered(caseData)
? getConfirmationSummary(caseData)
: toggleService.isCertificateOfServiceEnabled()
? format(CONFIRMATION_BODY_LIP_COS,
: format(CONFIRMATION_BODY_LIP_COS,
format("/cases/case-details/%s#Service%%20Request", caseData.getCcdCaseReference()),
format(caseDocLocation, caseData.getCcdCaseReference()),
claimUrlsConfiguration.getResponsePackLink())
+ exitSurveyContentService.applicantSurvey()
: format(CONFIRMATION_BODY_COS,
format("/cases/case-details/%s#Service%%20Request", caseData.getCcdCaseReference()),
format(caseDocLocation, caseData.getCcdCaseReference()),
claimUrlsConfiguration.getResponsePackLink())
+ exitSurveyContentService.applicantSurvey();

+ exitSurveyContentService.applicantSurvey();
}

private String getConfirmationSummary(CaseData caseData) {
Expand Down
Loading

0 comments on commit 165a12e

Please sign in to comment.