[SDC Client] Allow HTTP 86/126186/9
authorSylvain Desbureaux <sylvain.desbureaux@orange.com>
Fri, 10 Dec 2021 09:55:32 +0000 (10:55 +0100)
committerDan Timoney <dtimoney@att.com>
Mon, 13 Dec 2021 20:51:33 +0000 (20:51 +0000)
By default, SDC client is using only https, which can be problematic
when used on top of service mesh for example.
Let's override isUseHttpsWithSDC in order to allow use of http thanks to
a configuration variable.

Issue-ID: OOM-2258
Signed-off-by: Sylvain Desbureaux <sylvain.desbureaux@orange.com>
Change-Id: I029f1dc802bba647b8088fb61a5e60680337aa00

ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/SdcListenerConfiguration.java
ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImpl.java
ms/sdclistener/application/src/main/resources/application.yaml
ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/SdcListenerConfigurationTest.java
ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImplTest.java
ms/sdclistener/distribution/src/main/dc/docker-compose.yaml
ms/sdclistener/parent/pom.xml

index 5caac6a..b56772a 100644 (file)
@@ -67,6 +67,21 @@ public class SdcListenerConfiguration implements IConfiguration {
     @Value("${listenerservice.config.isUseHttpsWithDmaap}")
     private boolean isUseHttpsWithDmaap;
 
+    @Value("${listenerservice.config.isUseHttpsWithSDC}")
+    private boolean isUseHttpsWithSDC;
+
+    @Value("${listenerservice.config.httpsProxyHost}")
+    private String getHttpsProxyHost;
+
+    @Value("${listenerservice.config.httpProxyHost}")
+    private String getHttpProxyHost;
+
+    @Value("${listenerservice.config.httpsProxyPort}")
+    private int getHttpsProxyPort;
+
+    @Value("${listenerservice.config.httpProxyPort}")
+    private int getHttpProxyPort;
+
     @Override
     public String getAsdcAddress() {
         return asdcAddress;
@@ -142,5 +157,31 @@ public class SdcListenerConfiguration implements IConfiguration {
         return isUseHttpsWithDmaap;
     }
 
+    @Override
+    public Boolean isUseHttpsWithSDC() {
+        return isUseHttpsWithSDC;
+    }
+
+    @Override
+    public String getHttpsProxyHost() {
+        return getHttpsProxyHost;
+    }
+
+    @Override
+    public String getHttpProxyHost() {
+        return getHttpsProxyHost;
+    }
+
+    @Override
+    public int getHttpsProxyPort() {
+        return getHttpsProxyPort;
+    }
+
+    @Override
+    public int getHttpProxyPort() {
+        return getHttpsProxyPort;
+    }
+
+
 }
 
index ee27a94..dd81d76 100644 (file)
@@ -81,8 +81,7 @@ public class ListenerServiceImpl implements ListenerService {
     @Value("${listenerservice.config.grpcPort}")
     private int grpcPort;
 
-    private static final String CBA_ZIP_PATH =
-            "Artifacts/[a-zA-Z0-9-_.]+/Deployment/CONTROLLER_BLUEPRINT_ARCHIVE/[a-zA-Z0-9-_.()]+[.]zip";
+    private static final String CBA_ZIP_PATH = "Artifacts/[a-zA-Z0-9-_.]+/Deployment/CONTROLLER_BLUEPRINT_ARCHIVE/[a-zA-Z0-9-_.()]+[.]zip";
     private static final int SUCCESS_CODE = 200;
     private static final Logger LOGGER = LoggerFactory.getLogger(ListenerServiceImpl.class);
 
index d07d8ae..080f19d 100644 (file)
@@ -14,10 +14,15 @@ listenerservice:
     keyStorePath: ${keyStorePath}
     activateServerTLSAuth : ${activateServerTLSAuth:false}
     isUseHttpsWithDmaap: ${isUseHttpsWithDmaap:false}
+    isUseHttpsWithSDC: ${isUseHttpsWithSDC:true}
     archivePath: ${archivePath:/opt/app/onap/cds-sdc-listener/}
     grpcAddress: ${grpcAddress:localhost}
     grpcPort: ${grpcPort:9111}
     authHeader: ${authHeader:Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==}
+    httpsProxyHost: ${httpsProxyHost:}
+    httpProxyHost: ${httpProxyHost:}
+    httpsProxyPort: ${httpsProxyPort:0}
+    httpProxyPort: ${httpProxyPort:0}
 #port needed by Liveness probe
 server:
   port: ${healthcheckPort:9000}
index 8275bc0..bc07c52 100644 (file)
@@ -46,6 +46,8 @@ public class SdcListenerConfigurationTest {
         assertEquals(listenerConfiguration.getEnvironmentName(), "AUTO");
         assertEquals(listenerConfiguration.getConsumerID(), "cds-id-local");
         assertEquals(listenerConfiguration.activateServerTLSAuth(), false);
+        assertEquals(listenerConfiguration.isUseHttpsWithSDC(), true);
+        assertEquals(listenerConfiguration.isUseHttpsWithDmaap(), false);
     }
 
 }
index 4179cca..dcf942f 100644 (file)
@@ -32,7 +32,7 @@ import org.onap.ccsdk.cds.sdclistener.dto.SdcListenerDto;
 import org.onap.ccsdk.cds.sdclistener.handler.BluePrintProcesssorHandler;
 import org.onap.ccsdk.cds.sdclistener.status.SdcListenerStatus;
 import org.onap.sdc.api.results.IDistributionClientDownloadResult;
-import org.onap.sdc.impl.mock.DistributionClientResultStubImpl;
+import org.onap.sdc.utils.DistributionActionResultEnum;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.boot.test.context.SpringBootTest;
@@ -50,15 +50,14 @@ import static org.onap.ccsdk.cds.sdclistener.status.SdcListenerStatus.Notificati
 import static org.onap.sdc.utils.DistributionStatusEnum.COMPONENT_DONE_OK;
 
 @RunWith(SpringRunner.class)
-@EnableConfigurationProperties({SdcListenerAuthClientInterceptor.class, BluePrintProcesssorHandler.class,
-        SdcListenerDto.class, ListenerServiceImpl.class, SdcListenerStatus.class, SdcListenerConfiguration.class})
-@SpringBootTest(classes = {ListenerServiceImplTest.class})
+@EnableConfigurationProperties({ SdcListenerAuthClientInterceptor.class, BluePrintProcesssorHandler.class,
+        SdcListenerDto.class, ListenerServiceImpl.class, SdcListenerStatus.class, SdcListenerConfiguration.class })
+@SpringBootTest(classes = { ListenerServiceImplTest.class })
 public class ListenerServiceImplTest {
 
     private static final String CSAR_SAMPLE = "src/test/resources/service-ServicePnfTest-csar.csar";
     private static final String WRONG_CSAR_SAMPLE = "src/test/resources/wrong_csar_pattern.csar";
-    private static final String CBA_ZIP_PATH =
-            "Artifacts/[a-zA-Z0-9-_.]+/Deployment/CONTROLLER_BLUEPRINT_ARCHIVE/[a-zA-Z0-9-_.()]+[.]zip";
+    private static final String CBA_ZIP_PATH = "Artifacts/[a-zA-Z0-9-_.]+/Deployment/CONTROLLER_BLUEPRINT_ARCHIVE/[a-zA-Z0-9-_.()]+[.]zip";
     private static final String ZIP_FILE = ".zip";
     private static final String CSAR_FILE = ".csar";
     private static final String DISTRIBUTION_ID = "1";
@@ -141,10 +140,20 @@ public class ListenerServiceImplTest {
         return null;
     }
 
-    public class DistributionClientDownloadResultStubImpl extends DistributionClientResultStubImpl
-            implements IDistributionClientDownloadResult {
+    public class DistributionClientDownloadResultStubImpl implements IDistributionClientDownloadResult {
 
-        public DistributionClientDownloadResultStubImpl() {}
+        @Override
+        public DistributionActionResultEnum getDistributionActionResult() {
+            return DistributionActionResultEnum.SUCCESS;
+        }
+
+        @Override
+        public String getDistributionMessageResult() {
+            return "Stub Result, method not implemented!";
+        }
+
+        public DistributionClientDownloadResultStubImpl() {
+        }
 
         public byte[] getArtifactPayload() {
             File file = Paths.get(CSAR_SAMPLE).toFile();
index 1c68f6c..b03953e 100755 (executable)
@@ -20,6 +20,7 @@ services:
       keyStorePath:
       activateServerTLSAuth: "false"
       isUseHttpsWithDmaap: "false"
+      isUseHttpsWithSDC: "true"
       archivePath: /opt/app/onap/cds-sdc-listener/
       grpcAddress: localhost
       grpcPort: 9111
@@ -27,3 +28,7 @@ services:
       #port needed by Liveness probe
       healthcheckPort: "9000"
       sprintWebListenerEnabled: "true"
+      httpsProxyHost:
+      httpProxyHost:
+      httpsProxyPort: 0
+      httpProxyPort: 0
index 244102d..98574b0 100755 (executable)
@@ -39,7 +39,7 @@
         <mockk.version>1.9</mockk.version>
         <dmaap.client.version>1.1.5</dmaap.client.version>
         <mockkserver.version>5.5.1</mockkserver.version>
-        <sdc-distribution-client.version>1.4.0</sdc-distribution-client.version>
+        <sdc-distribution-client.version>1.4.5</sdc-distribution-client.version>
         <jmockit.version>1.49</jmockit.version>
         <reactorcore.version>3.2.6.RELEASE</reactorcore.version>
     </properties>