From f9cdcbc9465d5f695125fd3a1d41a9947147a3da Mon Sep 17 00:00:00 2001
From: "Rustam Lotsmanenko (EPAM)" <rustam_lotsmanenko@epam.com>
Date: Wed, 28 Oct 2020 08:53:36 -0400
Subject: [PATCH] GONRG-940

Pass properties to audit event
---
 .../java/org/opengroup/osdu/legal/api/LegalTagApi.java    | 3 ++-
 .../org/opengroup/osdu/legal/logging/AuditEvents.java     | 8 ++++----
 .../org/opengroup/osdu/legal/logging/AuditLogger.java     | 8 ++++----
 .../org/opengroup/osdu/legal/api/LegalTagApiTests.java    | 2 +-
 .../opengroup/osdu/legal/logging/AuditLoggerTests.java    | 4 ++--
 5 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/legal-core/src/main/java/org/opengroup/osdu/legal/api/LegalTagApi.java b/legal-core/src/main/java/org/opengroup/osdu/legal/api/LegalTagApi.java
index f78078a8d..293aa55ee 100644
--- a/legal-core/src/main/java/org/opengroup/osdu/legal/api/LegalTagApi.java
+++ b/legal-core/src/main/java/org/opengroup/osdu/legal/api/LegalTagApi.java
@@ -1,6 +1,7 @@
 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);
     }
diff --git a/legal-core/src/main/java/org/opengroup/osdu/legal/logging/AuditEvents.java b/legal-core/src/main/java/org/opengroup/osdu/legal/logging/AuditEvents.java
index fc00f8bee..7331668c6 100644
--- a/legal-core/src/main/java/org/opengroup/osdu/legal/logging/AuditEvents.java
+++ b/legal-core/src/main/java/org/opengroup/osdu/legal/logging/AuditEvents.java
@@ -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();
 	}
 
diff --git a/legal-core/src/main/java/org/opengroup/osdu/legal/logging/AuditLogger.java b/legal-core/src/main/java/org/opengroup/osdu/legal/logging/AuditLogger.java
index 8df60fb12..939b2cdd6 100644
--- a/legal-core/src/main/java/org/opengroup/osdu/legal/logging/AuditLogger.java
+++ b/legal-core/src/main/java/org/opengroup/osdu/legal/logging/AuditLogger.java
@@ -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() {
diff --git a/legal-core/src/test/java/org/opengroup/osdu/legal/api/LegalTagApiTests.java b/legal-core/src/test/java/org/opengroup/osdu/legal/api/LegalTagApiTests.java
index a62d12e01..1d48b3593 100644
--- a/legal-core/src/test/java/org/opengroup/osdu/legal/api/LegalTagApiTests.java
+++ b/legal-core/src/test/java/org/opengroup/osdu/legal/api/LegalTagApiTests.java
@@ -268,6 +268,6 @@ public class LegalTagApiTests {
     public void shouldCreateAuditLogs_when_getLegalTagProperties() {
         sut.getLegalTagProperties();
 
-        verify(auditLogger).readLegalPropertiesSuccess();
+        verify(auditLogger).readLegalPropertiesSuccess(any());
     }
 }
diff --git a/legal-core/src/test/java/org/opengroup/osdu/legal/logging/AuditLoggerTests.java b/legal-core/src/test/java/org/opengroup/osdu/legal/logging/AuditLoggerTests.java
index aba5c74aa..5d5220ea6 100644
--- a/legal-core/src/test/java/org/opengroup/osdu/legal/logging/AuditLoggerTests.java
+++ b/legal-core/src/test/java/org/opengroup/osdu/legal/logging/AuditLoggerTests.java
@@ -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());
     }
 
-- 
GitLab