summaryrefslogtreecommitdiffstats
path: root/catalog-fe/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-fe/src/test/java')
-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.
*/