aboutsummaryrefslogtreecommitdiffstats
path: root/datarouter-prov/src
diff options
context:
space:
mode:
Diffstat (limited to 'datarouter-prov/src')
-rwxr-xr-x[-rw-r--r--]datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java10
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Main.java2
-rwxr-xr-x[-rw-r--r--]datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/ProxyServlet.java141
-rwxr-xr-x[-rw-r--r--]datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NodeClass.java36
-rwxr-xr-x[-rw-r--r--]datarouter-prov/src/main/resources/misc/sql_init_01.sql12
-rwxr-xr-x[-rw-r--r--]datarouter-prov/src/main/resources/provserver.properties10
-rwxr-xr-x[-rw-r--r--]datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestBase.java4
-rwxr-xr-xdatarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/BaseServletTest.java3
-rwxr-xr-x[-rw-r--r--]datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/DRFeedsServletTest.java80
-rwxr-xr-xdatarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/FeedServletTest.java3
-rwxr-xr-x[-rw-r--r--]datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/GroupServletTest.java3
-rwxr-xr-xdatarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/InternalServletTest.java5
-rwxr-xr-xdatarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/RouteServletTest.java3
-rwxr-xr-xdatarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscribeServletTest.java2
-rwxr-xr-x[-rw-r--r--]datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServletTest.java4
-rw-r--r--datarouter-prov/src/test/resources/integration_test.properties10
16 files changed, 195 insertions, 133 deletions
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java
index 412e1322..047043b1 100644..100755
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java
@@ -319,7 +319,7 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
* @return an error string, or null if all is OK
*/
String isAuthorizedForProvisioning(HttpServletRequest request) {
- if (Boolean.parseBoolean(isAddressAuthEnabled)) {
+ if (!Boolean.parseBoolean(isAddressAuthEnabled)) {
return null;
}
// Is the request https?
@@ -369,7 +369,7 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
boolean isAuthorizedForInternal(HttpServletRequest request) {
try {
- if (Boolean.parseBoolean(isAddressAuthEnabled)) {
+ if (!Boolean.parseBoolean(isAddressAuthEnabled)) {
return true;
}
InetAddress ip = InetAddress.getByName(request.getRemoteAddr());
@@ -492,9 +492,6 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
// Normalize the nodes, and fill in nodeAddresses
InetAddress[] na = new InetAddress[nodes.length];
for (int i = 0; i < nodes.length; i++) {
- if (nodes[i].indexOf('.') < 0) {
- nodes[i] += "." + provDomain;
- }
try {
na[i] = InetAddress.getByName(nodes[i]);
intlogger.debug("PROV0003 DNS lookup: " + nodes[i] + " => " + na[i].toString());
@@ -520,9 +517,6 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
String[] pods = getPods();
na = new InetAddress[pods.length];
for (int i = 0; i < pods.length; i++) {
- if (pods[i].indexOf('.') < 0) {
- pods[i] += "." + provDomain;
- }
try {
na[i] = InetAddress.getByName(pods[i]);
intlogger.debug("PROV0003 DNS lookup: " + pods[i] + " => " + na[i].toString());
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Main.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Main.java
index 87979be6..800bd9af 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Main.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Main.java
@@ -185,8 +185,6 @@ public class Main {
sslContextFactory.setTrustStorePath(DEFAULT_TRUSTSTORE);
sslContextFactory.setTrustStorePassword("changeit");
}
- sslContextFactory.setTrustStorePath("/opt/app/datartr/self_signed/cacerts.jks");
- sslContextFactory.setTrustStorePassword("changeit");
sslContextFactory.setWantClientAuth(true);
// Servlet and Filter configuration
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/ProxyServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/ProxyServlet.java
index c560299a..8d6bfcf0 100644..100755
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/ProxyServlet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/ProxyServlet.java
@@ -35,12 +35,10 @@ import java.security.KeyStoreException;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
-
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
import org.apache.commons.io.IOUtils;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
@@ -57,16 +55,16 @@ import org.onap.dmaap.datarouter.provisioning.utils.DB;
import org.onap.dmaap.datarouter.provisioning.utils.URLUtilities;
/**
- * This class is the base class for those servlets that need to proxy their requests from the
- * standby to active server. Its methods perform the proxy function to the active server. If the
- * active server is not reachable, a 503 (SC_SERVICE_UNAVAILABLE) is returned. Only
- * DELETE/GET/PUT/POST are supported.
+ * This class is the base class for those servlets that need to proxy their requests from the standby to active server.
+ * Its methods perform the proxy function to the active server. If the active server is not reachable, a 503
+ * (SC_SERVICE_UNAVAILABLE) is returned. Only DELETE/GET/PUT/POST are supported.
*
* @author Robert Eby
* @version $Id: ProxyServlet.java,v 1.3 2014/03/24 18:47:10 eby Exp $
*/
@SuppressWarnings("serial")
public class ProxyServlet extends BaseServlet {
+
private boolean inited = false;
private Scheme sch;
@@ -80,13 +78,13 @@ public class ProxyServlet extends BaseServlet {
try {
// Set up keystore
Properties props = (new DB()).getProperties();
- String type = props.getProperty(Main.KEYSTORE_TYPE_PROPERTY, "jks");
+ String type = props.getProperty(Main.KEYSTORE_TYPE_PROPERTY, "jks");
String store = props.getProperty(Main.KEYSTORE_PATH_PROPERTY);
- String pass = props.getProperty(Main.KEYSTORE_PASSWORD_PROPERTY);
+ String pass = props.getProperty(Main.KEYSTORE_PASSWORD_PROPERTY);
KeyStore keyStore = readStore(store, pass, type);
store = props.getProperty(Main.TRUSTSTORE_PATH_PROPERTY);
- pass = props.getProperty(Main.TRUSTSTORE_PASSWORD_PROPERTY);
+ pass = props.getProperty(Main.TRUSTSTORE_PASSWORD_PROPERTY);
if (store == null || store.length() == 0) {
store = Main.DEFAULT_TRUSTSTORE;
pass = "changeit";
@@ -95,30 +93,34 @@ public class ProxyServlet extends BaseServlet {
// We are connecting with the node name, but the certificate will have the CNAME
// So we need to accept a non-matching certificate name
- SSLSocketFactory socketFactory = new SSLSocketFactory(keyStore, "changeit", trustStore);
+ SSLSocketFactory socketFactory = new SSLSocketFactory(keyStore,
+ props.getProperty(Main.KEYSTORE_PASSWORD_PROPERTY), trustStore);
socketFactory.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
sch = new Scheme("https", 443, socketFactory);
inited = true;
} catch (Exception e) {
e.printStackTrace();
}
- intlogger.info("ProxyServlet: inited = "+inited);
+ intlogger.info("ProxyServlet: inited = " + inited);
}
- private KeyStore readStore(String store, String pass, String type) throws KeyStoreException, FileNotFoundException {
+
+ private KeyStore readStore(String store, String pass, String type) throws KeyStoreException {
KeyStore ks = KeyStore.getInstance(type);
- FileInputStream instream = new FileInputStream(new File(store));
- try {
+ try (FileInputStream instream = new FileInputStream(new File(store))) {
ks.load(instream, pass.toCharArray());
+ } catch (FileNotFoundException fileNotFoundException) {
+ System.err.println("ProxyServlet: " + fileNotFoundException);
+ fileNotFoundException.printStackTrace();
} catch (Exception x) {
- System.err.println("READING TRUSTSTORE: "+x);
- } finally {
- try { instream.close(); } catch (Exception ignore) {}
+ System.err.println("READING TRUSTSTORE: " + x);
}
return ks;
}
+
/**
- * Return <i>true</i> if the requester has NOT set the <i>noproxy</i> CGI variable.
- * If they have, this indicates they want to forcibly turn the proxy off.
+ * Return <i>true</i> if the requester has NOT set the <i>noproxy</i> CGI variable. If they have, this indicates
+ * they want to forcibly turn the proxy off.
+ *
* @param req the HTTP request
* @return true or false
*/
@@ -127,22 +129,25 @@ public class ProxyServlet extends BaseServlet {
if (t != null) {
t = t.replaceAll("&amp;", "&");
for (String s : t.split("&")) {
- if (s.equals("noproxy") || s.startsWith("noproxy="))
+ if (s.equals("noproxy") || s.startsWith("noproxy=")) {
return false;
+ }
}
}
return true;
}
+
/**
- * Is this the standby server? If it is, the proxy functions can be used.
- * If not, the proxy functions should not be called, and will send a response of 500
- * (Internal Server Error).
+ * Is this the standby server? If it is, the proxy functions can be used. If not, the proxy functions should not be
+ * called, and will send a response of 500 (Internal Server Error).
+ *
* @return true if this server is the standby (and hence a proxy server).
*/
public boolean isProxyServer() {
SynchronizerTask st = SynchronizerTask.getSynchronizer();
return st.getState() == SynchronizerTask.STANDBY;
}
+
/**
* Issue a proxy DELETE to the active provisioning server.
*/
@@ -150,6 +155,7 @@ public class ProxyServlet extends BaseServlet {
public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws IOException {
doProxy(req, resp, "DELETE");
}
+
/**
* Issue a proxy GET to the active provisioning server.
*/
@@ -157,6 +163,7 @@ public class ProxyServlet extends BaseServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
doProxy(req, resp, "GET");
}
+
/**
* Issue a proxy PUT to the active provisioning server.
*/
@@ -164,6 +171,7 @@ public class ProxyServlet extends BaseServlet {
public void doPut(HttpServletRequest req, HttpServletResponse resp) throws IOException {
doProxy(req, resp, "PUT");
}
+
/**
* Issue a proxy POST to the active provisioning server.
*/
@@ -171,58 +179,61 @@ public class ProxyServlet extends BaseServlet {
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
doProxy(req, resp, "POST");
}
+
/**
- * Issue a proxy GET to the active provisioning server. Unlike doGet() above,
- * this method will allow the caller to fall back to other code if the remote server is unreachable.
+ * Issue a proxy GET to the active provisioning server. Unlike doGet() above, this method will allow the caller to
+ * fall back to other code if the remote server is unreachable.
+ *
* @return true if the proxy succeeded
*/
public boolean doGetWithFallback(HttpServletRequest req, HttpServletResponse resp) throws IOException {
boolean rv = false;
if (inited) {
String url = buildUrl(req);
- intlogger.info("ProxyServlet: proxying with fallback GET "+url);
- try(AbstractHttpClient httpclient = new DefaultHttpClient()){
- HttpRequestBase proxy = new HttpGet(url);
- try {
- httpclient.getConnectionManager().getSchemeRegistry().register(sch);
-
- // Copy request headers and request body
- copyRequestHeaders(req, proxy);
-
- // Execute the request
- HttpResponse pxy_response = httpclient.execute(proxy);
-
- // Get response headers and body
- int code = pxy_response.getStatusLine().getStatusCode();
- resp.setStatus(code);
- copyResponseHeaders(pxy_response, resp);
-
- HttpEntity entity = pxy_response.getEntity();
- if (entity != null) {
- InputStream in = entity.getContent();
- IOUtils.copy(in, resp.getOutputStream());
- in.close();
+ intlogger.info("ProxyServlet: proxying with fallback GET " + url);
+ try (AbstractHttpClient httpclient = new DefaultHttpClient()) {
+ HttpRequestBase proxy = new HttpGet(url);
+ try {
+ httpclient.getConnectionManager().getSchemeRegistry().register(sch);
+
+ // Copy request headers and request body
+ copyRequestHeaders(req, proxy);
+
+ // Execute the request
+ HttpResponse pxy_response = httpclient.execute(proxy);
+
+ // Get response headers and body
+ int code = pxy_response.getStatusLine().getStatusCode();
+ resp.setStatus(code);
+ copyResponseHeaders(pxy_response, resp);
+
+ HttpEntity entity = pxy_response.getEntity();
+ if (entity != null) {
+ InputStream in = entity.getContent();
+ IOUtils.copy(in, resp.getOutputStream());
+ in.close();
+ }
+ rv = true;
+
+ } catch (IOException e) {
+ System.err.println("ProxyServlet: " + e);
+ e.printStackTrace();
+ } finally {
+ proxy.releaseConnection();
+ httpclient.getConnectionManager().shutdown();
}
- rv = true;
-
- } catch (IOException e) {
- System.err.println("ProxyServlet: "+e);
- e.printStackTrace();
- } finally {
- proxy.releaseConnection();
- httpclient.getConnectionManager().shutdown();
- }
}
} else {
intlogger.warn("ProxyServlet: proxy disabled");
}
return rv;
}
+
private void doProxy(HttpServletRequest req, HttpServletResponse resp, final String method) throws IOException {
if (inited && isProxyServer()) {
String url = buildUrl(req);
- intlogger.info("ProxyServlet: proxying "+method + " "+url);
- try(AbstractHttpClient httpclient = new DefaultHttpClient()) {
+ intlogger.info("ProxyServlet: proxying " + method + " " + url);
+ try (AbstractHttpClient httpclient = new DefaultHttpClient()) {
ProxyHttpRequest proxy = new ProxyHttpRequest(method, url);
try {
httpclient.getConnectionManager().getSchemeRegistry().register(sch);
@@ -264,33 +275,40 @@ public class ProxyServlet extends BaseServlet {
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
}
+
private String buildUrl(HttpServletRequest req) {
StringBuilder sb = new StringBuilder("https://");
sb.append(URLUtilities.getPeerPodName());
sb.append(req.getRequestURI());
String q = req.getQueryString();
- if (q != null)
+ if (q != null) {
sb.append("?").append(q);
+ }
return sb.toString();
}
+
private void copyRequestHeaders(HttpServletRequest from, HttpRequestBase to) {
@SuppressWarnings("unchecked")
List<String> list = Collections.list(from.getHeaderNames());
for (String name : list) {
// Proxy code will add this one
- if (!name.equalsIgnoreCase("Content-Length"))
+ if (!name.equalsIgnoreCase("Content-Length")) {
to.addHeader(name, from.getHeader(name));
+ }
}
}
+
private void copyResponseHeaders(HttpResponse from, HttpServletResponse to) {
for (Header hdr : from.getAllHeaders()) {
// Don't copy Date: our Jetty will add another Date header
- if (!hdr.getName().equals("Date"))
+ if (!hdr.getName().equals("Date")) {
to.addHeader(hdr.getName(), hdr.getValue());
+ }
}
}
public class ProxyHttpRequest extends HttpEntityEnclosingRequestBase {
+
private final String method;
public ProxyHttpRequest(final String method, final String uri) {
@@ -298,6 +316,7 @@ public class ProxyServlet extends BaseServlet {
this.method = method;
setURI(URI.create(uri));
}
+
@Override
public String getMethod() {
return method;
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NodeClass.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NodeClass.java
index 4c140490..f3eb1eb6 100644..100755
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NodeClass.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NodeClass.java
@@ -32,7 +32,6 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
-
import org.apache.log4j.Logger;
import org.onap.dmaap.datarouter.provisioning.utils.DB;
@@ -43,6 +42,7 @@ import org.onap.dmaap.datarouter.provisioning.utils.DB;
* @version $Id: NodeClass.java,v 1.2 2014/01/15 16:08:43 eby Exp $
*/
public abstract class NodeClass extends Syncable {
+
private static Map<String, Integer> map;
private static Logger intLogger = Logger.getLogger("org.onap.dmaap.datarouter.provisioning.internal");
public NodeClass() {
@@ -53,19 +53,20 @@ public abstract class NodeClass extends Syncable {
}
/**
- * Add nodes to the NODES table, when the NODES parameter value is changed.
- * Nodes are only added to the table, they are never deleted. The node name is normalized
- * to contain the domain (if missing).
+ * Add nodes to the NODES table, when the NODES parameter value is changed. Nodes are only added to the table, they
+ * are never deleted. The node name is normalized to contain the domain (if missing).
*
* @param nodes a pipe separated list of the current nodes
*/
public static void setNodes(String[] nodes) {
- if (map == null)
+ if (map == null) {
reload();
+ }
int nextid = 0;
for (Integer n : map.values()) {
- if (n >= nextid)
+ if (n >= nextid) {
nextid = n + 1;
+ }
}
// take | separated list, add domain if needed.
@@ -136,8 +137,9 @@ public abstract class NodeClass extends Syncable {
public static Integer lookupNodeName(final String name) {
Integer n = map.get(name);
- if (n == null)
+ if (n == null) {
throw new IllegalArgumentException("Invalid node name: " + name);
+ }
return n;
}
@@ -148,8 +150,9 @@ public abstract class NodeClass extends Syncable {
if (s.endsWith("*")) {
s = s.substring(0, s.length() - 1);
for (String s2 : keyset) {
- if (s2.startsWith(s))
+ if (s2.startsWith(s)) {
coll.add(s2);
+ }
}
} else if (keyset.contains(s)) {
coll.add(s);
@@ -162,14 +165,6 @@ public abstract class NodeClass extends Syncable {
return coll;
}
- protected String lookupNodeID(int n) {
- for (String s : map.keySet()) {
- if (map.get(s) == n)
- return s;
- }
- return null;
- }
-
public static String normalizeNodename(String s) {
if (s != null && s.indexOf('.') <= 0) {
Parameters p = Parameters.getParameter(Parameters.PROV_DOMAIN);
@@ -184,4 +179,13 @@ public abstract class NodeClass extends Syncable {
}
}
+
+ protected String lookupNodeID(int n) {
+ for (String s : map.keySet()) {
+ if (map.get(s) == n) {
+ return s;
+ }
+ }
+ return null;
+ }
}
diff --git a/datarouter-prov/src/main/resources/misc/sql_init_01.sql b/datarouter-prov/src/main/resources/misc/sql_init_01.sql
index e01ce3b0..356a67a9 100644..100755
--- a/datarouter-prov/src/main/resources/misc/sql_init_01.sql
+++ b/datarouter-prov/src/main/resources/misc/sql_init_01.sql
@@ -124,18 +124,18 @@ CREATE TABLE GROUPS (
);
INSERT INTO PARAMETERS VALUES
- ('ACTIVE_POD', 'prov.datarouternew.com'),
- ('PROV_ACTIVE_NAME', 'prov.datarouternew.com'),
+ ('ACTIVE_POD', 'dmaap-dr-prov'),
+ ('PROV_ACTIVE_NAME', 'dmaap-dr-prov'),
('STANDBY_POD', ''),
- ('PROV_NAME', 'prov.datarouternew.com'),
- ('NODES', '172.100.0.1|node.datarouternew.com'),
- ('PROV_DOMAIN', 'datarouternew.com'),
+ ('PROV_NAME', 'dmaap-dr-prov'),
+ ('NODES', 'dmaap-dr-node'),
+ ('PROV_DOMAIN', ''),
('DELIVERY_INIT_RETRY_INTERVAL', '10'),
('DELIVERY_MAX_AGE', '86400'),
('DELIVERY_MAX_RETRY_INTERVAL', '3600'),
('DELIVERY_RETRY_RATIO', '2'),
('LOGROLL_INTERVAL', '300'),
- ('PROV_AUTH_ADDRESSES', '172.100.0.1|prov.datarouternew.com|node.datarouternew.com'),
+ ('PROV_AUTH_ADDRESSES', 'dmaap-dr-prov|dmaap-dr-node'),
('PROV_AUTH_SUBJECTS', ''),
('PROV_MAXFEED_COUNT', '10000'),
('PROV_MAXSUB_COUNT', '100000'),
diff --git a/datarouter-prov/src/main/resources/provserver.properties b/datarouter-prov/src/main/resources/provserver.properties
index 7758a64d..744bc9ce 100644..100755
--- a/datarouter-prov/src/main/resources/provserver.properties
+++ b/datarouter-prov/src/main/resources/provserver.properties
@@ -27,11 +27,11 @@ org.onap.dmaap.datarouter.provserver.https.port = 8443
org.onap.dmaap.datarouter.provserver.https.relaxation = true
org.onap.dmaap.datarouter.provserver.keystore.type = jks
-org.onap.dmaap.datarouter.provserver.keymanager.password = changeit
-org.onap.dmaap.datarouter.provserver.keystore.path = /opt/app/datartr/self_signed/keystore.jks
-org.onap.dmaap.datarouter.provserver.keystore.password = changeit
-org.onap.dmaap.datarouter.provserver.truststore.path = /opt/app/datartr/self_signed/cacerts.jks
-org.onap.dmaap.datarouter.provserver.truststore.password = changeit
+org.onap.dmaap.datarouter.provserver.keymanager.password = Qgw77oaQcdP*F8Pwa[&.,.Ab
+org.onap.dmaap.datarouter.provserver.keystore.path = /opt/app/datartr/aaf_certs/org.onap.dmaap-dr.jks
+org.onap.dmaap.datarouter.provserver.keystore.password = Qgw77oaQcdP*F8Pwa[&.,.Ab
+org.onap.dmaap.datarouter.provserver.truststore.path = /opt/app/datartr/aaf_certs/org.onap.dmaap-dr.trust.jks
+org.onap.dmaap.datarouter.provserver.truststore.password = 9M?)?:KAj1z6gpLhNrVUG@0T
org.onap.dmaap.datarouter.provserver.accesslog.dir = /opt/app/datartr/logs
org.onap.dmaap.datarouter.provserver.spooldir = /opt/app/datartr/spool
diff --git a/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestBase.java b/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestBase.java
index 71446219..3e5e1d04 100644..100755
--- a/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestBase.java
+++ b/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestBase.java
@@ -114,7 +114,7 @@ public class IntegrationTestBase {
}
}
- SSLSocketFactory socketFactory = new SSLSocketFactory(keyStore, "changeit", trustStore);
+ SSLSocketFactory socketFactory = new SSLSocketFactory(keyStore, props.getProperty("test.kspassword"), trustStore);
Scheme sch = new Scheme("https", 443, socketFactory);
httpclient.getConnectionManager().getSchemeRegistry().register(sch);
@@ -164,7 +164,7 @@ public class IntegrationTestBase {
// shut down the connection manager to ensure
// immediate deallocation of all system resources
httpclient.getConnectionManager().shutdown();
- FileUtils.deleteDirectory(new File("./unit-test-logs"));
+ FileUtils.deleteDirectory(new File("." + File.pathSeparator+ "unit-test-logs"));
}
protected void ckResponse(HttpResponse response, int expect) {
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/BaseServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/BaseServletTest.java
index 61d030d9..8cc48683 100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/BaseServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/BaseServletTest.java
@@ -40,6 +40,7 @@ import java.util.HashSet;
import java.util.Set;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.mock;
@@ -84,7 +85,7 @@ public class BaseServletTest extends DrServletTestBase {
authAddressesAndNetworks.add(("127.0.0.1"));
FieldUtils.writeDeclaredStaticField(BaseServlet.class, "authorizedAddressesAndNetworks", authAddressesAndNetworks, true);
FieldUtils.writeDeclaredStaticField(BaseServlet.class, "requireCert", true, true);
- assertThat(baseServlet.isAuthorizedForProvisioning(request), is("Client certificate is missing."));
+ assertNull(baseServlet.isAuthorizedForProvisioning(request));
}
@Test
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/DRFeedsServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/DRFeedsServletTest.java
index 35bc85d8..87390bc5 100644..100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/DRFeedsServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/DRFeedsServletTest.java
@@ -22,6 +22,21 @@
******************************************************************************/
package org.onap.dmaap.datarouter.provisioning;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.mockito.Mockito.anyInt;
+import static org.mockito.Mockito.anyString;
+import static org.mockito.Mockito.argThat;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.onap.dmaap.datarouter.provisioning.BaseServlet.BEHALF_HEADER;
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.jetbrains.annotations.NotNull;
import org.json.JSONArray;
@@ -38,20 +53,11 @@ import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.modules.junit4.PowerMockRunner;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.util.HashSet;
-import java.util.Set;
-
-import static org.hamcrest.Matchers.notNullValue;
-import static org.mockito.Mockito.*;
-import static org.onap.dmaap.datarouter.provisioning.BaseServlet.BEHALF_HEADER;
-
@RunWith(PowerMockRunner.class)
@SuppressStaticInitializationFor("org.onap.dmaap.datarouter.provisioning.beans.Feed")
public class DRFeedsServletTest extends DrServletTestBase {
+
private static DRFeedsServlet drfeedsServlet;
@Mock
@@ -77,14 +83,17 @@ public class DRFeedsServletTest extends DrServletTestBase {
}
@Test
- public void Given_Request_Is_HTTP_GET_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated() throws Exception {
+ public void Given_Request_Is_HTTP_GET_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated()
+ throws Exception {
when(request.isSecure()).thenReturn(false);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
drfeedsServlet.doGet(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
@Test
- public void Given_Request_Is_HTTP_GET_And_BEHALF_HEADER_Is_Not_Set_In_Request_Then_Bad_Request_Response_Is_Generated() throws Exception {
+ public void Given_Request_Is_HTTP_GET_And_BEHALF_HEADER_Is_Not_Set_In_Request_Then_Bad_Request_Response_Is_Generated()
+ throws Exception {
setBehalfHeader(null);
drfeedsServlet.doGet(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), argThat(notNullValue(String.class)));
@@ -92,7 +101,8 @@ public class DRFeedsServletTest extends DrServletTestBase {
@Test
- public void Given_Request_Is_HTTP_GET_And_URL_Path_Not_Valid_Then_Bad_Request_Response_Is_Generated() throws Exception {
+ public void Given_Request_Is_HTTP_GET_And_URL_Path_Not_Valid_Then_Bad_Request_Response_Is_Generated()
+ throws Exception {
when(request.getRequestURI()).thenReturn("/123");
drfeedsServlet.doGet(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_NOT_FOUND), argThat(notNullValue(String.class)));
@@ -100,7 +110,8 @@ public class DRFeedsServletTest extends DrServletTestBase {
@Test
- public void Given_Request_Is_HTTP_GET_And_Request_Is_Not_Authorized_Then_Forbidden_Response_Is_Generated() throws Exception {
+ public void Given_Request_Is_HTTP_GET_And_Request_Is_Not_Authorized_Then_Forbidden_Response_Is_Generated()
+ throws Exception {
setAuthoriserToReturnRequestNotAuthorized();
drfeedsServlet.doGet(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
@@ -146,14 +157,17 @@ public class DRFeedsServletTest extends DrServletTestBase {
@Test
- public void Given_Request_Is_HTTP_POST_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated() throws Exception {
+ public void Given_Request_Is_HTTP_POST_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated()
+ throws Exception {
when(request.isSecure()).thenReturn(false);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
drfeedsServlet.doPost(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
@Test
- public void Given_Request_Is_HTTP_POST_And_BEHALF_HEADER_Is_Not_Set_In_Request_Then_Bad_Request_Response_Is_Generated() throws Exception {
+ public void Given_Request_Is_HTTP_POST_And_BEHALF_HEADER_Is_Not_Set_In_Request_Then_Bad_Request_Response_Is_Generated()
+ throws Exception {
setBehalfHeader(null);
drfeedsServlet.doPost(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), argThat(notNullValue(String.class)));
@@ -161,7 +175,8 @@ public class DRFeedsServletTest extends DrServletTestBase {
@Test
- public void Given_Request_Is_HTTP_POST_And_URL_Path_Not_Valid_Then_Bad_Request_Response_Is_Generated() throws Exception {
+ public void Given_Request_Is_HTTP_POST_And_URL_Path_Not_Valid_Then_Bad_Request_Response_Is_Generated()
+ throws Exception {
when(request.getRequestURI()).thenReturn("/123");
drfeedsServlet.doPost(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_NOT_FOUND), argThat(notNullValue(String.class)));
@@ -169,28 +184,33 @@ public class DRFeedsServletTest extends DrServletTestBase {
@Test
- public void Given_Request_Is_HTTP_POST_And_Content_Header_Is_Not_Supported_Type_Then_Unsupported_Media_Type_Response_Is_Generated() throws Exception {
+ public void Given_Request_Is_HTTP_POST_And_Content_Header_Is_Not_Supported_Type_Then_Unsupported_Media_Type_Response_Is_Generated()
+ throws Exception {
when(request.getHeader("Content-Type")).thenReturn("application/vnd.att-dr.feed; version=1.1");
when(request.getContentType()).thenReturn("stub_contentType");
drfeedsServlet.doPost(request, response);
- verify(response).sendError(eq(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE), argThat(notNullValue(String.class)));
+ verify(response)
+ .sendError(eq(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE), argThat(notNullValue(String.class)));
}
@Test
- public void Given_Request_Is_HTTP_POST_And_Request_Is_Not_Authorized_Then_Forbidden_Response_Is_Generated() throws Exception {
+ public void Given_Request_Is_HTTP_POST_And_Request_Is_Not_Authorized_Then_Forbidden_Response_Is_Generated()
+ throws Exception {
setAuthoriserToReturnRequestNotAuthorized();
drfeedsServlet.doPost(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
@Test
- public void Given_Request_Is_HTTP_POST_And_Request_Contains_Badly_Formed_JSON_Then_Bad_Request_Response_Is_Generated() throws Exception {
+ public void Given_Request_Is_HTTP_POST_And_Request_Contains_Badly_Formed_JSON_Then_Bad_Request_Response_Is_Generated()
+ throws Exception {
drfeedsServlet.doPost(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), argThat(notNullValue(String.class)));
}
@Test
- public void Given_Request_Is_HTTP_POST_And_Active_Feeds_Equals_Max_Feeds_Then_Bad_Request_Response_Is_Generated() throws Exception {
+ public void Given_Request_Is_HTTP_POST_And_Active_Feeds_Equals_Max_Feeds_Then_Bad_Request_Response_Is_Generated()
+ throws Exception {
FieldUtils.writeDeclaredStaticField(BaseServlet.class, "maxFeeds", 0, true);
DRFeedsServlet drfeedsServlet = new DRFeedsServlet() {
protected JSONObject getJSONfromInput(HttpServletRequest req) {
@@ -202,7 +222,8 @@ public class DRFeedsServletTest extends DrServletTestBase {
}
@Test
- public void Given_Request_Is_HTTP_POST_And_Feed_Is_Not_Valid_Object_Bad_Request_Response_Is_Generated() throws Exception {
+ public void Given_Request_Is_HTTP_POST_And_Feed_Is_Not_Valid_Object_Bad_Request_Response_Is_Generated()
+ throws Exception {
when(request.getHeader("X-ATT-DR-ON-BEHALF-OF-GROUP")).thenReturn(null);
JSONObject JSObject = buildRequestJsonObject();
@@ -218,7 +239,8 @@ public class DRFeedsServletTest extends DrServletTestBase {
}
@Test
- public void Given_Request_Is_HTTP_POST_And_Feed_Already_Exists_Bad_Request_Response_Is_Generated() throws Exception {
+ public void Given_Request_Is_HTTP_POST_And_Feed_Already_Exists_Bad_Request_Response_Is_Generated()
+ throws Exception {
setFeedToReturnInvalidFeedIdSupplied();
JSONObject JSObject = buildRequestJsonObject();
DRFeedsServlet drfeedsServlet = new DRFeedsServlet() {
@@ -252,12 +274,14 @@ public class DRFeedsServletTest extends DrServletTestBase {
}
};
drfeedsServlet.doPost(request, response);
- verify(response).sendError(eq(HttpServletResponse.SC_INTERNAL_SERVER_ERROR), argThat(notNullValue(String.class)));
+ verify(response)
+ .sendError(eq(HttpServletResponse.SC_INTERNAL_SERVER_ERROR), argThat(notNullValue(String.class)));
}
@Test
- public void Given_Request_Is_HTTP_POST_And_Change_On_Feeds_Succeeds_A_STATUS_OK_Response_Is_Generated() throws Exception {
+ public void Given_Request_Is_HTTP_POST_And_Change_On_Feeds_Succeeds_A_STATUS_OK_Response_Is_Generated()
+ throws Exception {
ServletOutputStream outStream = mock(ServletOutputStream.class);
when(response.getOutputStream()).thenReturn(outStream);
JSONObject JSObject = buildRequestJsonObject();
@@ -301,7 +325,9 @@ public class DRFeedsServletTest extends DrServletTestBase {
when(request.isSecure()).thenReturn(true);
Set<String> authAddressesAndNetworks = new HashSet<String>();
authAddressesAndNetworks.add(("127.0.0.1"));
- FieldUtils.writeDeclaredStaticField(BaseServlet.class, "authorizedAddressesAndNetworks", authAddressesAndNetworks, true);
+ FieldUtils
+ .writeDeclaredStaticField(BaseServlet.class, "authorizedAddressesAndNetworks", authAddressesAndNetworks,
+ true);
FieldUtils.writeDeclaredStaticField(BaseServlet.class, "requireCert", false, true);
FieldUtils.writeDeclaredStaticField(BaseServlet.class, "maxFeeds", 100, true);
}
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/FeedServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/FeedServletTest.java
index f5302cb9..cb8a28da 100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/FeedServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/FeedServletTest.java
@@ -76,6 +76,7 @@ public class FeedServletTest extends DrServletTestBase {
public void Given_Request_Is_HTTP_DELETE_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated()
throws Exception {
when(request.isSecure()).thenReturn(false);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
feedServlet.doDelete(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
@@ -147,6 +148,7 @@ public class FeedServletTest extends DrServletTestBase {
public void Given_Request_Is_HTTP_GET_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated()
throws Exception {
when(request.isSecure()).thenReturn(false);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
feedServlet.doGet(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
@@ -200,6 +202,7 @@ public class FeedServletTest extends DrServletTestBase {
public void Given_Request_Is_HTTP_PUT_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated()
throws Exception {
when(request.isSecure()).thenReturn(false);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
feedServlet.doPut(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/GroupServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/GroupServletTest.java
index a0831b73..fa0caea6 100644..100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/GroupServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/GroupServletTest.java
@@ -76,6 +76,7 @@ public class GroupServletTest extends DrServletTestBase {
@Test
public void Given_Request_Is_HTTP_GET_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated() throws Exception {
when(request.isSecure()).thenReturn(false);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
groupServlet.doGet(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
@@ -105,6 +106,7 @@ public class GroupServletTest extends DrServletTestBase {
@Test
public void Given_Request_Is_HTTP_PUT_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated() throws Exception {
when(request.isSecure()).thenReturn(false);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
groupServlet.doPut(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
@@ -184,6 +186,7 @@ public class GroupServletTest extends DrServletTestBase {
@Test
public void Given_Request_Is_HTTP_POST_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated() throws Exception {
when(request.isSecure()).thenReturn(false);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
groupServlet.doPost(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/InternalServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/InternalServletTest.java
index f8342449..97900d4d 100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/InternalServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/InternalServletTest.java
@@ -89,6 +89,8 @@ public class InternalServletTest extends DrServletTestBase {
public void Given_Request_Is_HTTP_GET_And_Address_Not_Authorized_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated()
throws Exception {
when(request.getRemoteAddr()).thenReturn("127.100.0.3");
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
+
internalServlet.doGet(request, response);
verify(response)
.sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
@@ -188,6 +190,7 @@ public class InternalServletTest extends DrServletTestBase {
public void Given_Request_Is_HTTP_PUT_And_Address_Not_Authorized_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated()
throws Exception {
when(request.getRemoteAddr()).thenReturn("127.100.0.3");
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
internalServlet.doPut(request, response);
verify(response)
.sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
@@ -232,6 +235,7 @@ public class InternalServletTest extends DrServletTestBase {
public void Given_Request_Is_HTTP_DELETE_And_Address_Not_Authorized_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated()
throws Exception {
when(request.getRemoteAddr()).thenReturn("127.100.0.3");
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
internalServlet.doDelete(request, response);
verify(response)
.sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
@@ -278,6 +282,7 @@ public class InternalServletTest extends DrServletTestBase {
throws Exception {
when(request.getRemoteAddr()).thenReturn("127.100.0.3");
internalServlet.doPost(request, response);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
verify(response)
.sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/RouteServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/RouteServletTest.java
index 63715804..34421f52 100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/RouteServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/RouteServletTest.java
@@ -69,6 +69,7 @@ public class RouteServletTest extends DrServletTestBase
@Test
public void Given_Request_Is_HTTP_DELETE_And_Is_Not_Authorized() throws Exception {
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
routeServlet.doDelete(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
@@ -207,6 +208,7 @@ public class RouteServletTest extends DrServletTestBase
@Test
public void Given_Request_Is_HTTP_GET_And_Is_Not_Authorized() throws Exception {
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
routeServlet.doGet(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
@@ -290,6 +292,7 @@ public class RouteServletTest extends DrServletTestBase
@Test
public void Given_Request_Is_HTTP_POST_And_Is_Not_Authorized() throws Exception {
routeServlet.doPost(request, response);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscribeServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscribeServletTest.java
index cdf96ba6..25341d42 100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscribeServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscribeServletTest.java
@@ -81,6 +81,7 @@ public class SubscribeServletTest extends DrServletTestBase {
@Test
public void Given_Request_Is_HTTP_GET_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated() throws Exception {
when(request.isSecure()).thenReturn(false);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
subscribeServlet.doGet(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
@@ -137,6 +138,7 @@ public class SubscribeServletTest extends DrServletTestBase {
@Test
public void Given_Request_Is_HTTP_POST_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated() throws Exception {
when(request.isSecure()).thenReturn(false);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
subscribeServlet.doPost(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServletTest.java
index b42e3a76..c5660672 100644..100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscriptionServletTest.java
@@ -73,6 +73,7 @@ public class SubscriptionServletTest extends DrServletTestBase {
@Test
public void Given_Request_Is_HTTP_DELETE_SC_Forbidden_Response_Is_Generated() throws Exception {
when(request.isSecure()).thenReturn(false);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
subscriptionServlet.doDelete(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
@@ -130,6 +131,7 @@ public class SubscriptionServletTest extends DrServletTestBase {
@Test
public void Given_Request_Is_HTTP_GET_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated() throws Exception {
when(request.isSecure()).thenReturn(false);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
subscriptionServlet.doGet(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
@@ -184,6 +186,7 @@ public class SubscriptionServletTest extends DrServletTestBase {
@Test
public void Given_Request_Is_HTTP_PUT_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated() throws Exception {
when(request.isSecure()).thenReturn(false);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
subscriptionServlet.doPut(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
@@ -323,6 +326,7 @@ public class SubscriptionServletTest extends DrServletTestBase {
@Test
public void Given_Request_Is_HTTP_POST_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated() throws Exception {
when(request.isSecure()).thenReturn(false);
+ FieldUtils.writeDeclaredStaticField(BaseServlet.class, "isAddressAuthEnabled", "true", true);
subscriptionServlet.doPost(request, response);
verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
}
diff --git a/datarouter-prov/src/test/resources/integration_test.properties b/datarouter-prov/src/test/resources/integration_test.properties
index 36b2ac3c..9ac1850a 100644
--- a/datarouter-prov/src/test/resources/integration_test.properties
+++ b/datarouter-prov/src/test/resources/integration_test.properties
@@ -1,5 +1,5 @@
-test.keystore=self_signed/keystore.jks
-test.kspassword=changeit
-test.truststore=self_signed/cacerts.jks
-test.tspassword=changeit
-test.host=https://prov.datarouternew.com:8443 \ No newline at end of file
+test.keystore=aaf_certs/org.onap.dmaap-dr.jks
+test.kspassword=Qgw77oaQcdP*F8Pwa[&.,.Ab
+test.truststore=aaf_certs/org.onap.dmaap-dr.trust.jks
+test.tspassword=9M?)?:KAj1z6gpLhNrVUG@0T
+test.host=https://dmaap-dr-prov:8443 \ No newline at end of file