From 6676064b635904d7ac87b2a43c7e5f7bb4067bd3 Mon Sep 17 00:00:00 2001 From: Martin Date: Wed, 30 Oct 2024 09:17:04 +0000 Subject: [PATCH] Remove unnecessary log and audit enabled check. --- Jenkinsfile_CNP | 2 - Jenkinsfile_nightly | 1 - .../values.preview.template.yaml | 1 - .../ccd/parameter/TestParameterResolver.java | 8 --- .../hmcts/reform/ccd/utils/LauTestUtils.java | 18 +++--- .../resources/application-functional.yaml | 1 - .../ccd/config/TestParameterResolver.java | 8 --- .../ccd/utils/LauRemoteDeletionVerifier.java | 12 +--- .../resources/application-test.yaml | 1 - .../parameter/DefaultParameterResolver.java | 8 --- .../ccd/parameter/ParameterResolver.java | 2 - .../remote/LogAndAuditRemoteOperation.java | 58 ++++++++++--------- src/main/resources/application.yaml | 2 - .../LogAndAuditRemoteOperationTest.java | 1 - 14 files changed, 42 insertions(+), 81 deletions(-) diff --git a/Jenkinsfile_CNP b/Jenkinsfile_CNP index 74e647b5..5ebc5522 100644 --- a/Jenkinsfile_CNP +++ b/Jenkinsfile_CNP @@ -105,7 +105,6 @@ withPipeline(type, product, component) { loadVaultSecrets(prSecrets) env.ENV = 'preview' env.CREATE_GLOBAL_SEARCH = true - env.LOG_AND_AUDIT_ENABLED = true env.DATA_STORE_DB_USERNAME = "hmcts" env.DATA_STORE_DB_PASSWORD = "hmcts" env.DATA_STORE_DB_NAME = "ccd_data_store" @@ -152,7 +151,6 @@ withPipeline(type, product, component) { afterAlways('akschartsinstall') { // Set required environment variables to run functional tests apart from one in vaults. env.ELASTIC_SEARCH_ENABLED = true - env.LOG_AND_AUDIT_ENABLED = true env.IDAM_S2S_URL = 'http://rpe-service-auth-provider-aat.service.core-compute-aat.internal' env.IDAM_API_URL = 'https://idam-api.aat.platform.hmcts.net' env.ROLE_ASSIGNMENT_HOST = 'http://am-role-assignment-service-aat.service.core-compute-aat.internal' diff --git a/Jenkinsfile_nightly b/Jenkinsfile_nightly index e719ec89..90d0e30c 100644 --- a/Jenkinsfile_nightly +++ b/Jenkinsfile_nightly @@ -50,7 +50,6 @@ GradleBuilder builder = new GradleBuilder(this, product) withNightlyPipeline(type, product, component) { // Set required environment variables to run functional tests apart from one in vaults. env.ELASTIC_SEARCH_ENABLED = true - env.LOG_AND_AUDIT_ENABLED = true env.DATA_STORE_DB_PORT = '5432' env.DATA_STORE_DB_OPTIONS = '?sslmode=require' env.DATA_STORE_DB_HOST = 'ccd-data-store-api-postgres-db-v15-aat.postgres.database.azure.com' diff --git a/charts/ccd-case-disposer/values.preview.template.yaml b/charts/ccd-case-disposer/values.preview.template.yaml index def4d4de..a5812a5a 100644 --- a/charts/ccd-case-disposer/values.preview.template.yaml +++ b/charts/ccd-case-disposer/values.preview.template.yaml @@ -15,7 +15,6 @@ job: DATA_STORE_DB_PASSWORD: hmcts DATA_STORE_DB_OPTIONS: "?sslmode=allow" ELASTIC_SEARCH_ENABLED: true - LOG_AND_AUDIT_ENABLED: true ELASTIC_SEARCH_HOSTS: ${SERVICE_NAME}-es-master:9200 ELASTIC_SEARCH_DATA_NODES_HOSTS: http://${SERVICE_NAME}-es-master:9200 DEFINITION_STORE_HOST: http://${SERVICE_NAME}-ccd-definition-store diff --git a/src/functionalTest/java/uk/gov/hmcts/reform/ccd/parameter/TestParameterResolver.java b/src/functionalTest/java/uk/gov/hmcts/reform/ccd/parameter/TestParameterResolver.java index 15855770..fcc309a0 100644 --- a/src/functionalTest/java/uk/gov/hmcts/reform/ccd/parameter/TestParameterResolver.java +++ b/src/functionalTest/java/uk/gov/hmcts/reform/ccd/parameter/TestParameterResolver.java @@ -50,9 +50,6 @@ public class TestParameterResolver implements ParameterResolver { @Value("${ccd.tasks.host}") private String tasksHost; - @Value("${log.and.audit.enabled}") - private Boolean isLogAndAuditEnabled; - @Value("${ccd.role.assignment.check-case-roles-exist}") private Boolean checkCaseRolesExist; @@ -167,11 +164,6 @@ public Integer getAppInsightsLogSize() { return appInsightsLogSize; } - @Override - public Boolean isLogAndAuditEnabled() { - return isLogAndAuditEnabled; - } - @Override public Integer getThreadMaxPoolSize() { return threadMaxPoolSize; diff --git a/src/functionalTest/java/uk/gov/hmcts/reform/ccd/utils/LauTestUtils.java b/src/functionalTest/java/uk/gov/hmcts/reform/ccd/utils/LauTestUtils.java index 911a8311..60fe839e 100644 --- a/src/functionalTest/java/uk/gov/hmcts/reform/ccd/utils/LauTestUtils.java +++ b/src/functionalTest/java/uk/gov/hmcts/reform/ccd/utils/LauTestUtils.java @@ -26,16 +26,16 @@ public class LauTestUtils { public void verifyLauLogs(final List> deletableEndStateRowIds) { final List caseRefs = deletableEndStateRowIds.stream() - .flatMap(List::stream) - .collect(Collectors.toList()); + .flatMap(List::stream) + .collect(Collectors.toList()); - if (parameterResolver.isLogAndAuditEnabled()) { - with().await() - .untilAsserted(() -> assertThat(lauRecordHolder.getLauCaseRefList()) - .containsExactlyInAnyOrderElementsOf(transform(newArrayList(caseRefs), - toStringFunction()))); + with().await() + .untilAsserted(() -> assertThat(lauRecordHolder.getLauCaseRefList()) + .containsExactlyInAnyOrderElementsOf(transform( + newArrayList(caseRefs), + toStringFunction() + ))); - lauRecordHolder.getLauCaseRefList().clear(); - } + lauRecordHolder.getLauCaseRefList().clear(); } } diff --git a/src/functionalTest/resources/application-functional.yaml b/src/functionalTest/resources/application-functional.yaml index 42f4ff9a..cf66522d 100644 --- a/src/functionalTest/resources/application-functional.yaml +++ b/src/functionalTest/resources/application-functional.yaml @@ -43,7 +43,6 @@ ccd: create.global.search: ${CREATE_GLOBAL_SEARCH:true} app.insights.log.size: ${CASE_DISPOSER_SUMMARY_LOG_SIZE:250} -log.and.audit.enabled: ${LOG_AND_AUDIT_ENABLED:false} thread: max_pool_size: ${THREAD_MAX_POOL_SIZE:10} diff --git a/src/integrationTest/java/uk/gov/hmcts/reform/ccd/config/TestParameterResolver.java b/src/integrationTest/java/uk/gov/hmcts/reform/ccd/config/TestParameterResolver.java index f1e2d65d..07746890 100644 --- a/src/integrationTest/java/uk/gov/hmcts/reform/ccd/config/TestParameterResolver.java +++ b/src/integrationTest/java/uk/gov/hmcts/reform/ccd/config/TestParameterResolver.java @@ -42,9 +42,6 @@ public class TestParameterResolver implements ParameterResolver { @Value("${ccd.tasks.host}") private String tasksHost; - @Value("${log.and.audit.enabled}") - private Boolean isLogAndAuditEnabled; - @Value("${ccd.role.assignment.check-case-roles-exist}") private Boolean checkCaseRolesExist; @@ -161,11 +158,6 @@ public Integer getAppInsightsLogSize() { return appInsightsLogSize; } - @Override - public Boolean isLogAndAuditEnabled() { - return isLogAndAuditEnabled; - } - @Override public Integer getThreadMaxPoolSize() { return threadMaxPoolSize; diff --git a/src/integrationTest/java/uk/gov/hmcts/reform/ccd/utils/LauRemoteDeletionVerifier.java b/src/integrationTest/java/uk/gov/hmcts/reform/ccd/utils/LauRemoteDeletionVerifier.java index 9a3db7d7..8650876b 100644 --- a/src/integrationTest/java/uk/gov/hmcts/reform/ccd/utils/LauRemoteDeletionVerifier.java +++ b/src/integrationTest/java/uk/gov/hmcts/reform/ccd/utils/LauRemoteDeletionVerifier.java @@ -4,7 +4,6 @@ import com.google.common.collect.Lists; import jakarta.inject.Inject; import org.springframework.stereotype.Component; -import uk.gov.hmcts.reform.ccd.parameter.ParameterResolver; import uk.gov.hmcts.reform.ccd.util.log.LauRecordHolder; import java.util.List; @@ -17,15 +16,10 @@ public class LauRemoteDeletionVerifier implements RemoteDeletionVerifier { @Inject private LauRecordHolder lauRecordHolder; - @Inject - private ParameterResolver parameterResolver; - public void verifyRemoteDeletion(final List caseRefs) { - if (parameterResolver.isLogAndAuditEnabled()) { - assertThat(lauRecordHolder.getLauCaseRefList()) - .containsExactlyInAnyOrderElementsOf(Lists.transform(caseRefs, Functions.toStringFunction())); + assertThat(lauRecordHolder.getLauCaseRefList()) + .containsExactlyInAnyOrderElementsOf(Lists.transform(caseRefs, Functions.toStringFunction())); - lauRecordHolder.getLauCaseRefList().clear(); - } + lauRecordHolder.getLauCaseRefList().clear(); } } diff --git a/src/integrationTest/resources/application-test.yaml b/src/integrationTest/resources/application-test.yaml index 71332f1e..3cb48d26 100644 --- a/src/integrationTest/resources/application-test.yaml +++ b/src/integrationTest/resources/application-test.yaml @@ -62,7 +62,6 @@ ccd: host: http://localhost:4603 app.insights.log.size: 250 -log.and.audit.enabled: true thread: max_pool_size: ${THREAD_MAX_POOL_SIZE:10} diff --git a/src/main/java/uk/gov/hmcts/reform/ccd/parameter/DefaultParameterResolver.java b/src/main/java/uk/gov/hmcts/reform/ccd/parameter/DefaultParameterResolver.java index 62a8fa11..d77a152b 100644 --- a/src/main/java/uk/gov/hmcts/reform/ccd/parameter/DefaultParameterResolver.java +++ b/src/main/java/uk/gov/hmcts/reform/ccd/parameter/DefaultParameterResolver.java @@ -50,9 +50,6 @@ public class DefaultParameterResolver implements ParameterResolver { @Value("${ccd.tasks.host}") private String tasksHost; - @Value("${log.and.audit.enabled}") - private Boolean isLogAndAuditEnabled; - @Value("${ccd.role.assignment.check-case-roles-exist}") private Boolean checkCaseRolesExist; @@ -161,11 +158,6 @@ public Integer getAppInsightsLogSize() { return appInsightsLogSize; } - @Override - public Boolean isLogAndAuditEnabled() { - return isLogAndAuditEnabled; - } - @Override public Integer getThreadMaxPoolSize() { return threadMaxPoolSize; diff --git a/src/main/java/uk/gov/hmcts/reform/ccd/parameter/ParameterResolver.java b/src/main/java/uk/gov/hmcts/reform/ccd/parameter/ParameterResolver.java index 5b3e2333..9a7b0c31 100644 --- a/src/main/java/uk/gov/hmcts/reform/ccd/parameter/ParameterResolver.java +++ b/src/main/java/uk/gov/hmcts/reform/ccd/parameter/ParameterResolver.java @@ -37,8 +37,6 @@ public interface ParameterResolver { Integer getAppInsightsLogSize(); - Boolean isLogAndAuditEnabled(); - Integer getThreadMaxPoolSize(); Integer getThreadCorePoolSize(); diff --git a/src/main/java/uk/gov/hmcts/reform/ccd/service/remote/LogAndAuditRemoteOperation.java b/src/main/java/uk/gov/hmcts/reform/ccd/service/remote/LogAndAuditRemoteOperation.java index d692b725..d60ae73f 100644 --- a/src/main/java/uk/gov/hmcts/reform/ccd/service/remote/LogAndAuditRemoteOperation.java +++ b/src/main/java/uk/gov/hmcts/reform/ccd/service/remote/LogAndAuditRemoteOperation.java @@ -48,39 +48,41 @@ public LogAndAuditRemoteOperation(final ParameterResolver parameterResolver, } public void postCaseDeletionToLogAndAudit(final CaseData caseData) { - if (parameterResolver.isLogAndAuditEnabled()) { - try { - final CaseActionPostRequestResponse caseActionPostRequestResponse = - buildCaseActionPostRequest(caseData); - final String logAndAuditPostResponse = ccdRestClientBuilder.postRequestWithServiceAuthHeader( - parameterResolver.getLogAndAuditHost(), - LAU_SAVE_PATH, - gson.toJson(caseActionPostRequestResponse) - ); - - logResponse(logAndAuditPostResponse); - } catch (final Exception exception) { - final String errorMessage = String.format("Error posting to Log and Audit for case : %s", - caseData.getReference()); - log.error(errorMessage, exception); - throw new LogAndAuditException(errorMessage, exception); - } + try { + final CaseActionPostRequestResponse caseActionPostRequestResponse = + buildCaseActionPostRequest(caseData); + final String logAndAuditPostResponse = ccdRestClientBuilder.postRequestWithServiceAuthHeader( + parameterResolver.getLogAndAuditHost(), + LAU_SAVE_PATH, + gson.toJson(caseActionPostRequestResponse) + ); + + logResponse(logAndAuditPostResponse); + } catch (final Exception exception) { + final String errorMessage = String.format( + "Error posting to Log and Audit for case : %s", + caseData.getReference() + ); + log.error(errorMessage, exception); + throw new LogAndAuditException(errorMessage, exception); } } private void logResponse(final String logAndAuditPostResponse) { try { final CaseActionPostRequestResponse caseActionResults = - gson.fromJson(logAndAuditPostResponse, CaseActionPostRequestResponse.class); + gson.fromJson(logAndAuditPostResponse, CaseActionPostRequestResponse.class); logLauRecord(caseActionResults); - log.info("Case data with case ref: {} successfully posted to Log and Audit", - caseActionResults.getActionLog().getCaseRef()); + log.info( + "Case data with case ref: {} successfully posted to Log and Audit", + caseActionResults.getActionLog().getCaseRef() + ); } catch (final JsonParseException jsonParseException) { final String errorMessage = "Unable to map json to object Log and Audit endpoint response due" - + " to following endpoint response: ".concat(logAndAuditPostResponse); + + " to following endpoint response: ".concat(logAndAuditPostResponse); log.error(errorMessage); throw new LogAndAuditException(errorMessage); } @@ -93,13 +95,13 @@ private void logLauRecord(final CaseActionPostRequestResponse caseActionResults) private CaseActionPostRequestResponse buildCaseActionPostRequest(final CaseData caseData) { return new CaseActionPostRequestResponse(ActionLog.builder() - .userId(securityUtil.getUserDetails().getId()) - .caseAction("DELETE") - .caseTypeId(caseData.getCaseType()) - .caseRef(caseData.getReference().toString()) - .caseJurisdictionId(caseData.getJurisdiction()) - .timestamp(getTimestamp()) - .build()); + .userId(securityUtil.getUserDetails().getId()) + .caseAction("DELETE") + .caseTypeId(caseData.getCaseType()) + .caseRef(caseData.getReference().toString()) + .caseJurisdictionId(caseData.getJurisdiction()) + .timestamp(getTimestamp()) + .build()); } diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index bf1a923e..45344e93 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -75,8 +75,6 @@ smoke.test.enabled: false app.insights.log.size: ${CASE_DISPOSER_SUMMARY_LOG_SIZE:250} -log.and.audit.enabled: ${LOG_AND_AUDIT_ENABLED:false} - thread: max_pool_size: ${THREAD_MAX_POOL_SIZE:10} core_pool_size: ${THREAD_CORE_POOL_SIZE:5} diff --git a/src/test/java/uk/gov/hmcts/reform/ccd/service/remote/LogAndAuditRemoteOperationTest.java b/src/test/java/uk/gov/hmcts/reform/ccd/service/remote/LogAndAuditRemoteOperationTest.java index 13f1d11b..081621d4 100644 --- a/src/test/java/uk/gov/hmcts/reform/ccd/service/remote/LogAndAuditRemoteOperationTest.java +++ b/src/test/java/uk/gov/hmcts/reform/ccd/service/remote/LogAndAuditRemoteOperationTest.java @@ -50,7 +50,6 @@ class LogAndAuditRemoteOperationTest { void setUp() { final UserDetails userDetails = mock(UserDetails.class); when(parameterResolver.getLogAndAuditHost()).thenReturn("http://localhost"); - when(parameterResolver.isLogAndAuditEnabled()).thenReturn(true); when(securityUtil.getUserDetails()).thenReturn(userDetails); when(userDetails.getId()).thenReturn("123"); }