From a868f407c6b80ea0c533fc534d45b9e04e69521a Mon Sep 17 00:00:00 2001 From: Amir Skalka Date: Tue, 5 Nov 2019 11:19:37 +0200 Subject: Validations in different tests for audit log ChangeManagementApi/UserApi to verify incoming requests in audit log. Refactor assert message and contains method for validation Add audit logging validation to Health Check test Refactor audit log validation according to code review comments Fix the test of Add audit logging validation to Health Check test Issue-ID: VID-253 Signed-off-by: Amir Skalka Change-Id: I0379520054b65f2141745579a14690bdc4824655 --- .../main/java/org/onap/vid/api/BaseApiTest.java | 24 +++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'vid-automation/src/main/java/org') 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 interceptors = loginWithChosenRESTClient(userCredentials, restTemplate); + restTemplateErrorAgnostic.setInterceptors(interceptors); + restTemplateErrorAgnostic.setErrorHandler(new DefaultResponseErrorHandler() { + @Override + public boolean hasError(ClientHttpResponse response) { + return false; + } + }); + } + + public List loginWithChosenRESTClient(UserCredentials userCredentials,RestTemplate givenRestTemplate) { final List 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; } -- cgit 1.2.3-korg