Skip to content
Snippets Groups Projects
Commit 7997fa1a authored by Rustam Lotsmanenko (EPAM)'s avatar Rustam Lotsmanenko (EPAM)
Browse files

GONRG-940

Pass properties to audit event
parent ea655924
No related branches found
No related tags found
7 merge requests!98(GONRG-1768) GCP: logging impl,!92Cloud-agnostic module `legal-reference` for Anthos (GONRG-1423),!87Fix gcp unit test,!84Gcp fix sonar comments (GONRG-1366),!82Gcp update core common (GONRG-1211),!71Removed unhardcode repositories and distribution management from all poms (GONRG-993),!69Add properties in audit log (GONRG-940)
package org.opengroup.osdu.legal.api;
import com.google.gson.Gson;
import java.util.Collections;
import org.opengroup.osdu.legal.countries.LegalTagCountriesService;
import org.opengroup.osdu.legal.logging.AuditLogger;
import org.opengroup.osdu.legal.tags.LegalTagService;
......@@ -137,7 +138,7 @@ public class LegalTagApi {
output.setPersonalDataTypes(allowedLegaltagPropertyValues.getPersonalDataType());
output.setSecurityClassifications(allowedLegaltagPropertyValues.getSecurityClassifications());
output.setDataTypes(allowedLegaltagPropertyValues.getDataTypes());
auditLogger.readLegalPropertiesSuccess();
auditLogger.readLegalPropertiesSuccess(Collections.singletonList(output.toString()));
return new ResponseEntity<ReadablePropertyValues>(output, HttpStatus.OK);
}
......
......@@ -82,25 +82,25 @@ public class AuditEvents {
.build();
}
public AuditPayload getReadLegalPropertiesEventSuccess() {
public AuditPayload getReadLegalPropertiesEventSuccess(List<String> resources) {
return AuditPayload.builder()
.action(AuditAction.READ)
.status(AuditStatus.SUCCESS)
.user(this.user)
.actionId(READ_ACTION_ID)
.message(READ_MESSAGE_SUCCESS)
.resources(singletonList(PROPERTY_VALUE))
.resources(resources)
.build();
}
public AuditPayload getReadLegalPropertiesEventFail() {
public AuditPayload getReadLegalPropertiesEventFail(List<String> resources) {
return AuditPayload.builder()
.action(AuditAction.READ)
.status(AuditStatus.FAILURE)
.user(this.user)
.actionId(READ_ACTION_ID)
.message(READ_MESSAGE_FAILURE)
.resources(singletonList(PROPERTY_VALUE))
.resources(resources)
.build();
}
......
......@@ -63,12 +63,12 @@ public class AuditLogger {
this.writeLog(this.getEvents().getLegalTagStatusJobEventFail(resources));
}
public void readLegalPropertiesSuccess() {
this.writeLog(this.getEvents().getReadLegalPropertiesEventSuccess());
public void readLegalPropertiesSuccess(List<String> resources) {
this.writeLog(this.getEvents().getReadLegalPropertiesEventSuccess(resources));
}
public void readLegalPropertiesFail() {
this.writeLog(this.getEvents().getReadLegalPropertiesEventFail());
public void readLegalPropertiesFail(List<String> resources) {
this.writeLog(this.getEvents().getReadLegalPropertiesEventFail(resources));
}
public void validateLegalTagSuccess() {
......
......@@ -268,6 +268,6 @@ public class LegalTagApiTests {
public void shouldCreateAuditLogs_when_getLegalTagProperties() {
sut.getLegalTagProperties();
verify(auditLogger).readLegalPropertiesSuccess();
verify(auditLogger).readLegalPropertiesSuccess(any());
}
}
......@@ -67,13 +67,13 @@ public class AuditLoggerTests {
@Test
public void should_writeLegalTagReadPropertiesSuccessEvent(){
sut.readLegalPropertiesSuccess();
sut.readLegalPropertiesSuccess(any());
verify(log).audit(any());
}
@Test
public void should_writeLegalTagReadPropertiesFailEvent(){
sut.readLegalPropertiesFail();
sut.readLegalPropertiesFail(any());
verify(log).audit(any());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment