aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-fe/src
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2018-07-29 16:13:45 +0300
committerMichael Lando <ml636r@att.com>2018-07-29 16:20:34 +0300
commit5b593496b8f1b8e8be8d7d2dbcc223332e65a49b (patch)
tree2f9dfc45191e723da69cf74be7829784e9741b94 /catalog-fe/src
parent9200382f2ce7b4bb729aa287d0878004b2d2b4f9 (diff)
re base code
Change-Id: I12a5ca14a6d8a87e9316b9ff362eb131105f98a5 Issue-ID: SDC-1566 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/GzipFilter.java10
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/Audit.java7
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/HttpRequestInfo.java3
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/MdcData.java38
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/PluginStatusBL.java11
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/listen/FEAppContextListener.java11
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/listen/MyObjectMapperProvider.java6
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/ConfigMgrServlet.java16
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/FeProxyServlet.java129
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/KibanaServlet.java9
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/LoggingServlet.java3
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/PortalServlet.java27
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/SSLProxyServlet.java9
-rw-r--r--catalog-fe/src/main/resources/application-context.xml11
-rw-r--r--catalog-fe/src/main/resources/config/configuration.yaml17
-rw-r--r--catalog-fe/src/test/java/org/openecomp/sdc/fe/GzipFilterTest.java36
-rw-r--r--catalog-fe/src/test/java/org/openecomp/sdc/fe/impl/HttpRequestInfoTest.java32
-rw-r--r--catalog-fe/src/test/java/org/openecomp/sdc/fe/listen/MyObjectMapperProviderTest.java28
-rw-r--r--catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/PluginStatusBLTest.java17
-rw-r--r--catalog-fe/src/test/java/org/openecomp/sdc/servlets/FeProxyServletTest.java23
-rw-r--r--catalog-fe/src/test/java/org/openecomp/sdc/servlets/PortalServletTest.java64
21 files changed, 230 insertions, 277 deletions
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/GzipFilter.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/GzipFilter.java
index 884e688503..99caad2de3 100644
--- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/GzipFilter.java
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/GzipFilter.java
@@ -1,14 +1,8 @@
package org.openecomp.sdc.fe;
-import java.io.IOException;
-
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
+import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
public class GzipFilter implements Filter {
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/Audit.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/Audit.java
index 449d8a932d..6eef071eb4 100644
--- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/Audit.java
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/Audit.java
@@ -20,13 +20,12 @@
package org.openecomp.sdc.fe.impl;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-
import org.openecomp.sdc.common.api.Constants;
import org.slf4j.Logger;
+import javax.servlet.http.HttpServletRequest;
+import java.util.Map;
+
public class Audit {
private Audit() {
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/HttpRequestInfo.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/HttpRequestInfo.java
index bf39a982c4..bf5165fe58 100644
--- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/HttpRequestInfo.java
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/HttpRequestInfo.java
@@ -20,12 +20,11 @@
package org.openecomp.sdc.fe.impl;
+import javax.servlet.http.HttpServletRequest;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Map;
-import javax.servlet.http.HttpServletRequest;
-
public class HttpRequestInfo {
public HttpRequestInfo(HttpServletRequest request, Map<String, String> headersMap, String data) {
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/MdcData.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/MdcData.java
new file mode 100644
index 0000000000..816975fa04
--- /dev/null
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/MdcData.java
@@ -0,0 +1,38 @@
+package org.openecomp.sdc.fe.impl;
+
+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;
+ }
+ } \ No newline at end of file
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/PluginStatusBL.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/PluginStatusBL.java
index df68e1927d..4d466b1e2d 100644
--- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/PluginStatusBL.java
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/PluginStatusBL.java
@@ -1,9 +1,7 @@
package org.openecomp.sdc.fe.impl;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpHead;
@@ -15,8 +13,9 @@ import org.openecomp.sdc.fe.config.PluginsConfiguration.Plugin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
public class PluginStatusBL {
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/listen/FEAppContextListener.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/listen/FEAppContextListener.java
index 76190bc790..987b1fe82e 100644
--- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/listen/FEAppContextListener.java
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/listen/FEAppContextListener.java
@@ -20,12 +20,6 @@
package org.openecomp.sdc.fe.listen;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-
import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.impl.ExternalConfiguration;
import org.openecomp.sdc.common.listener.AppContextListener;
@@ -36,6 +30,11 @@ import org.openecomp.sdc.fe.servlets.HealthCheckService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
public class FEAppContextListener extends AppContextListener implements ServletContextListener {
private static Logger log = LoggerFactory.getLogger(FEAppContextListener.class.getName());
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/listen/MyObjectMapperProvider.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/listen/MyObjectMapperProvider.java
index f891ba4e3f..74f60146da 100644
--- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/listen/MyObjectMapperProvider.java
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/listen/MyObjectMapperProvider.java
@@ -20,12 +20,12 @@
package org.openecomp.sdc.fe.listen;
-import javax.ws.rs.ext.ContextResolver;
-import javax.ws.rs.ext.Provider;
-
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
+import javax.ws.rs.ext.ContextResolver;
+import javax.ws.rs.ext.Provider;
+
@Provider
public class MyObjectMapperProvider implements ContextResolver<ObjectMapper> {
final ObjectMapper defaultObjectMapper;
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/ConfigMgrServlet.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/ConfigMgrServlet.java
index 356f9261c6..547f8ac367 100644
--- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/ConfigMgrServlet.java
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/ConfigMgrServlet.java
@@ -20,6 +20,14 @@
package org.openecomp.sdc.fe.servlets;
+import org.openecomp.sdc.common.api.Constants;
+import org.openecomp.sdc.common.rest.api.RestConfigurationInfo;
+import org.openecomp.sdc.common.servlets.BasicServlet;
+import org.openecomp.sdc.fe.config.Configuration;
+import org.openecomp.sdc.fe.config.ConfigurationManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.GET;
@@ -29,14 +37,6 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
-import org.openecomp.sdc.common.api.Constants;
-import org.openecomp.sdc.common.rest.api.RestConfigurationInfo;
-import org.openecomp.sdc.common.servlets.BasicServlet;
-import org.openecomp.sdc.fe.config.Configuration;
-import org.openecomp.sdc.fe.config.ConfigurationManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* Root resource (exposed at "/" path)
*/
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 a8aa2069e1..b726998555 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,30 +20,28 @@
package org.openecomp.sdc.fe.servlets;
-import java.util.concurrent.TimeUnit;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
import org.eclipse.jetty.client.api.Response;
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.FeEcompErrorManager;
-import org.openecomp.sdc.fe.mdc.MdcData;
+import org.openecomp.sdc.fe.impl.MdcData;
import org.openecomp.sdc.fe.utils.BeProtocol;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
-import com.google.common.cache.Cache;
-import com.google.common.cache.CacheBuilder;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.concurrent.TimeUnit;
public class FeProxyServlet extends SSLProxyServlet {
private static final long serialVersionUID = 1L;
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 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();
@@ -108,7 +106,7 @@ public class FeProxyServlet extends SSLProxyServlet {
if (mdcData != null) {
Long transactionStartTime = mdcData.getTransactionStartTime();
if (transactionStartTime != null) {// should'n ever be null, but
- // just to be defensive
+ // just to be defensive
transactionRoundTime = Long.toString(System.currentTimeMillis() - transactionStartTime);
}
updateMdc(uuid, mdcData.getServiceInstanceID(), mdcData.getUserId(), mdcData.getRemoteAddr(), mdcData.getLocalAddr(), transactionRoundTime);
@@ -138,79 +136,78 @@ public class FeProxyServlet extends SSLProxyServlet {
MDC.put("timer", transactionStartTime);
}
- private String getModifiedUrl(HttpServletRequest request) {
+
+
+ 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");
}
String uri = request.getRequestURI();
- String protocol;
- String host;
- String port;
+ 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();
- }
- 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();
- }
+ uri = uri.replace("/sdc1/feProxy"+ONBOARDING_CONTEXT,ONBOARDING_CONTEXT);
+ protocol = config.getOnboarding().getProtocolBe();
+ host = config.getOnboarding().getHostBe();
+ port = config.getOnboarding().getPortBe().toString();
+ }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();
- }
-
- }
+ 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();
+ }
+ }
- String authority = getAuthority(host, port);
- String queryString = getQueryString(request);
- return String.format(URL,protocol,authority,uri,queryString);
+ String authority = getAuthority(host, port);
+ String queryString = getQueryString(request);
+ return String.format(URL,protocol,authority,uri,queryString);
+ }
- }
-
- private Configuration getConfiguration(HttpServletRequest request) {
+ private Configuration getConfiguration(HttpServletRequest request) {
return ((ConfigurationManager) request.getSession().getServletContext().getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).getConfiguration();
}
- 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;
- }
+ 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/KibanaServlet.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/KibanaServlet.java
index 64784b3265..fb75a06c1d 100644
--- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/KibanaServlet.java
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/KibanaServlet.java
@@ -20,11 +20,6 @@
package org.openecomp.sdc.fe.servlets;
-import java.net.URI;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.client.api.Response;
import org.eclipse.jetty.proxy.ProxyServlet;
@@ -34,6 +29,10 @@ import org.openecomp.sdc.fe.config.ConfigurationManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.net.URI;
+
public class KibanaServlet extends ProxyServlet {
private static final long serialVersionUID = 1L;
private static Logger log = LoggerFactory.getLogger(KibanaServlet.class.getName());
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/LoggingServlet.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/LoggingServlet.java
index af07810f87..2a75e561e9 100644
--- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/LoggingServlet.java
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/LoggingServlet.java
@@ -4,12 +4,11 @@ import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.servlets.BasicServlet;
-import org.openecomp.sdc.fe.mdc.MdcData;
+import org.openecomp.sdc.fe.impl.MdcData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
-
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Response;
import java.util.concurrent.TimeUnit;
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/PortalServlet.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/PortalServlet.java
index 140b293b46..408529f710 100644
--- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/PortalServlet.java
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/PortalServlet.java
@@ -20,20 +20,6 @@
package org.openecomp.sdc.fe.servlets;
-import java.io.IOException;
-import java.util.Enumeration;
-import java.util.List;
-
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletException;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.core.Context;
-
import org.openecomp.portalsdk.core.onboarding.util.CipherUtil;
import org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants;
import org.openecomp.portalsdk.core.onboarding.util.PortalApiProperties;
@@ -45,6 +31,19 @@ import org.openecomp.sdc.fe.config.FeEcompErrorManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Context;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.List;
+
/**
* Root resource (exposed at "/" path)
*/
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 4edcfe1286..ffed2dde8c 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
@@ -20,11 +20,6 @@
package org.openecomp.sdc.fe.servlets;
-import java.util.Enumeration;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.http.HttpHeader;
@@ -37,6 +32,10 @@ import org.openecomp.sdc.fe.utils.BeProtocol;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import java.util.Enumeration;
+
public abstract class SSLProxyServlet extends ProxyServlet {
private static final long serialVersionUID = 1L;
diff --git a/catalog-fe/src/main/resources/application-context.xml b/catalog-fe/src/main/resources/application-context.xml
index a5ec92697a..43f7ca354d 100644
--- a/catalog-fe/src/main/resources/application-context.xml
+++ b/catalog-fe/src/main/resources/application-context.xml
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
- xmlns:aop="http://www.springframework.org/schema/aop" xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:aop="http://www.springframework.org/schema/aop"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
- http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
+ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<context:annotation-config />
<aop:aspectj-autoproxy proxy-target-class="true" />
diff --git a/catalog-fe/src/main/resources/config/configuration.yaml b/catalog-fe/src/main/resources/config/configuration.yaml
index b2dc6da63d..d1156da771 100644
--- a/catalog-fe/src/main/resources/config/configuration.yaml
+++ b/catalog-fe/src/main/resources/config/configuration.yaml
@@ -27,10 +27,15 @@ healthCheckSocketTimeoutInMs: 5000
healthCheckIntervalInSeconds: 5
onboarding:
- protocol: http
- host: localhost
- port: 8181
- healthCheckUri: "/onboarding/v1.0/healthcheck"
+ hostFe: localhost
+ protocolFe: http
+ portFe: 8181
+
+ hostBe: localhost
+ protocolBe: http
+ portBe: 8080
+
+ healthCheckUriFe: "/onboarding/v1.0/healthcheck"
dcae:
protocol: http
@@ -92,6 +97,4 @@ kibanaProtocol: http
healthStatusExclude:
- DE
- ES
- - DMAPP
-
- \ No newline at end of file
+ - DMAAP
diff --git a/catalog-fe/src/test/java/org/openecomp/sdc/fe/GzipFilterTest.java b/catalog-fe/src/test/java/org/openecomp/sdc/fe/GzipFilterTest.java
deleted file mode 100644
index 685d6b3d8f..0000000000
--- a/catalog-fe/src/test/java/org/openecomp/sdc/fe/GzipFilterTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.openecomp.sdc.fe;
-
-import javax.servlet.FilterConfig;
-
-import org.junit.Test;
-
-
-public class GzipFilterTest {
-
- private GzipFilter createTestSubject() {
- return new GzipFilter();
- }
-
-
-
-
- @Test
- public void testInit() throws Exception {
- GzipFilter testSubject;
- FilterConfig filterConfig = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.init(filterConfig);
- }
-
-
- @Test
- public void testDestroy() throws Exception {
- GzipFilter testSubject;
-
- // default test
- testSubject = createTestSubject();
- testSubject.destroy();
- }
-} \ No newline at end of file
diff --git a/catalog-fe/src/test/java/org/openecomp/sdc/fe/impl/HttpRequestInfoTest.java b/catalog-fe/src/test/java/org/openecomp/sdc/fe/impl/HttpRequestInfoTest.java
index c7a44c564e..3bb0006a26 100644
--- a/catalog-fe/src/test/java/org/openecomp/sdc/fe/impl/HttpRequestInfoTest.java
+++ b/catalog-fe/src/test/java/org/openecomp/sdc/fe/impl/HttpRequestInfoTest.java
@@ -1,5 +1,9 @@
package org.openecomp.sdc.fe.impl;
+import org.junit.Test;
+
+import javax.servlet.*;
+import javax.servlet.http.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -9,19 +13,6 @@ import java.util.Collection;
import java.util.Enumeration;
import java.util.Locale;
import java.util.Map;
-import javax.servlet.AsyncContext;
-import javax.servlet.DispatcherType;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletInputStream;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-import javax.servlet.http.Part;
-import org.junit.Test;
public class HttpRequestInfoTest {
@@ -147,6 +138,11 @@ public class HttpRequestInfoTest {
}
@Override
+ public long getContentLengthLong() {
+ return 0;
+ }
+
+ @Override
public String getContentType() {
// TODO Auto-generated method stub
return null;
@@ -459,6 +455,11 @@ public class HttpRequestInfoTest {
}
@Override
+ public String changeSessionId() {
+ return null;
+ }
+
+ @Override
public boolean isRequestedSessionIdValid() {
// TODO Auto-generated method stub
return false;
@@ -510,5 +511,10 @@ public class HttpRequestInfoTest {
return null;
}
+ @Override
+ public <T extends HttpUpgradeHandler> T upgrade(Class<T> aClass) throws IOException, ServletException {
+ return null;
+ }
+
}
} \ No newline at end of file
diff --git a/catalog-fe/src/test/java/org/openecomp/sdc/fe/listen/MyObjectMapperProviderTest.java b/catalog-fe/src/test/java/org/openecomp/sdc/fe/listen/MyObjectMapperProviderTest.java
deleted file mode 100644
index c77206fb03..0000000000
--- a/catalog-fe/src/test/java/org/openecomp/sdc/fe/listen/MyObjectMapperProviderTest.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.openecomp.sdc.fe.listen;
-
-import org.junit.Test;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-
-public class MyObjectMapperProviderTest {
-
- private MyObjectMapperProvider createTestSubject() {
- return new MyObjectMapperProvider();
- }
-
-
- @Test
- public void testGetContext() throws Exception {
- MyObjectMapperProvider testSubject;
- Class<?> type = null;
- ObjectMapper result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getContext(type);
- }
-
-
-
-} \ No newline at end of file
diff --git a/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/PluginStatusBLTest.java b/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/PluginStatusBLTest.java
index 25fef8968b..e1d93b702d 100644
--- a/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/PluginStatusBLTest.java
+++ b/catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/PluginStatusBLTest.java
@@ -1,12 +1,7 @@
package org.openecomp.sdc.fe.servlets;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.when;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
@@ -21,8 +16,12 @@ import org.openecomp.sdc.fe.config.PluginsConfiguration;
import org.openecomp.sdc.fe.config.PluginsConfiguration.Plugin;
import org.openecomp.sdc.fe.impl.PluginStatusBL;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
public class PluginStatusBLTest {
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 7143e8776b..1e42fec42f 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
@@ -20,19 +20,6 @@
package org.openecomp.sdc.servlets;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.http.HttpFields;
import org.junit.BeforeClass;
@@ -43,6 +30,16 @@ import org.openecomp.sdc.fe.config.Configuration;
import org.openecomp.sdc.fe.config.ConfigurationManager;
import org.openecomp.sdc.fe.servlets.FeProxyServlet;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.*;
+
public class FeProxyServletTest {
/*
* Example Url Mappings:
diff --git a/catalog-fe/src/test/java/org/openecomp/sdc/servlets/PortalServletTest.java b/catalog-fe/src/test/java/org/openecomp/sdc/servlets/PortalServletTest.java
index 02f685302e..72d279d3e5 100644
--- a/catalog-fe/src/test/java/org/openecomp/sdc/servlets/PortalServletTest.java
+++ b/catalog-fe/src/test/java/org/openecomp/sdc/servlets/PortalServletTest.java
@@ -20,46 +20,39 @@
package org.openecomp.sdc.servlets;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-import javax.ws.rs.core.Application;
-
import org.glassfish.jersey.internal.inject.AbstractBinder;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
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.servlets.PortalServlet;
+import javax.servlet.*;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import javax.ws.rs.core.Application;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.glassfish.jersey.test.TestProperties.CONTAINER_PORT;
+import static org.mockito.Mockito.*;
+
public class PortalServletTest extends JerseyTest {
- final static HttpServletRequest request = 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 HttpServletResponse response = Mockito.spy(HttpServletResponse.class);
- final static RequestDispatcher rd = Mockito.spy(RequestDispatcher.class);
+ private final static HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
+ private final static HttpSession httpSession = Mockito.mock(HttpSession.class);
+ private final static ServletContext servletContext = Mockito.mock(ServletContext.class);
+ private final static ConfigurationManager configurationManager = Mockito.mock(ConfigurationManager.class);
+ private final static Configuration configuration = Mockito.mock(Configuration.class);
+ private final static HttpServletResponse response = Mockito.spy(HttpServletResponse.class);
+ private final static RequestDispatcher rd = Mockito.spy(RequestDispatcher.class);
@SuppressWarnings("serial")
@BeforeClass
@@ -69,7 +62,7 @@ public class PortalServletTest extends JerseyTest {
when(httpSession.getServletContext()).thenReturn(servletContext);
when(servletContext.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).thenReturn(configurationManager);
when(configurationManager.getConfiguration()).thenReturn(configuration);
- List<List<String>> mandatoryHeaders = new ArrayList<List<String>>();
+ List<List<String>> mandatoryHeaders = new ArrayList<>();
mandatoryHeaders.add(new ArrayList<String>() {
{
add("HTTP_IV_USER");
@@ -95,7 +88,7 @@ public class PortalServletTest extends JerseyTest {
}
});
- List<List<String>> optionalHeaders = new ArrayList<List<String>>();
+ List<List<String>> optionalHeaders = new ArrayList<>();
optionalHeaders.add(new ArrayList<String>() {
{
add("HTTP_CSP_FIRSTNAME");
@@ -129,14 +122,11 @@ public class PortalServletTest extends JerseyTest {
}
@Test
- public void testSuccesfulRequest() throws IOException, ServletException {
- Mockito.doAnswer(new Answer<Object>() {
- public Object answer(InvocationOnMock invocation) {
- Object[] args = invocation.getArguments();
- String headerName = (String) args[0];
- return headerName;
- }
- }).when(request).getHeader(Mockito.anyString());
+ public void testSuccessfulRequest() throws IOException, ServletException {
+ Mockito.doAnswer((Answer<Object>) invocation -> {
+ Object[] args = invocation.getArguments();
+ return (String) args[0];
+ }).when(request).getHeader(Mockito.anyString());
target().path("/portal").request().get();
verify(rd).forward(Mockito.any(ServletRequest.class), Mockito.any(ServletResponse.class));
Mockito.reset(response, rd);
@@ -144,6 +134,8 @@ public class PortalServletTest extends JerseyTest {
@Override
protected Application configure() {
+ // Use any available port - this allows us to run the BE tests in parallel with this one.
+ forceSet(CONTAINER_PORT, "0");
ResourceConfig resourceConfig = new ResourceConfig(PortalServlet.class);
resourceConfig.register(new AbstractBinder() {