Skip to content
Snippets Groups Projects
Commit f9cdcbc9 authored by Rustam Lotsmanenko (EPAM)'s avatar Rustam Lotsmanenko (EPAM) Committed by Rostislav Dublin (EPAM)
Browse files

GONRG-940

Pass properties to audit event
parent 74a16034
No related branches found
No related tags found
No related merge requests found
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