Add partner-name header sending to SDC
Issue-ID: VID-253
Change-Id: I471ceea513b62f5bc83f8496e15b647f7d888926
Signed-off-by: Ittay Stern <ittay.stern@att.com>
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java b/vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java
index 9e139a0..96be591 100644
--- a/vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/asdc/rest/SdcRestClient.java
@@ -29,6 +29,7 @@
import static org.onap.vid.client.SyncRestClientInterface.HEADERS.CONTENT_TYPE;
import static org.onap.vid.client.SyncRestClientInterface.HEADERS.X_ECOMP_INSTANCE_ID;
import static org.onap.vid.client.UnirestPatchKt.extractRawAsString;
+import static org.onap.vid.logging.Headers.PARTNER_NAME;
import static org.onap.vid.utils.Logging.REQUEST_ID_HEADER_KEY;
import com.att.eelf.configuration.EELFLogger;
@@ -152,6 +153,7 @@
private Map<String, String> prepareHeaders(String auth, String contentType) {
return ImmutableMap.of(
X_ECOMP_INSTANCE_ID, SystemProperties.getProperty(APP_DISPLAY_NAME),
+ PARTNER_NAME.getHeaderName(), PARTNER_NAME.getHeaderValue(),
AUTHORIZATION, auth,
REQUEST_ID_HEADER_KEY, Logging.extractOrGenerateRequestId(),
CONTENT_TYPE, contentType
diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientITTest.java b/vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientITTest.java
index fd946eb..7cbf080 100644
--- a/vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientITTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/asdc/rest/SdcRestClientITTest.java
@@ -24,10 +24,14 @@
import static com.xebialabs.restito.semantics.Action.stringContent;
import static org.apache.http.client.config.RequestConfig.custom;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.hasItems;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.equalToIgnoringCase;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.matchesPattern;
import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
+import static org.hamcrest.collection.IsMapContaining.hasEntry;
+import static org.hamcrest.collection.IsMapContaining.hasKey;
+import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.onap.vid.client.SyncRestClientInterface.HEADERS.X_ECOMP_INSTANCE_ID;
@@ -125,10 +129,12 @@
assertTrue(first.isPresent());
- assertThat(first.get().getHeaders().keySet(),
- hasItems(X_ECOMP_INSTANCE_ID.toLowerCase(), REQUEST_ID_HEADER_KEY.toLowerCase()));
- assertThat(first.get().getHeaders().get(REQUEST_ID_HEADER_KEY.toLowerCase()).get(0),
- matchesPattern(UUID_REGEX));
+ assertThat(first.get().getHeaders(),
+ allOf(
+ hasEntry(equalToIgnoringCase(REQUEST_ID_HEADER_KEY), contains(matchesPattern(UUID_REGEX))),
+ hasKey(equalToIgnoringCase(X_ECOMP_INSTANCE_ID)),
+ hasEntry(equalToIgnoringCase("x-onap-partnerName"), contains(equalTo("VID.VID")))
+ ));
}
private Service getExpectedService(String stringId) {
diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/BasePresets/BaseSDCPreset.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/BasePresets/BaseSDCPreset.java
index d5f8b84..ad8dfb3 100644
--- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/BasePresets/BaseSDCPreset.java
+++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/BasePresets/BaseSDCPreset.java
@@ -1,12 +1,19 @@
package org.onap.simulator.presetGenerator.presets.BasePresets;
-/**
- * Created by itzikliderman on 27/12/2017.
- */
+import java.util.Map;
+
public abstract class BaseSDCPreset extends BasePreset {
@Override
protected String getRootPath() {
return "/sdc/v1/catalog/services";
}
+
+ @Override
+ public Map<String, String> getRequestHeaders() {
+ Map<String, String> map = super.getRequestHeaders();
+ map.put("X-ONAP-PartnerName", "VID.VID");
+ return map;
+ }
+
}