Skip to content
Snippets Groups Projects
Commit ebc60c17 authored by Riabokon Stanislav(EPAM)[GCP]'s avatar Riabokon Stanislav(EPAM)[GCP]
Browse files

Merge branch 'feature/GONRG-940-Implement_audit_events_Legal' into 'integration-master'

GONRG-940 Implement audit events for Legal

Closes GONRG-940

See merge request go3-nrg/platform/security-and-compliance/legal!15
parents ea655924 7997fa1a
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)
Pipeline #12609 passed
package org.opengroup.osdu.legal.api; package org.opengroup.osdu.legal.api;
import com.google.gson.Gson; import com.google.gson.Gson;
import java.util.Collections;
import org.opengroup.osdu.legal.countries.LegalTagCountriesService; import org.opengroup.osdu.legal.countries.LegalTagCountriesService;
import org.opengroup.osdu.legal.logging.AuditLogger; import org.opengroup.osdu.legal.logging.AuditLogger;
import org.opengroup.osdu.legal.tags.LegalTagService; import org.opengroup.osdu.legal.tags.LegalTagService;
...@@ -137,7 +138,7 @@ public class LegalTagApi { ...@@ -137,7 +138,7 @@ public class LegalTagApi {
output.setPersonalDataTypes(allowedLegaltagPropertyValues.getPersonalDataType()); output.setPersonalDataTypes(allowedLegaltagPropertyValues.getPersonalDataType());
output.setSecurityClassifications(allowedLegaltagPropertyValues.getSecurityClassifications()); output.setSecurityClassifications(allowedLegaltagPropertyValues.getSecurityClassifications());
output.setDataTypes(allowedLegaltagPropertyValues.getDataTypes()); output.setDataTypes(allowedLegaltagPropertyValues.getDataTypes());
auditLogger.readLegalPropertiesSuccess(); auditLogger.readLegalPropertiesSuccess(Collections.singletonList(output.toString()));
return new ResponseEntity<ReadablePropertyValues>(output, HttpStatus.OK); return new ResponseEntity<ReadablePropertyValues>(output, HttpStatus.OK);
} }
......
...@@ -82,25 +82,25 @@ public class AuditEvents { ...@@ -82,25 +82,25 @@ public class AuditEvents {
.build(); .build();
} }
public AuditPayload getReadLegalPropertiesEventSuccess() { public AuditPayload getReadLegalPropertiesEventSuccess(List<String> resources) {
return AuditPayload.builder() return AuditPayload.builder()
.action(AuditAction.READ) .action(AuditAction.READ)
.status(AuditStatus.SUCCESS) .status(AuditStatus.SUCCESS)
.user(this.user) .user(this.user)
.actionId(READ_ACTION_ID) .actionId(READ_ACTION_ID)
.message(READ_MESSAGE_SUCCESS) .message(READ_MESSAGE_SUCCESS)
.resources(singletonList(PROPERTY_VALUE)) .resources(resources)
.build(); .build();
} }
public AuditPayload getReadLegalPropertiesEventFail() { public AuditPayload getReadLegalPropertiesEventFail(List<String> resources) {
return AuditPayload.builder() return AuditPayload.builder()
.action(AuditAction.READ) .action(AuditAction.READ)
.status(AuditStatus.FAILURE) .status(AuditStatus.FAILURE)
.user(this.user) .user(this.user)
.actionId(READ_ACTION_ID) .actionId(READ_ACTION_ID)
.message(READ_MESSAGE_FAILURE) .message(READ_MESSAGE_FAILURE)
.resources(singletonList(PROPERTY_VALUE)) .resources(resources)
.build(); .build();
} }
......
...@@ -63,12 +63,12 @@ public class AuditLogger { ...@@ -63,12 +63,12 @@ public class AuditLogger {
this.writeLog(this.getEvents().getLegalTagStatusJobEventFail(resources)); this.writeLog(this.getEvents().getLegalTagStatusJobEventFail(resources));
} }
public void readLegalPropertiesSuccess() { public void readLegalPropertiesSuccess(List<String> resources) {
this.writeLog(this.getEvents().getReadLegalPropertiesEventSuccess()); this.writeLog(this.getEvents().getReadLegalPropertiesEventSuccess(resources));
} }
public void readLegalPropertiesFail() { public void readLegalPropertiesFail(List<String> resources) {
this.writeLog(this.getEvents().getReadLegalPropertiesEventFail()); this.writeLog(this.getEvents().getReadLegalPropertiesEventFail(resources));
} }
public void validateLegalTagSuccess() { public void validateLegalTagSuccess() {
......
...@@ -268,6 +268,6 @@ public class LegalTagApiTests { ...@@ -268,6 +268,6 @@ public class LegalTagApiTests {
public void shouldCreateAuditLogs_when_getLegalTagProperties() { public void shouldCreateAuditLogs_when_getLegalTagProperties() {
sut.getLegalTagProperties(); sut.getLegalTagProperties();
verify(auditLogger).readLegalPropertiesSuccess(); verify(auditLogger).readLegalPropertiesSuccess(any());
} }
} }
...@@ -67,13 +67,13 @@ public class AuditLoggerTests { ...@@ -67,13 +67,13 @@ public class AuditLoggerTests {
@Test @Test
public void should_writeLegalTagReadPropertiesSuccessEvent(){ public void should_writeLegalTagReadPropertiesSuccessEvent(){
sut.readLegalPropertiesSuccess(); sut.readLegalPropertiesSuccess(any());
verify(log).audit(any()); verify(log).audit(any());
} }
@Test @Test
public void should_writeLegalTagReadPropertiesFailEvent(){ public void should_writeLegalTagReadPropertiesFailEvent(){
sut.readLegalPropertiesFail(); sut.readLegalPropertiesFail(any());
verify(log).audit(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