From 5e0e88d7c19479494215af17d23e07b26dd62dbc Mon Sep 17 00:00:00 2001 From: Amir Skalka Date: Mon, 4 Nov 2019 14:26:17 +0200 Subject: [PATCH] Validate audit of request id on incoming requests to MSO ServiceInstanceMsoApiTest to verify incoming requests in audit log as well to headers and outgoing requests in logs. Issue-ID: VID-253 Change-Id: I4d94e6de4e2a844f2e0104df6c45b5070465de1e Signed-off-by: Amir Skalka --- .../src/test/java/org/onap/vid/api/AaiApiTest.java | 5 +++-- .../src/test/java/org/onap/vid/api/SdcApiTest.java | 5 +++-- .../org/onap/vid/api/ServiceInstanceMsoApiTest.java | 1 + .../test/java/org/onap/vid/more/LoggerFormatTest.java | 17 +++++++++++++++++ 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/vid-automation/src/test/java/org/onap/vid/api/AaiApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/AaiApiTest.java index 39110c550..05d73a619 100644 --- a/vid-automation/src/test/java/org/onap/vid/api/AaiApiTest.java +++ b/vid-automation/src/test/java/org/onap/vid/api/AaiApiTest.java @@ -774,11 +774,12 @@ public class AaiApiTest extends BaseApiAaiTest { new PresetAAIGetVpnsByType(), new PresetAAIGetSubscribersGet() ),CLEAR_THEN_SET); - - String url = uri + "/aai_get_vpn_list"; + String internalPath = "/aai_get_vpn_list"; + String url = uri + internalPath; ResponseEntity response = restTemplate.getForEntity(url, String.class); final String requestId = response.getHeaders().getFirst("X-ECOMP-RequestID-echo"); LoggerFormatTest.assertHeadersAndMetricLogs(restTemplate, uri, requestId,"/network/vpn-bindings" , 1); + LoggerFormatTest.verifyExistenceOfIncomingReqsInAuditLogs(restTemplate, uri, requestId, internalPath); } @Test diff --git a/vid-automation/src/test/java/org/onap/vid/api/SdcApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/SdcApiTest.java index f22b6de65..858b2f8ef 100644 --- a/vid-automation/src/test/java/org/onap/vid/api/SdcApiTest.java +++ b/vid-automation/src/test/java/org/onap/vid/api/SdcApiTest.java @@ -220,7 +220,7 @@ public class SdcApiTest extends BaseApiTest { public void whenCallSdc_thenRequestRecordedInMetricsLog() { ModelInfo modelInfo = ModelInfo.transportWithPnfsService; - + String internalPath = SDC_GET_SERVICE_MODEL + modelInfo.modelVersionId; registerExpectationFromPresets(ImmutableList.of( new PresetSDCGetServiceToscaModelGet(modelInfo), new PresetSDCGetServiceMetadataGet(modelInfo), @@ -228,11 +228,12 @@ public class SdcApiTest extends BaseApiTest { ), CLEAR_THEN_SET); ResponseEntity response = restTemplate.getForEntity( - buildUri(SDC_GET_SERVICE_MODEL + modelInfo.modelVersionId), String.class); + buildUri(internalPath), String.class); final String requestId = response.getHeaders().getFirst("X-ECOMP-RequestID-echo"); LoggerFormatTest.assertHeadersAndMetricLogs(restTemplate, uri, requestId, SDC_ROOT_PATH, 2); + LoggerFormatTest.verifyExistenceOfIncomingReqsInAuditLogs(restTemplate, uri, requestId, internalPath); } } diff --git a/vid-automation/src/test/java/org/onap/vid/api/ServiceInstanceMsoApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/ServiceInstanceMsoApiTest.java index 28b407697..8bc2a7390 100644 --- a/vid-automation/src/test/java/org/onap/vid/api/ServiceInstanceMsoApiTest.java +++ b/vid-automation/src/test/java/org/onap/vid/api/ServiceInstanceMsoApiTest.java @@ -139,6 +139,7 @@ public class ServiceInstanceMsoApiTest extends BaseMsoApiTest{ ResponseEntity responseEntity = restTemplate.postForEntity(buildUri(MSO_ACTIVATE_FABRIC_CONFIGURATION), requestBody, String.class); String requestId = responseEntity.getHeaders().getFirst("X-ECOMP-RequestID-echo"); LoggerFormatTest.assertHeadersAndMetricLogs(restTemplate, uri, requestId, msoRootPath, 1); + LoggerFormatTest.verifyExistenceOfIncomingReqsInAuditLogs(restTemplate, uri, requestId, MSO_ACTIVATE_FABRIC_CONFIGURATION); } @Test(dataProvider = "errorCodes") diff --git a/vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java b/vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java index a233f255e..7a4eedfa9 100644 --- a/vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java +++ b/vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java @@ -131,6 +131,23 @@ public class LoggerFormatTest extends BaseApiTest { return lines; } + public static void verifyExistenceOfIncomingReqsInAuditLogs(RestTemplate restTemplate, URI uri, String requestId, + String path){ + List logLines = getRequestLogLines(requestId, LogName.audit2019, restTemplate, uri); + String requestIdPrefix = "RequestID="; + assertThat("request id must be found in exactly two rows - entry & exit message in audit log, and include the req path", + logLines, + containsInRelativeOrder( + allOf( + containsString(requestIdPrefix+requestId), + containsString("ENTRY"), + containsString(path)), + allOf( + containsString(requestIdPrefix+requestId), + containsString("EXIT"), + containsString(path)) + )); + } public static void assertHeadersAndMetricLogs(RestTemplate restTemplate, URI uri, String requestId, String path, int requestsSize) { List logLines = -- 2.16.6