diff options
author | Ittay Stern <ittay.stern@att.com> | 2019-11-07 14:17:41 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-11-07 14:17:41 +0000 |
commit | ebef5249cb9d282ace976feac8517a7b44add450 (patch) | |
tree | 42eec74e3d514f093861abfe94be176acf1fdae6 /vid-automation/src/test/java/org | |
parent | 31e625a118836d02a95b18ff806903ed23deb25d (diff) | |
parent | a868f407c6b80ea0c533fc534d45b9e04e69521a (diff) |
Merge "Validations in different tests for audit log"
Diffstat (limited to 'vid-automation/src/test/java/org')
4 files changed, 23 insertions, 3 deletions
diff --git a/vid-automation/src/test/java/org/onap/vid/api/ChangeManagementApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/ChangeManagementApiTest.java index 7490c0610..b7f28f820 100644 --- a/vid-automation/src/test/java/org/onap/vid/api/ChangeManagementApiTest.java +++ b/vid-automation/src/test/java/org/onap/vid/api/ChangeManagementApiTest.java @@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet; import org.onap.simulator.presetGenerator.presets.mso.changeManagement.PresetMsoChangeManagementBase; import org.onap.simulator.presetGenerator.presets.mso.changeManagement.PresetMsoVnfInPlaceSoftwareUpdate; import org.onap.simulator.presetGenerator.presets.mso.changeManagement.PresetMsoVnfReplace; @@ -11,8 +12,10 @@ import org.onap.simulator.presetGenerator.presets.mso.changeManagement.PresetMso import org.onap.simulator.presetGenerator.presets.aaf.*; import org.onap.vid.model.mso.*; import org.onap.vid.model.workflow.*; +import org.onap.vid.more.LoggerFormatTest; import org.springframework.http.HttpStatus; import org.springframework.util.StopWatch; +import org.springframework.web.client.RestTemplate; import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; @@ -470,6 +473,14 @@ public class ChangeManagementApiTest extends BaseApiTest { Response response = callChangeManagementUpdate(vnfIds, changeManagementRequest); MsoResponseWrapper2 body = response.readEntity(MsoResponseWrapper2.class); assertForHappyPath(vnfIds, body, requestType); + RestTemplate manualRestTemplate = new RestTemplate(); + super.loginWithChosenRESTClient(getUserCredentials(), manualRestTemplate); + SimulatorApi.registerExpectationFromPreset( new PresetAAIGetSubscribersGet(), RegistrationStrategy.APPEND); + LoggerFormatTest + .verifyExistenceOfIncomingReqsInAuditLogs(manualRestTemplate, uri, + response.getHeaders().get("X-ECOMP-RequestID-echo").get(0).toString(), + "/vid/change-management/workflow/VidVnf"); + } private ChangeManagementRequest createChangeManagementRequest(VnfIds vnfDetails, String requestType) { diff --git a/vid-automation/src/test/java/org/onap/vid/api/ChangeManagementUserApiLoggingTest.java b/vid-automation/src/test/java/org/onap/vid/api/ChangeManagementUserApiLoggingTest.java index dd58e8198..ac8584406 100644 --- a/vid-automation/src/test/java/org/onap/vid/api/ChangeManagementUserApiLoggingTest.java +++ b/vid-automation/src/test/java/org/onap/vid/api/ChangeManagementUserApiLoggingTest.java @@ -41,6 +41,7 @@ public class ChangeManagementUserApiLoggingTest extends BaseApiTest { String requestId = responseEntity.getHeaders().getFirst("X-ECOMP-RequestID-echo"); LoggerFormatTest.assertHeadersAndMetricLogs(restTemplate, uri, requestId, "/mso/orchestrationRequests/", 2); + LoggerFormatTest.verifyExistenceOfIncomingReqsInAuditLogs(restTemplate, uri, requestId, CHANGE_MANAGEMENT + MSO); } @Test 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 6c4058f1e..1105a3f4c 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 @@ -162,9 +162,13 @@ public class LoggerFormatTest extends BaseApiTest { String path){ List<String> 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", + assertThat("\nENTRY & EXIT logs are expected to include RequestId: " + requestId + + " \nAnd request path: " + + path + + "\nin exactly two rows - inside the audit log matching lines:\n" + + String.join("\n", logLines) + "\n", logLines, - containsInRelativeOrder( + contains( allOf( containsString(requestIdPrefix+requestId), containsString("ENTRY"), diff --git a/vid-automation/src/test/java/org/onap/vid/more/RequestIdFilterInstalled.java b/vid-automation/src/test/java/org/onap/vid/more/RequestIdFilterInstalled.java index 93ab14036..d4a1ce3f8 100644 --- a/vid-automation/src/test/java/org/onap/vid/more/RequestIdFilterInstalled.java +++ b/vid-automation/src/test/java/org/onap/vid/more/RequestIdFilterInstalled.java @@ -136,10 +136,14 @@ public class RequestIdFilterInstalled extends BaseApiTest { @Test public void healthcheck_doGET_RequestIdReceived() { + String path = "/healthCheck"; final Pair<HttpEntity, String> responseAndUuid = makeRequest( - HttpMethod.GET, "/healthCheck", null + HttpMethod.GET, path, null ); assertThatUuidInResponseAndUuidIsInARecentLog(LogName.audit2019, responseAndUuid); + LoggerFormatTest + .verifyExistenceOfIncomingReqsInAuditLogs(restTemplate, uri, + responseAndUuid.getKey().getHeaders().get("X-ECOMP-RequestID-echo").get(0).toString(), path); } private void assertThatUuidInResponseAndUuidIsInARecentLog(LogName logName, Pair<HttpEntity, String> responseAndUuid) { |