summaryrefslogtreecommitdiffstats
path: root/engine-d/src
diff options
context:
space:
mode:
authortangpeng <tang.peng5@zte.com.cn>2019-03-30 07:58:02 +0000
committertangpeng <tang.peng5@zte.com.cn>2019-03-30 07:58:02 +0000
commit3f438510b3aae2372b33d4d976cd10482a07492a (patch)
tree9fa778a3985723598148182b69010b74a4c4d199 /engine-d/src
parent7ca609c6fecdb3e6996f12572aedde702bf375c9 (diff)
HTTP/S Modifications
Change-Id: Icabaf996d23297d0d5f16601645665a128616105 Issue-ID: HOLMES-203 Signed-off-by: tangpeng <tang.peng5@zte.com.cn>
Diffstat (limited to 'engine-d/src')
-rw-r--r--engine-d/src/main/java/org/onap/holmes/dsa/dmaappolling/Subscriber.java2
-rw-r--r--engine-d/src/main/java/org/onap/holmes/engine/EngineDActiveApp.java24
-rw-r--r--engine-d/src/test/java/org/onap/holmes/engine/EngineDActiveAppTest.java4
3 files changed, 18 insertions, 12 deletions
diff --git a/engine-d/src/main/java/org/onap/holmes/dsa/dmaappolling/Subscriber.java b/engine-d/src/main/java/org/onap/holmes/dsa/dmaappolling/Subscriber.java
index 160fc38..245647d 100644
--- a/engine-d/src/main/java/org/onap/holmes/dsa/dmaappolling/Subscriber.java
+++ b/engine-d/src/main/java/org/onap/holmes/dsa/dmaappolling/Subscriber.java
@@ -87,7 +87,7 @@ public class Subscriber {
CloseableHttpClient closeableHttpClient = null;
HttpGet httpGet = new HttpGet(url + "/" + consumerGroup + "/" + consumer + "?timeout=" + period);
try {
- closeableHttpClient = HttpsUtils.getHttpClient(timeout);
+ closeableHttpClient = HttpsUtils.getConditionalHttpsClient(timeout);
HttpResponse httpResponse = HttpsUtils
.get(httpGet, new HashMap<>(), closeableHttpClient);
response = HttpsUtils.extractResponseEntity(httpResponse);
diff --git a/engine-d/src/main/java/org/onap/holmes/engine/EngineDActiveApp.java b/engine-d/src/main/java/org/onap/holmes/engine/EngineDActiveApp.java
index c045050..9417242 100644
--- a/engine-d/src/main/java/org/onap/holmes/engine/EngineDActiveApp.java
+++ b/engine-d/src/main/java/org/onap/holmes/engine/EngineDActiveApp.java
@@ -16,19 +16,11 @@
package org.onap.holmes.engine;
import io.dropwizard.setup.Environment;
-
-import java.util.EnumSet;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-import javax.servlet.DispatcherType;
-
import lombok.extern.slf4j.Slf4j;
import org.onap.holmes.common.config.MicroServiceConfig;
import org.onap.holmes.common.dropwizard.ioc.bundle.IOCApplication;
import org.onap.holmes.common.exception.CorrelationException;
+import org.onap.holmes.common.utils.HttpsUtils;
import org.onap.holmes.common.utils.MSBRegisterUtil;
import org.onap.holmes.common.utils.transactionid.TransactionIdFilter;
import org.onap.holmes.engine.dcae.DcaeConfigurationPolling;
@@ -36,6 +28,14 @@ import org.onap.holmes.engine.resources.EngineResources;
import org.onap.msb.sdk.discovery.entity.MicroServiceInfo;
import org.onap.msb.sdk.discovery.entity.Node;
+import javax.servlet.DispatcherType;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
@Slf4j
public class EngineDActiveApp extends IOCApplication<EngineDAppConfig> {
@@ -66,6 +66,8 @@ public class EngineDActiveApp extends IOCApplication<EngineDAppConfig> {
}
private MicroServiceInfo createMicroServiceInfo() {
+ String msbAddrTemplate = (HttpsUtils.isHttpsEnabled() ? "https" : "http")
+ + "://%s:%s/api/holmes-engine-mgmt/v1/healthcheck";
String[] serviceAddrInfo = MicroServiceConfig.getMicroServiceIpAndPort();
MicroServiceInfo msinfo = new MicroServiceInfo();
msinfo.setServiceName("holmes-engine-mgmt");
@@ -73,13 +75,13 @@ public class EngineDActiveApp extends IOCApplication<EngineDAppConfig> {
msinfo.setUrl("/api/holmes-engine-mgmt/v1");
msinfo.setProtocol("REST");
msinfo.setVisualRange("0|1");
- msinfo.setEnable_ssl(true);
+ msinfo.setEnable_ssl(HttpsUtils.isHttpsEnabled());
Set<Node> nodes = new HashSet<>();
Node node = new Node();
node.setIp(serviceAddrInfo[0]);
node.setPort("9102");
node.setCheckType("HTTP");
- node.setCheckUrl(String.format("https://%s:%s/api/holmes-engine-mgmt/v1/healthcheck", serviceAddrInfo[0], "9102"));
+ node.setCheckUrl(String.format(msbAddrTemplate, serviceAddrInfo[0], "9102"));
node.setCheckTimeOut("60s");
node.setCheckInterval("60s");
nodes.add(node);
diff --git a/engine-d/src/test/java/org/onap/holmes/engine/EngineDActiveAppTest.java b/engine-d/src/test/java/org/onap/holmes/engine/EngineDActiveAppTest.java
index 1a5795a..7c9b652 100644
--- a/engine-d/src/test/java/org/onap/holmes/engine/EngineDActiveAppTest.java
+++ b/engine-d/src/test/java/org/onap/holmes/engine/EngineDActiveAppTest.java
@@ -22,16 +22,19 @@ import org.onap.holmes.common.config.MicroServiceConfig;
import org.onap.msb.sdk.discovery.entity.MicroServiceInfo;
import org.onap.msb.sdk.discovery.entity.Node;
import org.powermock.api.easymock.PowerMock;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;
+import static org.easymock.EasyMock.anyObject;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
@PrepareForTest(MicroServiceConfig.class)
@RunWith(PowerMockRunner.class)
+@PowerMockIgnore("javax.net.ssl.*")
public class EngineDActiveAppTest {
public static void main(String[] args) throws Exception {
@@ -48,6 +51,7 @@ public class EngineDActiveAppTest {
serviceAddrInfo[1] = "80";
EasyMock.expect(MicroServiceConfig.getMicroServiceIpAndPort()).andReturn(serviceAddrInfo);
EasyMock.expectLastCall();
+ EasyMock.expect(MicroServiceConfig.getEnv(anyObject(String.class))).andReturn("true").times(2);
PowerMock.replayAll();
MicroServiceInfo msinfo = Whitebox.invokeMethod(engineDActiveApp,"createMicroServiceInfo");