summaryrefslogtreecommitdiffstats
path: root/catalog-fe/src
diff options
context:
space:
mode:
authorAvi Ziv <avi.ziv@amdocs.com>2018-03-15 13:21:44 +0200
committerMichael Lando <ml636r@att.com>2018-04-24 07:50:44 +0000
commitc175a0de2f05d37c1c774684318a525eb96bb59b (patch)
tree0c8bd736fdbcb512fefce93ec841fd3537336206 /catalog-fe/src
parent08d85958f46d1de9aec9cf459632b5be040063be (diff)
Create on boarding docker
Add BE and Cassandra init docker images Change-Id: Id9d767c73fc946819cec821b4634ce650cbb22fd Issue-ID: SDC-781 Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-fe/src')
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/Constants.java17
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/mdc/MdcData.java38
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/FeProxyServlet.java196
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/HealthCheckService.java8
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/SSLProxyServlet.java14
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/utils/BeProtocol.java14
-rw-r--r--catalog-fe/src/test/java/org/openecomp/sdc/servlets/FeProxyServletTest.java62
7 files changed, 248 insertions, 101 deletions
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/Constants.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/Constants.java
index a64ba08d69..e42644466e 100644
--- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/Constants.java
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/Constants.java
@@ -22,15 +22,14 @@ package org.openecomp.sdc.fe;
public class Constants {
- public static String HTTP_IV_USER = "HTTP_IV_USER";
- public static String USER_ID = "USER_ID";
- public static String ECOMP_PORTAL_COOKIE = "UserId";
- public static String HTTP_CSP_FIRSTNAME = "HTTP_CSP_FIRSTNAME";
- public static String HTTP_CSP_LASTNAME = "HTTP_CSP_LASTNAME";
- public static String HTTP_IV_REMOTE_ADDRESS = "HTTP_IV_REMOTE_ADDRESS";
- public static String HTTP_CSP_WSTYPE = "HTTP_CSP_WSTYPE";
- public static String HTTP_CSP_EMAIL = "HTTP_CSP_EMAIL";
-
+ public static final String HTTP_IV_USER = "HTTP_IV_USER";
+ public static final String USER_ID = "USER_ID";
+ public static final String ECOMP_PORTAL_COOKIE = "UserId";
+ public static final String HTTP_CSP_FIRSTNAME = "HTTP_CSP_FIRSTNAME";
+ public static final String HTTP_CSP_LASTNAME = "HTTP_CSP_LASTNAME";
+ public static final String HTTP_IV_REMOTE_ADDRESS = "HTTP_IV_REMOTE_ADDRESS";
+ public static final String HTTP_CSP_WSTYPE = "HTTP_CSP_WSTYPE";
+ public static final String HTTP_CSP_EMAIL = "HTTP_CSP_EMAIL";
public static final String WEBSEAL_USER_ID_HEADER = "csp-attuid";
}
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/mdc/MdcData.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/mdc/MdcData.java
new file mode 100644
index 0000000000..aa78a89eaf
--- /dev/null
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/mdc/MdcData.java
@@ -0,0 +1,38 @@
+package org.openecomp.sdc.fe.mdc;
+
+public class MdcData {
+ private String serviceInstanceID;
+ private String userId;
+ private String remoteAddr;
+ private String localAddr;
+ private Long transactionStartTime;
+
+ public MdcData(String serviceInstanceID, String userId, String remoteAddr, String localAddr, Long transactionStartTime) {
+ super();
+ this.serviceInstanceID = serviceInstanceID;
+ this.userId = userId;
+ this.remoteAddr = remoteAddr;
+ this.localAddr = localAddr;
+ this.transactionStartTime = transactionStartTime;
+ }
+
+ public Long getTransactionStartTime() {
+ return transactionStartTime;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public String getRemoteAddr() {
+ return remoteAddr;
+ }
+
+ public String getLocalAddr() {
+ return localAddr;
+ }
+
+ public String getServiceInstanceID() {
+ return serviceInstanceID;
+ }
+}
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/FeProxyServlet.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/FeProxyServlet.java
index f9ac666933..511592afe2 100644
--- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/FeProxyServlet.java
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/FeProxyServlet.java
@@ -20,7 +20,6 @@
package org.openecomp.sdc.fe.servlets;
-import java.net.URI;
import java.util.concurrent.TimeUnit;
import javax.servlet.http.HttpServletRequest;
@@ -28,10 +27,11 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.client.api.Response;
import org.openecomp.sdc.common.api.Constants;
-import org.openecomp.sdc.common.config.EcompErrorName;
import org.openecomp.sdc.fe.config.Configuration;
import org.openecomp.sdc.fe.config.ConfigurationManager;
import org.openecomp.sdc.fe.config.FeEcompErrorManager;
+import org.openecomp.sdc.fe.mdc.MdcData;
+import org.openecomp.sdc.fe.utils.BeProtocol;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
@@ -41,12 +41,30 @@ import com.google.common.cache.CacheBuilder;
public class FeProxyServlet extends SSLProxyServlet {
private static final long serialVersionUID = 1L;
- private static final String URL = "%s://%s:%s%s";
- private static Logger log = LoggerFactory.getLogger(FeProxyServlet.class.getName());
+ private static final String URL = "%s://%s%s%s";
+ private static final String ONBOARDING_CONTEXT = "/onboarding-api";
+ private static final String DCAED_CONTEXT = "/dcae-api";
+ private static final Logger log = LoggerFactory.getLogger(FeProxyServlet.class.getName());
private static Cache<String, MdcData> mdcDataCache = CacheBuilder.newBuilder().expireAfterWrite(10, TimeUnit.SECONDS).build();
+// @Override
+// public URI rewriteURI(HttpServletRequest request) {
+// try {
+// logFeRequest(request);
+// } catch (Exception e) {
+// FeEcompErrorManager.getInstance().logFeHttpLoggingError("FE Request");
+// log.error("Unexpected FE request logging error :", e);
+// }
+// String originalUrl = request.getRequestURL().toString();
+// String redirectedUrl = getModifiedUrl(request);
+//
+// log.debug("FeProxyServlet Redirecting request from: {} , to: {}", originalUrl, redirectedUrl);
+//
+// return URI.create(redirectedUrl);
+// }
+
@Override
- public URI rewriteURI(HttpServletRequest request) {
+ protected String rewriteTarget(HttpServletRequest request) {
try {
logFeRequest(request);
} catch (Exception e) {
@@ -58,18 +76,29 @@ public class FeProxyServlet extends SSLProxyServlet {
log.debug("FeProxyServlet Redirecting request from: {} , to: {}", originalUrl, redirectedUrl);
- return URI.create(redirectedUrl);
+ return redirectedUrl;
}
+// @Override
+// protected void onResponseSuccess(HttpServletRequest request, HttpServletResponse response, Response proxyResponse) {
+// try {
+// logFeResponse(request, proxyResponse);
+// } catch (Exception e) {
+// FeEcompErrorManager.getInstance().logFeHttpLoggingError("FE Response");
+// log.error("Unexpected FE response logging error :", e);
+// }
+// super.onResponseSuccess(request, response, proxyResponse);
+// }
+//protected void onProxyResponseSuccess(HttpServletRequest clientRequest, HttpServletResponse proxyResponse, Response serverResponse) {
@Override
- protected void onResponseSuccess(HttpServletRequest request, HttpServletResponse response, Response proxyResponse) {
+ protected void onProxyResponseSuccess(HttpServletRequest request, HttpServletResponse proxyResponse, Response response) {
try {
- logFeResponse(request, proxyResponse);
+ logFeResponse(request, response);
} catch (Exception e) {
FeEcompErrorManager.getInstance().logFeHttpLoggingError("FE Response");
log.error("Unexpected FE response logging error :", e);
}
- super.onResponseSuccess(request, response, proxyResponse);
+ super.onProxyResponseSuccess(request, proxyResponse, response);
}
private void logFeRequest(HttpServletRequest httpRequest) {
@@ -135,79 +164,104 @@ public class FeProxyServlet extends SSLProxyServlet {
MDC.put("timer", transactionStartTime);
}
- private class MdcData {
- private String serviceInstanceID;
- private String userId;
- private String remoteAddr;
- private String localAddr;
- private Long transactionStartTime;
-
- public MdcData(String serviceInstanceID, String userId, String remoteAddr, String localAddr, Long transactionStartTime) {
- super();
- this.serviceInstanceID = serviceInstanceID;
- this.userId = userId;
- this.remoteAddr = remoteAddr;
- this.localAddr = localAddr;
- this.transactionStartTime = transactionStartTime;
+ private String getModifiedUrl(HttpServletRequest request) {
+ Configuration config = getConfiguration(request);
+ if (config == null) {
+ log.error("failed to retrive configuration.");
+ throw new RuntimeException("failed to read FE configuration");
}
-
- public Long getTransactionStartTime() {
- return transactionStartTime;
+ String uri = request.getRequestURI();
+ String protocol;
+ String host;
+ String port;
+ if (uri.contains(ONBOARDING_CONTEXT)){
+ uri = uri.replace("/sdc1/feProxy"+ONBOARDING_CONTEXT,ONBOARDING_CONTEXT);
+ protocol = config.getOnboarding().getProtocolBe();
+ host = config.getOnboarding().getHostBe();
+ port = config.getOnboarding().getPortBe().toString();
}
-
- public String getUserId() {
- return userId;
+ else if(uri.contains(DCAED_CONTEXT)){
+ uri = uri.replace("/sdc1/feProxy"+DCAED_CONTEXT,DCAED_CONTEXT);
+ protocol = config.getBeProtocol();
+ host = config.getBeHost();
+ if (config.getBeProtocol().equals(BeProtocol.HTTP.getProtocolName())) {
+ port = config.getBeHttpPort().toString();
+ } else {
+ port = config.getBeSslPort().toString();
+ }
}
+ else{
+ uri = uri.replace("/sdc1/feProxy","/sdc2");
+ protocol = config.getBeProtocol();
+ host = config.getBeHost();
+ if (config.getBeProtocol().equals(BeProtocol.HTTP.getProtocolName())) {
+ port = config.getBeHttpPort().toString();
+ } else {
+ port = config.getBeSslPort().toString();
+ }
- public String getRemoteAddr() {
- return remoteAddr;
}
- public String getLocalAddr() {
- return localAddr;
- }
+ String authority = getAuthority(host, port);
+ String queryString = getQueryString(request);
+ return String.format(URL,protocol,authority,uri,queryString);
+
+
+
+
+// String scheme = config.getBeProtocol();
+// String uri = request.getRequestURI().toString();
+// StringBuilder url = new StringBuilder();
+// url.append(scheme).append("://").append(config.getBeHost());
+// url.append(":");
+// if (config.getBeProtocol().equals(BeProtocol.HTTP.getProtocolName())) {
+// url.append(config.getBeHttpPort());
+// } else {
+// url.append(config.getBeSslPort());
+// }
+// url.append(uri);
+// String queryString = request.getQueryString(); // d=789
+// if (queryString != null) {
+// url.append("?").append(queryString);
+// }
+//
+// String redirectedUrl = url.toString();
+// String onboardingForwardContext = config.getOnboardingForwardContext();
+// if (onboardingForwardContext == null || onboardingForwardContext.isEmpty()) {
+// onboardingForwardContext = "/onboarding-api";
+// }
+// redirectedUrl = redirectedUrl.replace("/sdc1/feProxy/dcae-api", "/dcae");
+// redirectedUrl = redirectedUrl.replace("/sdc1/feProxy/onboarding-api", onboardingForwardContext);
+// redirectedUrl = redirectedUrl.replace("/sdc1/feProxy", "/sdc2");
+// return redirectedUrl;
- public String getServiceInstanceID() {
- return serviceInstanceID;
- }
}
- public String getModifiedUrl(HttpServletRequest request) {
- Configuration config = getConfiguration(request);
- if (config == null) {
- log.error("failed to retrive configuration.");
- }
- String scheme = config.getBeProtocol();
- String uri = request.getRequestURI().toString();
- StringBuilder url = new StringBuilder();
- url.append(scheme).append("://").append(config.getBeHost());
- url.append(":");
- if (config.getBeProtocol().equals(BE_PROTOCOL.HTTP.getProtocolName())) {
- url.append(config.getBeHttpPort());
- } else {
- url.append(config.getBeSslPort());
- }
- url.append(uri);
- String queryString = request.getQueryString(); // d=789
- if (queryString != null) {
- url.append("?").append(queryString);
- }
-
- String redirectedUrl = url.toString();
- String onboardingForwardContext = config.getOnboardingForwardContext();
- if (onboardingForwardContext == null || onboardingForwardContext.isEmpty()) {
- onboardingForwardContext = "/onboarding-api";
- }
- redirectedUrl = redirectedUrl.replace("/sdc1/feProxy/dcae-api", "/dcae");
- redirectedUrl = redirectedUrl.replace("/sdc1/feProxy/onboarding-api", onboardingForwardContext);
- redirectedUrl = redirectedUrl.replace("/sdc1/feProxy", "/sdc2");
- return redirectedUrl;
+ private Configuration getConfiguration(HttpServletRequest request) {
+ return ((ConfigurationManager) request.getSession().getServletContext().getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).getConfiguration();
}
- private Configuration getConfiguration(HttpServletRequest request) {
- Configuration config = ((ConfigurationManager) request.getSession().getServletContext().getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).getConfiguration();
- return config;
- }
+ private String getAuthority(String host, String port) {
+ String authority;
+ if (port==null){
+ authority=host;
+ }
+ else{
+ authority=host+":"+port;
+ }
+ return authority;
+ }
+
+ private String getQueryString(HttpServletRequest request) {
+ String queryString = request.getQueryString();
+ if (queryString != null) {
+ queryString="?"+queryString;
+ }
+ else{
+ queryString="";
+ }
+ return queryString;
+ }
}
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/HealthCheckService.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/HealthCheckService.java
index fce5d35d20..7f5ea06b97 100644
--- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/HealthCheckService.java
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/HealthCheckService.java
@@ -295,10 +295,10 @@ public class HealthCheckService {
Configuration.OnboardingConfig onboardingConfig = config.getOnboarding();
if (onboardingConfig != null) {
- String protocol = onboardingConfig.getProtocol();
- String host = onboardingConfig.getHost();
- Integer port = onboardingConfig.getPort();
- String uri = onboardingConfig.getHealthCheckUri();
+ String protocol = onboardingConfig.getProtocolFe();
+ String host = onboardingConfig.getHostFe();
+ Integer port = onboardingConfig.getPortFe();
+ String uri = onboardingConfig.getHealthCheckUriFe();
return protocol + "://" + host + ":" + port + uri;
}
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/SSLProxyServlet.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/SSLProxyServlet.java
index c3ba279c8c..4edcfe1286 100644
--- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/SSLProxyServlet.java
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/SSLProxyServlet.java
@@ -33,6 +33,7 @@ import org.eclipse.jetty.util.ssl.SslContextFactory;
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.utils.BeProtocol;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -41,18 +42,7 @@ public abstract class SSLProxyServlet extends ProxyServlet {
private static final long serialVersionUID = 1L;
private static Logger log = LoggerFactory.getLogger(SSLProxyServlet.class.getName());
- public enum BE_PROTOCOL {
- HTTP("http"), SSL("ssl");
- private String protocolName;
- public String getProtocolName() {
- return protocolName;
- }
-
- BE_PROTOCOL(String protocolName) {
- this.protocolName = protocolName;
- }
- };
@Override
public void customizeProxyRequest(Request proxyRequest, HttpServletRequest request) {
@@ -77,7 +67,7 @@ public abstract class SSLProxyServlet extends ProxyServlet {
protected HttpClient createHttpClient() throws ServletException {
Configuration config = ((ConfigurationManager) getServletConfig().getServletContext()
.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).getConfiguration();
- boolean isSecureClient = !config.getBeProtocol().equals(BE_PROTOCOL.HTTP.getProtocolName());
+ boolean isSecureClient = !config.getBeProtocol().equals(BeProtocol.HTTP.getProtocolName());
HttpClient client = (isSecureClient) ? getSecureHttpClient() : super.createHttpClient();
setTimeout(600000);
client.setIdleTimeout(600000);
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/utils/BeProtocol.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/utils/BeProtocol.java
new file mode 100644
index 0000000000..923728672e
--- /dev/null
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/utils/BeProtocol.java
@@ -0,0 +1,14 @@
+package org.openecomp.sdc.fe.utils;
+
+public enum BeProtocol {
+ HTTP("http"), SSL("ssl");
+ private String protocolName;
+
+ public String getProtocolName() {
+ return protocolName;
+ }
+
+ BeProtocol(String protocolName) {
+ this.protocolName = protocolName;
+ }
+ }; \ No newline at end of file
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 4c4eb1ca2a..f3bd9a75b8 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
@@ -52,18 +52,22 @@ public class FeProxyServletTest {
* http://localhost:8080/sdc1/feProxy/dummy/not/working -->
* http://localhost:8090/sdc2/dummy/not/working
*/
- FeProxyServlet feProxy = new FeProxyServlet();
+ FeProxyServletForTest feProxy = new FeProxyServletForTest();
final static HttpServletRequest servletRequest = Mockito.mock(HttpServletRequest.class);
final static HttpSession httpSession = Mockito.mock(HttpSession.class);
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 Request proxyRequest = Mockito.spy(Request.class);
final static HttpFields httpFields = Mockito.mock(HttpFields.class);
final static String BE_PROTOCOL = "http";
final static String BE_HOST = "172.20.43.124";
final static int BE_PORT = 8090;
+ 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 HEADER_1 = "Header1";
final static String HEADER_2 = "Header2";
final static String HEADER_3 = "Header3";
@@ -81,6 +85,10 @@ public class FeProxyServletTest {
when(configuration.getBeProtocol()).thenReturn(BE_PROTOCOL);
when(configuration.getBeHost()).thenReturn(BE_HOST);
when(configuration.getBeHttpPort()).thenReturn(BE_PORT);
+ when(configuration.getOnboarding()).thenReturn(onboardingConfiguration);
+ when(configuration.getOnboarding().getProtocolBe()).thenReturn(ONBOARDING_BE_PROTOCOL);
+ when(configuration.getOnboarding().getHostBe()).thenReturn(ONBOARDING_BE_HOST);
+ when(configuration.getOnboarding().getPortBe()).thenReturn(ONBOARDING_BE_PORT);
List<String> strList = new ArrayList<String>();
strList.add(HEADER_1);
@@ -110,13 +118,44 @@ public class FeProxyServletTest {
when(servletRequest.getContextPath()).thenReturn("/sdc1");
when(servletRequest.getServletPath()).thenReturn("/feProxy/rest/dummyBeAPI");
- URI rewriteURI = feProxy.rewriteURI(servletRequest);
+ String rewriteURI = feProxy.rewriteTarget(servletRequest);
- assertTrue(rewriteURI.toString().equals(expectedChangedUrl));
+ assertTrue(rewriteURI.equals(expectedChangedUrl));
}
@Test
+ public void testRewriteURIWithOnboardingAPIRequest() {
+ when(servletRequest.getRequestURI()).thenReturn("/sdc1/feProxy/onboarding-api/gg%20g?subtype=VF");
+ String requestResourceUrl = "http://localhost:8080/sdc1/feProxy/onboarding-api/gg%20g?subtype=VF";
+ String expectedChangedUrl = ONBOARDING_BE_PROTOCOL + "://" + ONBOARDING_BE_HOST + ":" + ONBOARDING_BE_PORT + "/onboarding-api/gg%20g?subtype=VF";
+ when(servletRequest.getRequestURL()).thenReturn(new StringBuffer(requestResourceUrl));
+
+ when(servletRequest.getContextPath()).thenReturn("/sdc1");
+ when(servletRequest.getServletPath()).thenReturn("/feProxy/onboarding-api/gg%20g?subtype=VF");
+
+ String rewriteURI = feProxy.rewriteTarget(servletRequest);
+
+ assertTrue(rewriteURI.equals(expectedChangedUrl));
+ }
+
+
+ @Test
public void testRewriteURIWithQureyParam_APIRequest() {
+ when(servletRequest.getRequestURI()).thenReturn("/sdc1/feProxy/dcae-api/gg%20g?subtype=VF");
+ String requestResourceUrl = "http://localhost:8080/sdc1/feProxy/dcae-api/gg%20g?subtype=VF";
+ String expectedChangedUrl = BE_PROTOCOL + "://" + BE_HOST + ":" + BE_PORT + "/dcae-api/gg%20g?subtype=VF";
+ when(servletRequest.getRequestURL()).thenReturn(new StringBuffer(requestResourceUrl));
+
+ when(servletRequest.getContextPath()).thenReturn("/sdc1");
+ when(servletRequest.getServletPath()).thenReturn("/feProxy/dcae-api/gg%20g?subtype=VF");
+
+ String rewriteURI = feProxy.rewriteTarget(servletRequest);
+
+ assertTrue(rewriteURI.equals(expectedChangedUrl));
+ }
+
+ @Test
+ public void testRewriteTargetWithRedeirectAPIRequest() {
when(servletRequest.getRequestURI()).thenReturn("/sdc1/feProxy/rest/gg%20g?subtype=VF");
String requestResourceUrl = "http://localhost:8080/sdc1/feProxy/rest/gg%20g?subtype=VF";
String expectedChangedUrl = BE_PROTOCOL + "://" + BE_HOST + ":" + BE_PORT + "/sdc2/rest/gg%20g?subtype=VF";
@@ -125,11 +164,13 @@ public class FeProxyServletTest {
when(servletRequest.getContextPath()).thenReturn("/sdc1");
when(servletRequest.getServletPath()).thenReturn("/feProxy/rest/gg%20g?subtype=VF");
- URI rewriteURI = feProxy.rewriteURI(servletRequest);
+ String rewriteURI = feProxy.rewriteTarget(servletRequest);
- assertTrue(rewriteURI.toString().equals(expectedChangedUrl));
+ assertTrue(rewriteURI.equals(expectedChangedUrl));
}
+
+
@Test
public void testCustomizeProxyRequest() {
feProxy.customizeProxyRequest(proxyRequest, servletRequest);
@@ -137,4 +178,15 @@ public class FeProxyServletTest {
verify(proxyRequest, times(1)).header(Mockito.anyString(), Mockito.anyString());
}
+
+ /**
+ * class for testing only exposes the protected method.
+ */
+ public static class FeProxyServletForTest extends FeProxyServlet{
+
+ @Override
+ public String rewriteTarget(HttpServletRequest request) {
+ return super.rewriteTarget(request);
+ }
+ }
}