summaryrefslogtreecommitdiffstats
path: root/vid-automation
diff options
context:
space:
mode:
Diffstat (limited to 'vid-automation')
-rw-r--r--vid-automation/src/main/java/org/onap/vid/api/BaseApiTest.java24
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/ChangeManagementApiTest.java11
-rw-r--r--vid-automation/src/test/java/org/onap/vid/api/ChangeManagementUserApiLoggingTest.java1
-rw-r--r--vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java8
-rw-r--r--vid-automation/src/test/java/org/onap/vid/more/RequestIdFilterInstalled.java6
5 files changed, 37 insertions, 13 deletions
diff --git a/vid-automation/src/main/java/org/onap/vid/api/BaseApiTest.java b/vid-automation/src/main/java/org/onap/vid/api/BaseApiTest.java
index 3778e4b16..8492b9baa 100644
--- a/vid-automation/src/main/java/org/onap/vid/api/BaseApiTest.java
+++ b/vid-automation/src/main/java/org/onap/vid/api/BaseApiTest.java
@@ -77,9 +77,20 @@ public class BaseApiTest {
}
public void login(UserCredentials userCredentials) {
+ final List<ClientHttpRequestInterceptor> interceptors = loginWithChosenRESTClient(userCredentials, restTemplate);
+ restTemplateErrorAgnostic.setInterceptors(interceptors);
+ restTemplateErrorAgnostic.setErrorHandler(new DefaultResponseErrorHandler() {
+ @Override
+ public boolean hasError(ClientHttpResponse response) {
+ return false;
+ }
+ });
+ }
+
+ public List<ClientHttpRequestInterceptor> loginWithChosenRESTClient(UserCredentials userCredentials,RestTemplate givenRestTemplate) {
final List<ClientHttpRequestInterceptor> interceptors = singletonList(new CookieAndJsonHttpHeadersInterceptor(getUri(), userCredentials));
- restTemplate.setInterceptors(interceptors);
- restTemplate.setErrorHandler(new DefaultResponseErrorHandler() {
+ givenRestTemplate.setInterceptors(interceptors);
+ givenRestTemplate.setErrorHandler(new DefaultResponseErrorHandler() {
@Override
public void handleError(ClientHttpResponse response) throws IOException {
try {
@@ -90,14 +101,7 @@ public class BaseApiTest {
}
}
});
-
- restTemplateErrorAgnostic.setInterceptors(interceptors);
- restTemplateErrorAgnostic.setErrorHandler(new DefaultResponseErrorHandler() {
- @Override
- public boolean hasError(ClientHttpResponse response) {
- return false;
- }
- });
+ return interceptors;
}
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 7a4eedfa9..03c607d43 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
@@ -135,9 +135,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) {