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

Remove unnecessary log and audit enabled check. #650

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Jenkinsfile_CNP
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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'
Expand Down
1 change: 0 additions & 1 deletion Jenkinsfile_nightly
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 0 additions & 1 deletion charts/ccd-case-disposer/values.preview.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -167,11 +164,6 @@ public Integer getAppInsightsLogSize() {
return appInsightsLogSize;
}

@Override
public Boolean isLogAndAuditEnabled() {
return isLogAndAuditEnabled;
}

@Override
public Integer getThreadMaxPoolSize() {
return threadMaxPoolSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ public class LauTestUtils {
public void verifyLauLogs(final List<List<Long>> deletableEndStateRowIds) {

final List<Long> 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();
}
}
1 change: 0 additions & 1 deletion src/functionalTest/resources/application-functional.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -161,11 +158,6 @@ public Integer getAppInsightsLogSize() {
return appInsightsLogSize;
}

@Override
public Boolean isLogAndAuditEnabled() {
return isLogAndAuditEnabled;
}

@Override
public Integer getThreadMaxPoolSize() {
return threadMaxPoolSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -17,15 +16,10 @@ public class LauRemoteDeletionVerifier implements RemoteDeletionVerifier {
@Inject
private LauRecordHolder lauRecordHolder;

@Inject
private ParameterResolver parameterResolver;

public void verifyRemoteDeletion(final List<Long> 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();
}
}
1 change: 0 additions & 1 deletion src/integrationTest/resources/application-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -161,11 +158,6 @@ public Integer getAppInsightsLogSize() {
return appInsightsLogSize;
}

@Override
public Boolean isLogAndAuditEnabled() {
return isLogAndAuditEnabled;
}

@Override
public Integer getThreadMaxPoolSize() {
return threadMaxPoolSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public interface ParameterResolver {

Integer getAppInsightsLogSize();

Boolean isLogAndAuditEnabled();

Integer getThreadMaxPoolSize();

Integer getThreadCorePoolSize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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());
}


Expand Down
2 changes: 0 additions & 2 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down