summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java22
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java7
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestHeadersTest.java22
-rw-r--r--vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/BasePresets/BaseMSOPreset.java1
4 files changed, 18 insertions, 34 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java b/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java
index 91b288998..0585a4736 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java
@@ -20,10 +20,6 @@
package org.onap.vid.mso;
-import static org.onap.vid.logging.Headers.INVOCATION_ID;
-import static org.onap.vid.logging.Headers.PARTNER_NAME;
-import static org.onap.vid.utils.Logging.ONAP_REQUEST_ID_HEADER_KEY;
-import static org.onap.vid.utils.Logging.REQUEST_ID_HEADER_KEY;
import static org.onap.vid.utils.Logging.getMethodCallerName;
import static org.onap.vid.utils.Logging.getMethodName;
@@ -40,6 +36,7 @@ import javax.ws.rs.core.Response;
import org.apache.commons.codec.binary.Base64;
import org.eclipse.jetty.util.security.Password;
import org.glassfish.jersey.client.ClientProperties;
+import org.onap.logging.filter.base.MetricLogClientFilter;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.vid.aai.util.HttpClientMode;
import org.onap.vid.aai.util.HttpsAuthClient;
@@ -107,12 +104,8 @@ public class RestMsoImplementation {
MultivaluedHashMap<String, Object> commonHeaders = new MultivaluedHashMap();
commonHeaders.put("Authorization", Collections.singletonList(("Basic " + authStringEnc)));
- commonHeaders.put(PARTNER_NAME.getHeaderName(), Collections.singletonList(PARTNER_NAME.getHeaderValue()));
String requestIdValue = Logging.extractOrGenerateRequestId();
- commonHeaders.put(REQUEST_ID_HEADER_KEY, Collections.singletonList(requestIdValue));
- commonHeaders.put(ONAP_REQUEST_ID_HEADER_KEY, Collections.singletonList(requestIdValue));
- commonHeaders.put(INVOCATION_ID.getHeaderName(), Collections.singletonList(INVOCATION_ID.getHeaderValue()));
boolean useSsl = true;
if ( (mso_url != null) && ( !(mso_url.isEmpty()) ) ) {
@@ -121,11 +114,13 @@ public class RestMsoImplementation {
if (client == null) {
try {
- if ( useSsl ) {
- client = httpsAuthClient.getClient(HttpClientMode.WITHOUT_KEYSTORE);
- }
+ if ( useSsl ) {
+ client = httpsAuthClient.getClient(HttpClientMode.WITHOUT_KEYSTORE);
+ registerClientToMetricLogClientFilter(client);
+ }
else {
client = HttpBasicClient.getClient();
+ registerClientToMetricLogClientFilter(client);
}
} catch (Exception e) {
logger.info(EELFLoggerDelegate.errorLogger,methodname + " Unable to get the SSL client");
@@ -135,6 +130,11 @@ public class RestMsoImplementation {
return commonHeaders;
}
+ private void registerClientToMetricLogClientFilter(Client client) {
+ MetricLogClientFilter metricLogClientFilter = new MetricLogClientFilter();
+ client.register(metricLogClientFilter);
+ }
+
public <T> RestObject<T> GetForObject(String path, Class<T> clazz) {
final String methodName = getMethodName();
logger.debug(EELFLoggerDelegate.debugLogger, "start {}->{}({}, {})", getMethodCallerName(), methodName, path, clazz);
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java
index 792435002..2e321f93e 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/RestMsoImplementationTest.java
@@ -22,6 +22,7 @@
package org.onap.vid.mso;
import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
@@ -30,6 +31,7 @@ import static org.mockito.MockitoAnnotations.initMocks;
import io.joshworks.restclient.request.HttpRequest;
import java.io.IOException;
import java.security.GeneralSecurityException;
+import java.util.List;
import java.util.Optional;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.Entity;
@@ -39,6 +41,7 @@ import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.JerseyInvocation;
+import org.hamcrest.MatcherAssert;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.onap.vid.aai.util.HttpClientMode;
@@ -99,7 +102,9 @@ public class RestMsoImplementationTest {
MultivaluedHashMap<String, Object> result = restMsoImplementation.initMsoClient();
// then
- assertThat(result).containsKeys("Authorization","X-ONAP-PartnerName");
+ List<Object> authorizationHeaders = result.get("Authorization");
+ MatcherAssert.assertThat(authorizationHeaders, hasSize(1));
+ assertThat((String) authorizationHeaders.get(0)).startsWith("Basic ");
assertThat(result).doesNotContainKey("notExistingKey");
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestHeadersTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestHeadersTest.java
index cfb9ee6ea..fd66dab52 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestHeadersTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/OutgoingRequestHeadersTest.java
@@ -151,28 +151,6 @@ public class OutgoingRequestHeadersTest {
).map(l -> ImmutableList.of(l).toArray()).collect(Collectors.toList()).toArray(new Object[][]{});
}
- @Test(dataProvider = "msoMethods")
- public void mso(Consumer<RestMsoImplementation> f) throws Exception {
- final TestUtils.JavaxRsClientMocks mocks = setAndGetMocksInsideRestImpl(restMsoImplementation);
-
- f.accept(restMsoImplementation);
- HeadersVerifier headersVerifier = new HeadersVerifier().verifyFirstCall(mocks.getFakeBuilder());
-
- assertThat((String) captureHeaderKeyAndReturnItsValue(mocks.getFakeBuilder(), "Authorization"), startsWith("Basic "));
-
- //verify requestId is same in next call but invocationId is different
-
- //given
- final TestUtils.JavaxRsClientMocks mocks2 = setAndGetMocksInsideRestImpl(restMsoImplementation);
-
- //when
- f.accept(restMsoImplementation);
- //then
- headersVerifier.verifySecondCall(mocks2.getFakeBuilder());
- }
-
-
-
@Test
public void whenProvideMsoRestCallUserId_builderHasXRequestorIDHeader() throws Exception {
diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/BasePresets/BaseMSOPreset.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/BasePresets/BaseMSOPreset.java
index 2bc664591..1cfdd8866 100644
--- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/BasePresets/BaseMSOPreset.java
+++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/BasePresets/BaseMSOPreset.java
@@ -48,6 +48,7 @@ public abstract class BaseMSOPreset extends BasePreset {
public Map<String, String> getRequestHeaders() {
Map<String, String> map = super.getRequestHeaders();
map.put("X-ONAP-PartnerName", "VID.VID");
+ map.put("X-ECOMP-RequestID", "[0-9a-fA-F]{8}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{12}");
return map;
}
}