summaryrefslogtreecommitdiffstats
path: root/catalog-fe/src/test/java/org
diff options
context:
space:
mode:
authorpriyanshu <pagarwal@amdocs.com>2018-07-29 19:58:44 +0300
committerMichael Lando <ml636r@att.com>2018-07-31 10:03:15 +0000
commita9fd70f3839766507a58e2eabb38c2d70b7a4330 (patch)
tree68432977585acaf9b4b1bcfc692308d2837a5278 /catalog-fe/src/test/java/org
parente7c8c7299e656e3f7e2d8aca69d0aa9400903e60 (diff)
SDC-WF API Integration via Proxy
SDC-WF Integration to call WF APIs via SDC Proxy Integration using extensibility Plugin configuration Change-Id: I06debeacef6ad681eaae131287df2aaa2f70a4fd Issue-ID: SDC-1535 Signed-off-by: priyanshu <pagarwal@amdocs.com>
Diffstat (limited to 'catalog-fe/src/test/java/org')
-rw-r--r--catalog-fe/src/test/java/org/openecomp/sdc/servlets/FeProxyServletTest.java31
1 files changed, 30 insertions, 1 deletions
diff --git a/catalog-fe/src/test/java/org/openecomp/sdc/servlets/FeProxyServletTest.java b/catalog-fe/src/test/java/org/openecomp/sdc/servlets/FeProxyServletTest.java
index 1e42fec42f..9597928fc0 100644
--- a/catalog-fe/src/test/java/org/openecomp/sdc/servlets/FeProxyServletTest.java
+++ b/catalog-fe/src/test/java/org/openecomp/sdc/servlets/FeProxyServletTest.java
@@ -28,6 +28,7 @@ import org.mockito.Mockito;
import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.fe.config.Configuration;
import org.openecomp.sdc.fe.config.ConfigurationManager;
+import org.openecomp.sdc.fe.config.PluginsConfiguration;
import org.openecomp.sdc.fe.servlets.FeProxyServlet;
import javax.servlet.ServletContext;
@@ -37,6 +38,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.*;
@@ -54,9 +56,11 @@ public class FeProxyServletTest {
final static ServletContext servletContext = Mockito.mock(ServletContext.class);
final static ConfigurationManager configurationManager = Mockito.mock(ConfigurationManager.class);
final static Configuration configuration = Mockito.mock(Configuration.class);
- final static Configuration.OnboardingConfig onboardingConfiguration = Mockito.mock(Configuration.OnboardingConfig.class);
+ final static Configuration.OnboardingConfig onboardingConfiguration = Mockito.mock(Configuration.OnboardingConfig.class);
final static Request proxyRequest = Mockito.spy(Request.class);
final static HttpFields httpFields = Mockito.mock(HttpFields.class);
+ private static final PluginsConfiguration pluginsConfiguration = Mockito.mock(PluginsConfiguration.class);
+ private static final PluginsConfiguration.Plugin plugin = Mockito.mock(PluginsConfiguration.Plugin.class);
final static String BE_PROTOCOL = "http";
final static String BE_HOST = "172.20.43.124";
@@ -64,6 +68,9 @@ public class FeProxyServletTest {
final static String ONBOARDING_BE_PROTOCOL = "http";
final static String ONBOARDING_BE_HOST = "172.20.43.125";
final static int ONBOARDING_BE_PORT = 8091;
+ final static String WF_PROTOCOL = "http";
+ final static String WF_HOST = "172.20.43.126";
+ final static int WF_PORT = 8092;
final static String HEADER_1 = "Header1";
final static String HEADER_2 = "Header2";
final static String HEADER_3 = "Header3";
@@ -102,6 +109,13 @@ public class FeProxyServletTest {
when(httpFields.containsKey(HEADER_2)).thenReturn(true);
when(httpFields.containsKey(HEADER_3)).thenReturn(false);
+ List<PluginsConfiguration.Plugin> pluginList = new ArrayList<PluginsConfiguration.Plugin>();
+ when(plugin.getPluginId()).thenReturn("WORKFLOW");
+ when(plugin.getPluginSourceUrl()).thenReturn(WF_PROTOCOL + "://" + WF_HOST + ":" + WF_PORT);
+ pluginList.add(plugin);
+ when(configurationManager.getPluginsConfiguration()).thenReturn(pluginsConfiguration);
+ when(pluginsConfiguration.getPluginsList()).thenReturn(pluginList);
+
}
@Test
@@ -175,6 +189,21 @@ public class FeProxyServletTest {
}
+ @Test
+ public void testRewriteURIWithWFAPIRequest() {
+ when(servletRequest.getRequestURI()).thenReturn("/sdc1/feProxy/wf/workflows");
+ String requestResourceUrl = "http://localhost:8080/sdc1/feProxy/wf/workflows";
+ String expectedChangedUrl = WF_PROTOCOL + "://" + WF_HOST + ":" + WF_PORT + "/wf/workflows";
+ when(servletRequest.getRequestURL()).thenReturn(new StringBuffer(requestResourceUrl));
+
+ when(servletRequest.getContextPath()).thenReturn("/sdc1");
+ when(servletRequest.getServletPath()).thenReturn("/feProxy/wf/workflows");
+
+ String rewriteURI = feProxy.rewriteTarget(servletRequest);
+
+ assertEquals(expectedChangedUrl, rewriteURI);
+ }
+
/**
* class for testing only exposes the protected method.
*/