From 69e393da4cce52a0491fffff2dc81fbe59aeca08 Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Wed, 17 Feb 2021 15:25:45 -0500 Subject: Add new EnvProperties class Added new class EnvProperties, which extends java.util.Properties and supports property values containing embedded environment variable references. Updated code to use this class to load svclogic.properties, and updated dmaap listener to use that class to load dmaap listener configuration. Issue-ID: SDNC-1482 Signed-off-by: Dan Timoney Change-Id: I7538b719631d8c10c27d059aeb4f70ce92760ebd --- .../onap/ccsdk/sli/adaptors/aai/AAIRequest.java | 3 +- .../onap/ccsdk/sli/adaptors/aai/AAIService.java | 5 +- .../ccsdk/sli/adaptors/aai/AAIServiceProvider.java | 3 +- .../src/main/resources/aaiclient.properties | 6 +-- .../impl/AnsibleAdapterPropertiesProviderImpl.java | 5 +- .../mdsal/MdsalResourcePropertiesProviderImpl.java | 5 +- .../src/main/resources/mdsal-resource.properties | 4 +- .../src/main/resources/svclogic.properties | 8 +-- adaptors/netbox-client/provider/pom.xml | 20 +++---- .../adaptors/netbox/property/NetboxProperties.java | 4 +- .../sql/SqlResourcePropertiesProviderImpl.java | 5 +- .../src/main/resources/sql-resource.properties | 2 +- .../src/main/resources/svclogic.properties | 8 +-- .../adaptors/resource/sql/ITCaseSqlResource.java | 3 +- .../src/test/resources/sql-resource.properties | 2 +- .../src/test/resources/svclogic.properties | 8 +-- core/sli/common/pom.xml | 28 ++++++++-- .../org/onap/ccsdk/sli/core/sli/MessageWriter.java | 3 +- .../ccsdk/sli/core/sli/SvcLogicStoreFactory.java | 3 +- .../ccsdk/sli/core/sli/ITCaseSvcLogicParser.java | 5 +- .../ccsdk/sli/core/sli/TestSvcLogicLoader.java | 3 +- .../common/src/test/resources/svclogic.properties | 8 +-- core/sli/provider/pom.xml | 60 ++++++++++++++------- .../provider/SvcLogicPropertiesProviderImpl.java | 10 ++-- .../sli/provider/ITCaseSvcLogicGraphExecutor.java | 5 +- .../src/test/resources/svclogic.properties | 8 +-- .../sliapi/model/swagger/src/main/json/sliapi.json | 2 +- .../sliapi/model/swagger/src/main/yaml/sliapi.yaml | 46 ++++++++-------- core/sliapi/provider/pom.xml | 16 ++++++ .../ccsdk/sli/core/sliapi/TestSliapiProvider.java | 3 +- .../src/test/resources/svclogic.properties | 8 +-- core/utils/provider/pom.xml | 16 ++++++ .../ccsdk/sli/core/utils/common/EnvProperties.java | 61 ++++++++++++++++++++++ .../sli/core/utils/common/EnvPropertiesTest.java | 59 +++++++++++++++++++++ .../src/test/resources/svclogic.properties | 27 ++++++++++ .../DaeximOffsiteBackupProvider.java | 3 +- .../DaeximOffsiteBackupUtil.java | 4 +- .../resources/daexim-offsite-backup.properties | 4 +- .../resources/daexim-offsite-backup.properties | 4 +- northbound/dmaap-listener/pom.xml | 14 ++++- .../sli/northbound/dmaapclient/DmaapListener.java | 4 +- .../northbound/dmaapclient/TestDmaapListener.java | 3 +- .../src/test/resources/dmaap-consumer-1.properties | 10 ++-- .../dmaap-consumer-a1Adapter-policy-1.properties | 10 ++-- .../resources/dmaap-consumer-cMNotify-1.properties | 10 ++-- .../dmaap-consumer-esrsysteminfo.properties | 10 ++-- .../dmaap-consumer-generic-vnf.properties | 12 ++--- .../resources/dmaap-consumer-pserver.properties | 12 ++--- northbound/lcm/provider/pom.xml | 27 ++++++++++ .../onap/ccsdk/sli/northbound/TestLcmProvider.java | 3 +- .../src/test/resources/svclogic.properties | 8 +-- .../northbound/uebclient/SdncUebConfiguration.java | 3 +- .../src/test/resources/ueb-listener.properties | 8 +-- plugins/grToolkit/provider/pom.xml | 20 +++++++ .../sli/plugins/grtoolkit/GrToolkitProvider.java | 3 +- .../src/main/resources/gr-toolkit.properties | 2 +- .../src/test/resources/gr-toolkit.properties | 2 +- .../test/resources/single/gr-toolkit.properties | 2 +- .../src/test/resources/six/gr-toolkit.properties | 2 +- .../src/test/resources/three/gr-toolkit.properties | 2 +- .../ccsdk/sli/plugins/prop/PropertiesNode.java | 13 +++-- .../sli/plugins/restapicall/RestapiCallNode.java | 3 +- 62 files changed, 485 insertions(+), 175 deletions(-) create mode 100644 core/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/EnvProperties.java create mode 100644 core/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/EnvPropertiesTest.java create mode 100644 core/utils/provider/src/test/resources/svclogic.properties diff --git a/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java b/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java index 9facab82c..b38e75195 100755 --- a/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java +++ b/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java @@ -53,6 +53,7 @@ import java.util.TreeSet; import org.apache.commons.lang.StringUtils; import org.onap.aai.inventory.v21.GenericVnf; import org.onap.ccsdk.sli.adaptors.aai.data.AAIDatum; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.FrameworkUtil; @@ -194,7 +195,7 @@ public abstract class AAIRequest { try { Reader reader = new InputStreamReader(in, StandardCharsets.UTF_8); - Properties properties = new Properties(); + Properties properties = new EnvProperties(); properties.load(reader); LOG.info("loaded " + properties.size()); diff --git a/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIService.java b/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIService.java index 4d51550a3..747688746 100755 --- a/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIService.java +++ b/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIService.java @@ -81,6 +81,7 @@ import org.onap.ccsdk.sli.core.sli.MetricLogger; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicResource; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.onap.aai.inventory.v21.GenericVnf; import org.onap.aai.inventory.v21.PhysicalLink; import org.onap.aai.inventory.v21.ResultData; @@ -322,7 +323,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe } private static Properties getProperties(URL url) { - Properties properties = new Properties(); + Properties properties = new EnvProperties(); try { properties.load(url.openStream()); } catch (IOException exc) { @@ -491,7 +492,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe } InputStream is = null; - Properties props = new Properties(); + Properties props = new EnvProperties(); try { if(LOG.isDebugEnabled()) diff --git a/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIServiceProvider.java b/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIServiceProvider.java index 743f975b6..edc2e850d 100755 --- a/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIServiceProvider.java +++ b/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIServiceProvider.java @@ -37,6 +37,7 @@ import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver; import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; import org.onap.ccsdk.sli.core.utils.common.BundleContextFileResolver; import org.onap.ccsdk.sli.core.utils.common.CoreDefaultFileResolver; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.onap.ccsdk.sli.core.utils.common.SdncConfigEnvVarFileResolver; import org.osgi.framework.BundleContext; import org.osgi.framework.FrameworkUtil; @@ -110,7 +111,7 @@ public class AAIServiceProvider implements UtilsProvider { final File propertiesFile = determinePropertiesFile(); if (propertiesFile != null) { try(FileInputStream fileInputStream = new FileInputStream(propertiesFile)) { - properties = new Properties(); + properties = new EnvProperties(); properties.load(fileInputStream); if(properties.containsKey(AAICLIENT_PROPERTY_NAME)) { diff --git a/adaptors/aai-service/provider/src/main/resources/aaiclient.properties b/adaptors/aai-service/provider/src/main/resources/aaiclient.properties index 979537f8e..3fd79d0c9 100755 --- a/adaptors/aai-service/provider/src/main/resources/aaiclient.properties +++ b/adaptors/aai-service/provider/src/main/resources/aaiclient.properties @@ -27,11 +27,11 @@ # Certificate keystore and truststore # org.onap.ccsdk.sli.adaptors.aai.ssl.trust=/opt/onap/ccsdk/data/stores/truststore.onap.client.jks -org.onap.ccsdk.sli.adaptors.aai.ssl.trust.psswd=adminadmin +org.onap.ccsdk.sli.adaptors.aai.ssl.trust.psswd=${AAI_TRUSTSTORE_PASSWORD:-adminadmin}` org.onap.ccsdk.sli.adaptors.aai.host.certificate.ignore=true -org.onap.ccsdk.sli.adaptors.aai.client.name=SDNC -org.onap.ccsdk.sli.adaptors.aai.client.psswd=SDNC +org.onap.ccsdk.sli.adaptors.aai.client.name=${AAI_CLIENT_NAME:-SDNC} +org.onap.ccsdk.sli.adaptors.aai.client.psswd=${AAI_CLIENT_PASSWORD:-SDNC} org.onap.ccsdk.sli.adaptors.aai.application=CCSDK # diff --git a/adaptors/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/AnsibleAdapterPropertiesProviderImpl.java b/adaptors/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/AnsibleAdapterPropertiesProviderImpl.java index 482aaf8e5..36eec6a4b 100755 --- a/adaptors/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/AnsibleAdapterPropertiesProviderImpl.java +++ b/adaptors/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/AnsibleAdapterPropertiesProviderImpl.java @@ -33,6 +33,7 @@ import org.onap.ccsdk.sli.core.utils.JREFileResolver; import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver; import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; import org.onap.ccsdk.sli.core.utils.common.CoreDefaultFileResolver; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.onap.ccsdk.sli.core.utils.common.SdncConfigEnvVarFileResolver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -89,7 +90,7 @@ public class AnsibleAdapterPropertiesProviderImpl implements AnsibleAdapterPrope final File propertiesFile = determinePropertiesFile(this); if (propertiesFile != null) { try (FileInputStream fileInputStream = new FileInputStream(propertiesFile)) { - properties = new Properties(); + properties = new EnvProperties(); properties.load(fileInputStream); } catch (final IOException e) { LOG.error("Failed to load properties for file: {}", propertiesFile.toString(), @@ -101,7 +102,7 @@ public class AnsibleAdapterPropertiesProviderImpl implements AnsibleAdapterPrope InputStream propStr = getClass().getResourceAsStream("/" + ANSIBLEADAPTER_PROP_FILE_NAME); if (propStr != null) { - properties = new Properties(); + properties = new EnvProperties(); try { properties.load(propStr); propStr.close(); diff --git a/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/MdsalResourcePropertiesProviderImpl.java b/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/MdsalResourcePropertiesProviderImpl.java index e9e006f17..eee5f099f 100755 --- a/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/MdsalResourcePropertiesProviderImpl.java +++ b/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/MdsalResourcePropertiesProviderImpl.java @@ -33,6 +33,7 @@ import org.onap.ccsdk.sli.core.utils.JREFileResolver; import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver; import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; import org.onap.ccsdk.sli.core.utils.common.CoreDefaultFileResolver; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.onap.ccsdk.sli.core.utils.common.SdncConfigEnvVarFileResolver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -89,7 +90,7 @@ public class MdsalResourcePropertiesProviderImpl implements MdsalResourcePropert final File propertiesFile = determinePropertiesFile(this); if (propertiesFile != null) { try (FileInputStream fileInputStream = new FileInputStream(propertiesFile)) { - properties = new Properties(); + properties = new EnvProperties(); properties.load(fileInputStream); } catch (final IOException e) { LOG.error("Failed to load properties for file: {}", propertiesFile.toString(), @@ -101,7 +102,7 @@ public class MdsalResourcePropertiesProviderImpl implements MdsalResourcePropert InputStream propStr = getClass().getResourceAsStream("/" + MDSALRESOURCE_PROP_FILE_NAME); if (propStr != null) { - properties = new Properties(); + properties = new EnvProperties(); try { properties.load(propStr); propStr.close(); diff --git a/adaptors/mdsal-resource/provider/src/main/resources/mdsal-resource.properties b/adaptors/mdsal-resource/provider/src/main/resources/mdsal-resource.properties index 47c8ebf77..4e348b3c8 100644 --- a/adaptors/mdsal-resource/provider/src/main/resources/mdsal-resource.properties +++ b/adaptors/mdsal-resource/provider/src/main/resources/mdsal-resource.properties @@ -19,8 +19,8 @@ # ============LICENSE_END========================================================= ### -org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-user=admin -org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-passwd=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U +org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-user=${ODL_USER:-admin} +org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-passwd=${ODL_PASSWORD:-Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U} org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-host=localhost org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-protocol=http org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-port=8181 diff --git a/adaptors/mdsal-resource/provider/src/main/resources/svclogic.properties b/adaptors/mdsal-resource/provider/src/main/resources/svclogic.properties index 0abadc5c8..2c91a05d0 100644 --- a/adaptors/mdsal-resource/provider/src/main/resources/svclogic.properties +++ b/adaptors/mdsal-resource/provider/src/main/resources/svclogic.properties @@ -20,7 +20,7 @@ ### org.onap.ccsdk.sli.adaptors.dbtype = jdbc -org.onap.ccsdk.sli.adaptors.jdbc.url = jdbc:mysql://dbhost:3306/sdnctl -org.onap.ccsdk.sli.adaptors.jdbc.database = sdnctl -org.onap.ccsdk.sli.adaptors.jdbc.user = sdnctl -org.onap.ccsdk.sli.adaptors.jdbc.password = gamma +org.onap.ccsdk.sli.adaptors.jdbc.url = jdbc:mysql://dbhost:3306/${MYSQL_DATABASE} +org.onap.ccsdk.sli.adaptors.jdbc.database = ${MYSQL_DATABASE} +org.onap.ccsdk.sli.adaptors.jdbc.user = ${MYSQL_USER} +org.onap.ccsdk.sli.adaptors.jdbc.password = ${MYSQL_PASSWORD} diff --git a/adaptors/netbox-client/provider/pom.xml b/adaptors/netbox-client/provider/pom.xml index 483e80868..93eedd92d 100644 --- a/adaptors/netbox-client/provider/pom.xml +++ b/adaptors/netbox-client/provider/pom.xml @@ -22,7 +22,7 @@ org.onap.ccsdk.parent binding-parent 2.1.1-SNAPSHOT - + org.onap.ccsdk.sli.adaptors @@ -33,15 +33,15 @@ ccsdk-sli-adaptors :: netbox-client :: ${project.artifactId} - - - org.onap.ccsdk.sli.core - sli-core-artifacts - ${project.version} - pom - import - - + + + org.onap.ccsdk.sli.core + sli-core-artifacts + ${project.version} + pom + import + + diff --git a/adaptors/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/property/NetboxProperties.java b/adaptors/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/property/NetboxProperties.java index 9b4751e64..643a2dbed 100644 --- a/adaptors/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/property/NetboxProperties.java +++ b/adaptors/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/property/NetboxProperties.java @@ -20,6 +20,8 @@ import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.Properties; + +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.FrameworkUtil; @@ -52,7 +54,7 @@ public class NetboxProperties { } private void loadProps() { - properties = new Properties(); + properties = new EnvProperties(); // Try to load config from dir final String ccsdkConfigDir = System.getProperty(PROPERTIES_DIR_KEY, DEFAULT_PROPERTIES_DIR) + "/" + NETBOX_PROPERTY_FILE_NAME; diff --git a/adaptors/sql-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/sql/SqlResourcePropertiesProviderImpl.java b/adaptors/sql-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/sql/SqlResourcePropertiesProviderImpl.java index 7c9f6f161..f55390c39 100755 --- a/adaptors/sql-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/sql/SqlResourcePropertiesProviderImpl.java +++ b/adaptors/sql-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/sql/SqlResourcePropertiesProviderImpl.java @@ -33,6 +33,7 @@ import org.onap.ccsdk.sli.core.utils.JREFileResolver; import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver; import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; import org.onap.ccsdk.sli.core.utils.common.CoreDefaultFileResolver; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.onap.ccsdk.sli.core.utils.common.SdncConfigEnvVarFileResolver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -89,7 +90,7 @@ public class SqlResourcePropertiesProviderImpl implements SqlResourcePropertiesP final File propertiesFile = determinePropertiesFile(this); if (propertiesFile != null) { try (FileInputStream fileInputStream = new FileInputStream(propertiesFile)) { - properties = new Properties(); + properties = new EnvProperties(); properties.load(fileInputStream); } catch (final IOException e) { LOG.error("Failed to load properties for file: {}", propertiesFile.toString(), @@ -101,7 +102,7 @@ public class SqlResourcePropertiesProviderImpl implements SqlResourcePropertiesP InputStream propStr = getClass().getResourceAsStream("/" + SQLRESOURCE_PROP_FILE_NAME); if (propStr != null) { - properties = new Properties(); + properties = new EnvProperties(); try { properties.load(propStr); propStr.close(); diff --git a/adaptors/sql-resource/provider/src/main/resources/sql-resource.properties b/adaptors/sql-resource/provider/src/main/resources/sql-resource.properties index ac32f7734..0e3714eb6 100755 --- a/adaptors/sql-resource/provider/src/main/resources/sql-resource.properties +++ b/adaptors/sql-resource/provider/src/main/resources/sql-resource.properties @@ -19,5 +19,5 @@ # ============LICENSE_END========================================================= ### -org.openecomp.sdnc.resource.sql.cryptkey=QtfJMKggVk +org.onap.sdnc.resource.sql.cryptkey=${SQL_CRYPTKEY:-duMmyCrYptkEy} diff --git a/adaptors/sql-resource/provider/src/main/resources/svclogic.properties b/adaptors/sql-resource/provider/src/main/resources/svclogic.properties index 18718b869..65f3b2315 100644 --- a/adaptors/sql-resource/provider/src/main/resources/svclogic.properties +++ b/adaptors/sql-resource/provider/src/main/resources/svclogic.properties @@ -21,10 +21,10 @@ org.onap.ccsdk.sli.adaptors.dbtype=jdbc org.onap.ccsdk.sli.adaptors.jdbc.hosts=sdnctldb01,sdnctldb02 -org.onap.ccsdk.sli.adaptors.jdbc.url=jdbc:mysql://DBHOST:3306/sdnctl -org.onap.ccsdk.sli.adaptors.jdbc.database=sdnctl -org.onap.ccsdk.sli.adaptors.jdbc.user=sdnctl -org.onap.ccsdk.sli.adaptors.jdbc.password=gamma +org.onap.ccsdk.sli.adaptors.jdbc.url=jdbc:mysql://DBHOST:3306/${MYSQL_DATABASE} +org.onap.ccsdk.sli.adaptors.jdbc.database=${MYSQL_DATABASE} +org.onap.ccsdk.sli.adaptors.jdbc.user=${MYSQL_USER} +org.onap.ccsdk.sli.adaptors.jdbc.password=${MYSQL_PASSWORD} org.onap.ccsdk.sli.adaptors.jdbc.connection.name=sdnctldb01 org.onap.ccsdk.sli.adaptors.jdbc.connection.timeout=50 diff --git a/adaptors/sql-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/sql/ITCaseSqlResource.java b/adaptors/sql-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/sql/ITCaseSqlResource.java index 2863c6c96..4bf991e22 100755 --- a/adaptors/sql-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/sql/ITCaseSqlResource.java +++ b/adaptors/sql-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/sql/ITCaseSqlResource.java @@ -29,6 +29,7 @@ import java.util.Properties; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,7 +46,7 @@ public class ITCaseSqlResource extends TestCase { public void testExists() throws Exception { - Properties props = new Properties(); + Properties props = new EnvProperties(); InputStream propStr = getClass().getResourceAsStream("/svclogic.properties"); if (propStr == null) { fail("src/test/resources/svclogic.properties missing"); diff --git a/adaptors/sql-resource/provider/src/test/resources/sql-resource.properties b/adaptors/sql-resource/provider/src/test/resources/sql-resource.properties index ac32f7734..0e3714eb6 100755 --- a/adaptors/sql-resource/provider/src/test/resources/sql-resource.properties +++ b/adaptors/sql-resource/provider/src/test/resources/sql-resource.properties @@ -19,5 +19,5 @@ # ============LICENSE_END========================================================= ### -org.openecomp.sdnc.resource.sql.cryptkey=QtfJMKggVk +org.onap.sdnc.resource.sql.cryptkey=${SQL_CRYPTKEY:-duMmyCrYptkEy} diff --git a/adaptors/sql-resource/provider/src/test/resources/svclogic.properties b/adaptors/sql-resource/provider/src/test/resources/svclogic.properties index 6504e1aec..80c025359 100644 --- a/adaptors/sql-resource/provider/src/test/resources/svclogic.properties +++ b/adaptors/sql-resource/provider/src/test/resources/svclogic.properties @@ -21,11 +21,11 @@ org.onap.ccsdk.sli.dbtype=jdbc org.onap.ccsdk.sli.jdbc.hosts=sdnctldb01 -org.onap.ccsdk.sli.jdbc.url=jdbc:mysql://dbhost:3306/sdnctl +org.onap.ccsdk.sli.jdbc.url=jdbc:mysql://dbhost:3306/${MYSQL_DATABASE} org.onap.ccsdk.sli.jdbc.driver=org.mariadb.jdbc.Driver -org.onap.ccsdk.sli.jdbc.database=sdnctl -org.onap.ccsdk.sli.jdbc.user=sdnctl -org.onap.ccsdk.sli.jdbc.password=gamma +org.onap.ccsdk.sli.jdbc.database=${MYSQL_DATABASE} +org.onap.ccsdk.sli.jdbc.user=${MYSQL_USER} +org.onap.ccsdk.sli.jdbc.password=${MYSQL_PASSWORD} org.onap.ccsdk.sli.jdbc.connection.name=sdnctldb01 org.onap.ccsdk.sli.jdbc.connection.timeout=50 org.onap.ccsdk.sli.jdbc.request.timeout=100 diff --git a/core/sli/common/pom.xml b/core/sli/common/pom.xml index 34db3104c..716bef397 100755 --- a/core/sli/common/pom.xml +++ b/core/sli/common/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent binding-parent 2.1.1-SNAPSHOT - + org.onap.ccsdk.sli.core @@ -18,8 +18,8 @@ The SLI Common package includes common classes used by the various SLI subcomponents, as well as classes used by clients to interface with the service logic interpreter - - **/MessageWriter.java + + **/MessageWriter.java @@ -124,6 +124,28 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + + dummyUser + dummyPassword + dummyDatabase + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + dummyUser + dummyPassword + dummyDatabase + + + diff --git a/core/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java b/core/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java index 5ededb9eb..1b9b17951 100644 --- a/core/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java +++ b/core/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java @@ -30,6 +30,7 @@ import java.util.Date; import java.util.Properties; import javax.sql.rowset.CachedRowSet; import org.onap.ccsdk.sli.core.dblib.DbLibService; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -62,7 +63,7 @@ public class MessageWriter { initialized = true; // Read properties - Properties props = new Properties(); + Properties props = new EnvProperties(); String propPath = System.getenv(SVCLOGIC_PROP_VAR); if (propPath == null) { diff --git a/core/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java b/core/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java index e0eb57304..9076901a2 100644 --- a/core/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java +++ b/core/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java @@ -27,6 +27,7 @@ import java.io.InputStream; import java.util.Properties; import org.onap.ccsdk.sli.core.dblib.DBResourceManager; import org.onap.ccsdk.sli.core.utils.PathValidator; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,7 +59,7 @@ public class SvcLogicStoreFactory { public static SvcLogicStore getSvcLogicStore(InputStream inStr) throws SvcLogicException { - Properties props = new Properties(); + Properties props = new EnvProperties(); try { props.load(inStr); diff --git a/core/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java b/core/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java index 50eb917f8..715af9e8a 100644 --- a/core/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java +++ b/core/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java @@ -43,6 +43,7 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.onap.ccsdk.sli.core.dblib.DBResourceManager; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -64,7 +65,7 @@ public class ITCaseSvcLogicParser { InputStream propStr = ITCaseSvcLogicParser.class.getResourceAsStream("/svclogic.properties"); - Properties props = new Properties(); + Properties props = new EnvProperties(); props.load(propStr); @@ -150,7 +151,7 @@ public class ITCaseSvcLogicParser { InputStream propStr = ITCaseSvcLogicParser.class.getResourceAsStream("/dblib.properties"); - Properties props = new Properties(); + Properties props = new EnvProperties(); props.load(propStr); diff --git a/core/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestSvcLogicLoader.java b/core/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestSvcLogicLoader.java index 2dd83e86d..c868c8a81 100644 --- a/core/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestSvcLogicLoader.java +++ b/core/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/TestSvcLogicLoader.java @@ -7,6 +7,7 @@ import java.io.InputStream; import java.net.URL; import java.util.Properties; import org.junit.Test; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; public class TestSvcLogicLoader { @@ -16,7 +17,7 @@ public class TestSvcLogicLoader { InputStream propStr = ITCaseSvcLogicParser.class.getResourceAsStream("/svclogic.properties"); - Properties props = new Properties(); + Properties props = new EnvProperties(); props.load(propStr); diff --git a/core/sli/common/src/test/resources/svclogic.properties b/core/sli/common/src/test/resources/svclogic.properties index 426960f76..85818d7b6 100644 --- a/core/sli/common/src/test/resources/svclogic.properties +++ b/core/sli/common/src/test/resources/svclogic.properties @@ -20,8 +20,8 @@ ### org.onap.ccsdk.sli.dbtype = jdbc -org.onap.ccsdk.sli.jdbc.url=jdbc:derby:memory:sdnctl;create=true +org.onap.ccsdk.sli.jdbc.url=jdbc:derby:memory:${MYSQL_DATABASE};create=true org.onap.ccsdk.sli.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver -org.onap.ccsdk.sli.jdbc.database = sdnctl -org.onap.ccsdk.sli.jdbc.user = test -org.onap.ccsdk.sli.jdbc.password = test +org.onap.ccsdk.sli.jdbc.database = ${MYSQL_DATABASE} +org.onap.ccsdk.sli.jdbc.user = ${MYSQL_USER} +org.onap.ccsdk.sli.jdbc.password = ${MYSQL_PASSWORD} diff --git a/core/sli/provider/pom.xml b/core/sli/provider/pom.xml index d45b2e0f4..5f236809a 100755 --- a/core/sli/provider/pom.xml +++ b/core/sli/provider/pom.xml @@ -6,7 +6,7 @@ org.onap.ccsdk.parent binding-parent 2.1.1-SNAPSHOT - + org.onap.ccsdk.sli.core @@ -68,31 +68,31 @@ mdsal-binding-api provided - - org.opendaylight.mdsal.binding.model.ietf - rfc6991 + + org.opendaylight.mdsal.binding.model.ietf + rfc6991 provided - + org.opendaylight.bgpcep bgp-concepts provided true - - org.opendaylight.mdsal - mdsal-dom-api - provided - - - org.opendaylight.mdsal - yang-binding - provided - - - com.google.code.findbugs - annotations - + + org.opendaylight.mdsal + mdsal-dom-api + provided + + + org.opendaylight.mdsal + yang-binding + provided + + + com.google.code.findbugs + annotations + junit junit @@ -146,6 +146,28 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + + dummyUser + dummyPassword + dummyDatabase + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + dummyUser + dummyPassword + dummyDatabase + + + diff --git a/core/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImpl.java b/core/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImpl.java index aad7a5a6d..40d305610 100644 --- a/core/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImpl.java +++ b/core/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicPropertiesProviderImpl.java @@ -35,6 +35,7 @@ import org.onap.ccsdk.sli.core.utils.JREFileResolver; import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver; import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; import org.onap.ccsdk.sli.core.utils.common.CoreDefaultFileResolver; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.onap.ccsdk.sli.core.utils.common.SdncConfigEnvVarFileResolver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -69,9 +70,10 @@ public class SvcLogicPropertiesProviderImpl implements SvcLogicPropertiesProvide private Vector sliPropertiesFileResolvers = new Vector<>(); /** - * The configuration properties for the db connection. + * The configuration properties for the db connection. Use EnvProperties class, which + * extends Properties and resolves env variable references in values */ - private Properties properties; + private EnvProperties properties; /** * Set up the prioritized list of strategies for resolving dblib properties @@ -91,7 +93,7 @@ public class SvcLogicPropertiesProviderImpl implements SvcLogicPropertiesProvide final File propertiesFile = determinePropertiesFile(this); if (propertiesFile != null) { try (FileInputStream fileInputStream = new FileInputStream(propertiesFile)) { - properties = new Properties(); + properties = new EnvProperties(); properties.load(fileInputStream); } catch (final IOException e) { log.error("Failed to load properties for file: {}", propertiesFile.toString(), @@ -103,7 +105,7 @@ public class SvcLogicPropertiesProviderImpl implements SvcLogicPropertiesProvide InputStream propStr = getClass().getResourceAsStream("/" + SVCLOGIC_PROP_FILE_NAME); if (propStr != null) { - properties = new Properties(); + properties = new EnvProperties(); try { properties.load(propStr); propStr.close(); diff --git a/core/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java b/core/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java index ad439cdb4..02582269a 100644 --- a/core/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java +++ b/core/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java @@ -65,6 +65,7 @@ import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicPropertiesProvider; import org.onap.ccsdk.sli.core.sli.provider.base.SwitchNodeExecutor; import org.onap.ccsdk.sli.core.sli.provider.base.UpdateNodeExecutor; import org.onap.ccsdk.sli.core.sli.provider.base.WhileNodeExecutor; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -106,7 +107,7 @@ public class ITCaseSvcLogicGraphExecutor { InputStream propStr = ITCaseSvcLogicGraphExecutor.class.getResourceAsStream("/svclogic.properties"); - Properties svcprops = new Properties(); + Properties svcprops = new EnvProperties(); svcprops.load(propStr); SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(svcprops); @@ -152,7 +153,7 @@ public class ITCaseSvcLogicGraphExecutor { InputStream propStr = getClass().getResourceAsStream("/svclogic.properties"); - Properties svcprops = new Properties(); + Properties svcprops = new EnvProperties(); svcprops.load(propStr); diff --git a/core/sli/provider/src/test/resources/svclogic.properties b/core/sli/provider/src/test/resources/svclogic.properties index 426960f76..85818d7b6 100644 --- a/core/sli/provider/src/test/resources/svclogic.properties +++ b/core/sli/provider/src/test/resources/svclogic.properties @@ -20,8 +20,8 @@ ### org.onap.ccsdk.sli.dbtype = jdbc -org.onap.ccsdk.sli.jdbc.url=jdbc:derby:memory:sdnctl;create=true +org.onap.ccsdk.sli.jdbc.url=jdbc:derby:memory:${MYSQL_DATABASE};create=true org.onap.ccsdk.sli.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver -org.onap.ccsdk.sli.jdbc.database = sdnctl -org.onap.ccsdk.sli.jdbc.user = test -org.onap.ccsdk.sli.jdbc.password = test +org.onap.ccsdk.sli.jdbc.database = ${MYSQL_DATABASE} +org.onap.ccsdk.sli.jdbc.user = ${MYSQL_USER} +org.onap.ccsdk.sli.jdbc.password = ${MYSQL_PASSWORD} diff --git a/core/sliapi/model/swagger/src/main/json/sliapi.json b/core/sliapi/model/swagger/src/main/json/sliapi.json index 3848cb551..284defcc8 100644 --- a/core/sliapi/model/swagger/src/main/json/sliapi.json +++ b/core/sliapi/model/swagger/src/main/json/sliapi.json @@ -1 +1 @@ -{"swagger":"2.0","info":{"description":"This module contains a collection of generally useful derived\nYANG data types for Internet addresses and related things.\n\nCopyright (c) 2013 IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\nRedistribution and use in source and binary forms, with or\nwithout modification, is permitted pursuant to, and subject\nto the license terms contained in, the Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\nRelating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal notices.,Defines API to service logic interpreter,This module contains a collection of generally useful derived\nYANG data types.\n\nCopyright (c) 2013 IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\nRedistribution and use in source and binary forms, with or\nwithout modification, is permitted pursuant to, and subject\nto the license terms contained in, the Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\nRelating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal notices.","version":"1.2.0-SNAPSHOT","title":"ietf-inet-types,SLI-API,ietf-yang-types API"},"consumes":["application/json","application/xml"],"produces":["application/json","application/xml"],"paths":{"/config/SLI-API:test-results/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.TestResults","responseSchema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"},"schema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"}}}},"post":{"tags":["SLI-API"],"description":"creates sli.api.TestResults","parameters":[{"in":"body","name":"sli.api.TestResults.body-param","description":"sli.api.TestResults to be added to list","required":false,"schema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}},"put":{"tags":["SLI-API"],"description":"creates or updates sli.api.TestResults","parameters":[{"in":"body","name":"sli.api.TestResults.body-param","description":"sli.api.TestResults to be added or updated","required":false,"schema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"204":{"description":"Object modified"}}},"delete":{"tags":["SLI-API"],"description":"removes sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"204":{"description":"Object deleted"}}}},"/config/SLI-API:test-results/SLI-API:test-result/":{"post":{"description":"creates sli.api.testresults.TestResult","parameters":[{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added to list","required":false,"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}}},"/config/SLI-API:test-results/SLI-API:test-result/{test-identifier}/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.testresults.TestResult","responseSchema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"},"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}}},"post":{"tags":["SLI-API"],"description":"creates sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"},{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added to list","required":false,"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}},"put":{"tags":["SLI-API"],"description":"creates or updates sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"},{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added or updated","required":false,"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"204":{"description":"Object modified"}}},"delete":{"tags":["SLI-API"],"description":"removes sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"204":{"description":"Object deleted"}}}},"/operational/SLI-API:test-results/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.TestResults","responseSchema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"},"schema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"}}}}},"/operational/SLI-API:test-results/SLI-API:test-result/{test-identifier}/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.testresults.TestResult","responseSchema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"},"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}}}},"/operations/SLI-API:execute-graph/":{"post":{"tags":["SLI-API"],"parameters":[{"in":"body","name":"sli.api.executegraph.Input.body-param","required":false,"schema":{"properties":{"input":{"originalRef":"#/definitions/sli.api.executegraph.Input","$ref":"#/definitions/sli.api.executegraph.Input"}}}}],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","responseSchema":{"originalRef":"#/definitions/sli.api.ExecuteGraph","$ref":"#/definitions/sli.api.ExecuteGraph"},"schema":{"originalRef":"#/definitions/sli.api.ExecuteGraph","$ref":"#/definitions/sli.api.ExecuteGraph"}},"201":{"description":"No response"}}}},"/operations/SLI-API:healthcheck/":{"post":{"tags":["SLI-API"],"parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","responseSchema":{"originalRef":"#/definitions/sli.api.Healthcheck","$ref":"#/definitions/sli.api.Healthcheck"},"schema":{"originalRef":"#/definitions/sli.api.Healthcheck","$ref":"#/definitions/sli.api.Healthcheck"}},"201":{"description":"No response"}}}},"/operations/SLI-API:vlbcheck/":{"post":{"tags":["SLI-API"],"parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","responseSchema":{"originalRef":"#/definitions/sli.api.Vlbcheck","$ref":"#/definitions/sli.api.Vlbcheck"},"schema":{"originalRef":"#/definitions/sli.api.Vlbcheck","$ref":"#/definitions/sli.api.Vlbcheck"}},"201":{"description":"No response"}}}}},"definitions":{"sli.api.ExecuteGraph":{"type":"object","properties":{"output":{"originalRef":"#/definitions/sli.api.ResponseFields","$ref":"#/definitions/sli.api.ResponseFields"}}},"sli.api.Healthcheck":{"type":"object","properties":{"output":{"originalRef":"#/definitions/sli.api.ResponseFields","$ref":"#/definitions/sli.api.ResponseFields"}}},"sli.api.ModeEnumeration":{"type":"string","enum":["sync","async"]},"sli.api.ParameterSetting":{"type":"object","properties":{"string-value":{"type":"string"},"boolean-value":{"type":"boolean"},"parameter-name":{"type":"string","description":"Parameter name"},"int-value":{"type":"integer","format":"int32"}}},"sli.api.ResponseFields":{"type":"object","properties":{"response-code":{"type":"string"},"response-message":{"type":"string"},"context-memory-json":{"type":"string"},"ack-final-indicator":{"type":"string"}}},"sli.api.TestResults":{"type":"object","properties":{"test-result":{"type":"array","items":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}}},"sli.api.Vlbcheck":{"type":"object","properties":{"output":{"originalRef":"#/definitions/sli.api.ResponseFields","$ref":"#/definitions/sli.api.ResponseFields"}}},"sli.api.executegraph.Input":{"type":"object","properties":{"mode":{"originalRef":"#/definitions/sli.api.ModeEnumeration","$ref":"#/definitions/sli.api.ModeEnumeration"},"module-name":{"type":"string"},"sli-parameter":{"type":"array","items":{"originalRef":"#/definitions/sli.api.ParameterSetting","$ref":"#/definitions/sli.api.ParameterSetting"}},"rpc-name":{"type":"string"}}},"sli.api.testresults.TestResult":{"type":"object","properties":{"results":{"type":"array","items":{"type":"string"}},"test-identifier":{"type":"string"}}}}} \ No newline at end of file +{"swagger":"2.0","info":{"description":"Defines API to service logic interpreter,This module contains a collection of generally useful derived\nYANG data types.\n\nCopyright (c) 2013 IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\nRedistribution and use in source and binary forms, with or\nwithout modification, is permitted pursuant to, and subject\nto the license terms contained in, the Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\nRelating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal notices.,This module contains a collection of generally useful derived\nYANG data types for Internet addresses and related things.\n\nCopyright (c) 2013 IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\nRedistribution and use in source and binary forms, with or\nwithout modification, is permitted pursuant to, and subject\nto the license terms contained in, the Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\nRelating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal notices.","version":"1.2.0-SNAPSHOT","title":"SLI-API,ietf-yang-types,ietf-inet-types API"},"consumes":["application/json","application/xml"],"produces":["application/json","application/xml"],"paths":{"/config/SLI-API:test-results/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.TestResults","schema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"},"responseSchema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"}}}},"post":{"tags":["SLI-API"],"description":"creates sli.api.TestResults","parameters":[{"in":"body","name":"sli.api.TestResults.body-param","description":"sli.api.TestResults to be added to list","required":false,"schema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}},"put":{"tags":["SLI-API"],"description":"creates or updates sli.api.TestResults","parameters":[{"in":"body","name":"sli.api.TestResults.body-param","description":"sli.api.TestResults to be added or updated","required":false,"schema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"204":{"description":"Object modified"}}},"delete":{"tags":["SLI-API"],"description":"removes sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"204":{"description":"Object deleted"}}}},"/config/SLI-API:test-results/SLI-API:test-result/":{"post":{"description":"creates sli.api.testresults.TestResult","parameters":[{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added to list","required":false,"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}}},"/config/SLI-API:test-results/SLI-API:test-result/{test-identifier}/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.testresults.TestResult","schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"},"responseSchema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}}},"post":{"tags":["SLI-API"],"description":"creates sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"},{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added to list","required":false,"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"409":{"description":"Object already exists"}}},"put":{"tags":["SLI-API"],"description":"creates or updates sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"},{"in":"body","name":"sli.api.testresults.TestResult.body-param","description":"sli.api.testresults.TestResult to be added or updated","required":false,"schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}],"responses":{"400":{"description":"Internal error"},"201":{"description":"Object created"},"204":{"description":"Object modified"}}},"delete":{"tags":["SLI-API"],"description":"removes sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"204":{"description":"Object deleted"}}}},"/operational/SLI-API:test-results/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.TestResults","parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.TestResults","schema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"},"responseSchema":{"originalRef":"#/definitions/sli.api.TestResults","$ref":"#/definitions/sli.api.TestResults"}}}}},"/operational/SLI-API:test-results/SLI-API:test-result/{test-identifier}/":{"get":{"tags":["SLI-API"],"description":"returns sli.api.testresults.TestResult","parameters":[{"name":"test-identifier","in":"path","description":"Id of test-result","required":true,"type":"string"}],"responses":{"400":{"description":"Internal error"},"200":{"description":"sli.api.testresults.TestResult","schema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"},"responseSchema":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}}}},"/operations/SLI-API:execute-graph/":{"post":{"tags":["SLI-API"],"parameters":[{"in":"body","name":"sli.api.executegraph.Input.body-param","required":false,"schema":{"properties":{"input":{"originalRef":"#/definitions/sli.api.executegraph.Input","$ref":"#/definitions/sli.api.executegraph.Input"}}}}],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","schema":{"originalRef":"#/definitions/sli.api.ExecuteGraph","$ref":"#/definitions/sli.api.ExecuteGraph"},"responseSchema":{"originalRef":"#/definitions/sli.api.ExecuteGraph","$ref":"#/definitions/sli.api.ExecuteGraph"}},"201":{"description":"No response"}}}},"/operations/SLI-API:healthcheck/":{"post":{"tags":["SLI-API"],"parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","schema":{"originalRef":"#/definitions/sli.api.Healthcheck","$ref":"#/definitions/sli.api.Healthcheck"},"responseSchema":{"originalRef":"#/definitions/sli.api.Healthcheck","$ref":"#/definitions/sli.api.Healthcheck"}},"201":{"description":"No response"}}}},"/operations/SLI-API:vlbcheck/":{"post":{"tags":["SLI-API"],"parameters":[],"responses":{"400":{"description":"Internal error"},"200":{"description":"Correct response","schema":{"originalRef":"#/definitions/sli.api.Vlbcheck","$ref":"#/definitions/sli.api.Vlbcheck"},"responseSchema":{"originalRef":"#/definitions/sli.api.Vlbcheck","$ref":"#/definitions/sli.api.Vlbcheck"}},"201":{"description":"No response"}}}}},"definitions":{"sli.api.ExecuteGraph":{"type":"object","properties":{"output":{"originalRef":"#/definitions/sli.api.ResponseFields","$ref":"#/definitions/sli.api.ResponseFields"}}},"sli.api.Healthcheck":{"type":"object","properties":{"output":{"originalRef":"#/definitions/sli.api.ResponseFields","$ref":"#/definitions/sli.api.ResponseFields"}}},"sli.api.ModeEnumeration":{"type":"string","enum":["sync","async"]},"sli.api.ParameterSetting":{"type":"object","properties":{"string-value":{"type":"string"},"boolean-value":{"type":"boolean"},"parameter-name":{"type":"string","description":"Parameter name"},"int-value":{"type":"integer","format":"int32"}}},"sli.api.ResponseFields":{"type":"object","properties":{"response-code":{"type":"string"},"response-message":{"type":"string"},"context-memory-json":{"type":"string"},"ack-final-indicator":{"type":"string"}}},"sli.api.TestResults":{"type":"object","properties":{"test-result":{"type":"array","items":{"originalRef":"#/definitions/sli.api.testresults.TestResult","$ref":"#/definitions/sli.api.testresults.TestResult"}}}},"sli.api.Vlbcheck":{"type":"object","properties":{"output":{"originalRef":"#/definitions/sli.api.ResponseFields","$ref":"#/definitions/sli.api.ResponseFields"}}},"sli.api.executegraph.Input":{"type":"object","properties":{"mode":{"originalRef":"#/definitions/sli.api.ModeEnumeration","$ref":"#/definitions/sli.api.ModeEnumeration"},"module-name":{"type":"string"},"sli-parameter":{"type":"array","items":{"originalRef":"#/definitions/sli.api.ParameterSetting","$ref":"#/definitions/sli.api.ParameterSetting"}},"rpc-name":{"type":"string"}}},"sli.api.testresults.TestResult":{"type":"object","properties":{"results":{"type":"array","items":{"type":"string"}},"test-identifier":{"type":"string"}}}}} \ No newline at end of file diff --git a/core/sliapi/model/swagger/src/main/yaml/sliapi.yaml b/core/sliapi/model/swagger/src/main/yaml/sliapi.yaml index b97b1325a..d323e1058 100644 --- a/core/sliapi/model/swagger/src/main/yaml/sliapi.yaml +++ b/core/sliapi/model/swagger/src/main/yaml/sliapi.yaml @@ -1,25 +1,25 @@ --- swagger: "2.0" info: - description: "This module contains a collection of generally useful derived\nYANG\ - \ data types for Internet addresses and related things.\n\nCopyright (c) 2013\ - \ IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\ - \nRedistribution and use in source and binary forms, with or\nwithout modification,\ + description: "Defines API to service logic interpreter,This module contains a collection\ + \ of generally useful derived\nYANG data types.\n\nCopyright (c) 2013 IETF Trust\ + \ and the persons identified as\nauthors of the code. All rights reserved.\n\n\ + Redistribution and use in source and binary forms, with or\nwithout modification,\ \ is permitted pursuant to, and subject\nto the license terms contained in, the\ \ Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\n\ Relating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version\ \ of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal\ - \ notices.,Defines API to service logic interpreter,This module contains a collection\ - \ of generally useful derived\nYANG data types.\n\nCopyright (c) 2013 IETF Trust\ - \ and the persons identified as\nauthors of the code. All rights reserved.\n\n\ - Redistribution and use in source and binary forms, with or\nwithout modification,\ + \ notices.,This module contains a collection of generally useful derived\nYANG\ + \ data types for Internet addresses and related things.\n\nCopyright (c) 2013\ + \ IETF Trust and the persons identified as\nauthors of the code. All rights reserved.\n\ + \nRedistribution and use in source and binary forms, with or\nwithout modification,\ \ is permitted pursuant to, and subject\nto the license terms contained in, the\ \ Simplified BSD License\nset forth in Section 4.c of the IETF Trust's Legal Provisions\n\ Relating to IETF Documents\n(http://trustee.ietf.org/license-info).\n\nThis version\ \ of this YANG module is part of RFC 6991; see\nthe RFC itself for full legal\ \ notices." version: "1.2.0-SNAPSHOT" - title: "ietf-inet-types,SLI-API,ietf-yang-types API" + title: "SLI-API,ietf-yang-types,ietf-inet-types API" consumes: - "application/json" - "application/xml" @@ -38,10 +38,10 @@ paths: description: "Internal error" 200: description: "sli.api.TestResults" - responseSchema: + schema: originalRef: "#/definitions/sli.api.TestResults" $ref: "#/definitions/sli.api.TestResults" - schema: + responseSchema: originalRef: "#/definitions/sli.api.TestResults" $ref: "#/definitions/sli.api.TestResults" post: @@ -126,10 +126,10 @@ paths: description: "Internal error" 200: description: "sli.api.testresults.TestResult" - responseSchema: + schema: originalRef: "#/definitions/sli.api.testresults.TestResult" $ref: "#/definitions/sli.api.testresults.TestResult" - schema: + responseSchema: originalRef: "#/definitions/sli.api.testresults.TestResult" $ref: "#/definitions/sli.api.testresults.TestResult" post: @@ -206,10 +206,10 @@ paths: description: "Internal error" 200: description: "sli.api.TestResults" - responseSchema: + schema: originalRef: "#/definitions/sli.api.TestResults" $ref: "#/definitions/sli.api.TestResults" - schema: + responseSchema: originalRef: "#/definitions/sli.api.TestResults" $ref: "#/definitions/sli.api.TestResults" /operational/SLI-API:test-results/SLI-API:test-result/{test-identifier}/: @@ -228,10 +228,10 @@ paths: description: "Internal error" 200: description: "sli.api.testresults.TestResult" - responseSchema: + schema: originalRef: "#/definitions/sli.api.testresults.TestResult" $ref: "#/definitions/sli.api.testresults.TestResult" - schema: + responseSchema: originalRef: "#/definitions/sli.api.testresults.TestResult" $ref: "#/definitions/sli.api.testresults.TestResult" /operations/SLI-API:execute-graph/: @@ -252,10 +252,10 @@ paths: description: "Internal error" 200: description: "Correct response" - responseSchema: + schema: originalRef: "#/definitions/sli.api.ExecuteGraph" $ref: "#/definitions/sli.api.ExecuteGraph" - schema: + responseSchema: originalRef: "#/definitions/sli.api.ExecuteGraph" $ref: "#/definitions/sli.api.ExecuteGraph" 201: @@ -270,10 +270,10 @@ paths: description: "Internal error" 200: description: "Correct response" - responseSchema: + schema: originalRef: "#/definitions/sli.api.Healthcheck" $ref: "#/definitions/sli.api.Healthcheck" - schema: + responseSchema: originalRef: "#/definitions/sli.api.Healthcheck" $ref: "#/definitions/sli.api.Healthcheck" 201: @@ -288,10 +288,10 @@ paths: description: "Internal error" 200: description: "Correct response" - responseSchema: + schema: originalRef: "#/definitions/sli.api.Vlbcheck" $ref: "#/definitions/sli.api.Vlbcheck" - schema: + responseSchema: originalRef: "#/definitions/sli.api.Vlbcheck" $ref: "#/definitions/sli.api.Vlbcheck" 201: diff --git a/core/sliapi/provider/pom.xml b/core/sliapi/provider/pom.xml index 5bccec9b6..d22ec5803 100755 --- a/core/sliapi/provider/pom.xml +++ b/core/sliapi/provider/pom.xml @@ -95,4 +95,20 @@ test + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + dummyUser + dummyPassword + dummyDatabase + + + + + diff --git a/core/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java b/core/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java index b731423c5..cd7dd2058 100644 --- a/core/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java +++ b/core/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java @@ -62,6 +62,7 @@ import org.onap.ccsdk.sli.core.sli.provider.base.SetNodeExecutor; import org.onap.ccsdk.sli.core.sli.provider.base.SwitchNodeExecutor; import org.onap.ccsdk.sli.core.sli.provider.base.UpdateNodeExecutor; import org.onap.ccsdk.sli.core.sli.provider.base.WhileNodeExecutor; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.mdsal.dom.api.DOMDataBroker; @@ -123,7 +124,7 @@ public class TestSliapiProvider { // Load svclogic.properties and get a SvcLogicStore InputStream propStr = TestSliapiProvider.class.getResourceAsStream("/svclogic.properties"); - Properties svcprops = new Properties(); + Properties svcprops = new EnvProperties(); svcprops.load(propStr); SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(svcprops); diff --git a/core/sliapi/provider/src/test/resources/svclogic.properties b/core/sliapi/provider/src/test/resources/svclogic.properties index 426960f76..85818d7b6 100644 --- a/core/sliapi/provider/src/test/resources/svclogic.properties +++ b/core/sliapi/provider/src/test/resources/svclogic.properties @@ -20,8 +20,8 @@ ### org.onap.ccsdk.sli.dbtype = jdbc -org.onap.ccsdk.sli.jdbc.url=jdbc:derby:memory:sdnctl;create=true +org.onap.ccsdk.sli.jdbc.url=jdbc:derby:memory:${MYSQL_DATABASE};create=true org.onap.ccsdk.sli.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver -org.onap.ccsdk.sli.jdbc.database = sdnctl -org.onap.ccsdk.sli.jdbc.user = test -org.onap.ccsdk.sli.jdbc.password = test +org.onap.ccsdk.sli.jdbc.database = ${MYSQL_DATABASE} +org.onap.ccsdk.sli.jdbc.user = ${MYSQL_USER} +org.onap.ccsdk.sli.jdbc.password = ${MYSQL_PASSWORD} diff --git a/core/utils/provider/pom.xml b/core/utils/provider/pom.xml index e3a805f82..a94183479 100644 --- a/core/utils/provider/pom.xml +++ b/core/utils/provider/pom.xml @@ -46,4 +46,20 @@ test + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + dummyUser + dummyPassword + dummyDatabase + + + + + diff --git a/core/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/EnvProperties.java b/core/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/EnvProperties.java new file mode 100644 index 000000000..2e9f2673d --- /dev/null +++ b/core/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/EnvProperties.java @@ -0,0 +1,61 @@ +package org.onap.ccsdk.sli.core.utils.common; + +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.util.Enumeration; +import java.util.Properties; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class EnvProperties extends Properties { + + @Override + public synchronized void load(Reader reader) throws IOException { + super.load(reader); + resolveAllValues(); + } + + @Override + public synchronized void load(InputStream inStream) throws IOException { + super.load(inStream); + resolveAllValues(); + } + + @Override + public synchronized Object setProperty(String key, String value) { + return super.setProperty(key, EnvProperties.resolveValue(value)); + } + + private void resolveAllValues() { + Enumeration propNames = propertyNames(); + + while (propNames.hasMoreElements()) { + String propName = (String) propNames.nextElement(); + super.setProperty(propName, EnvProperties.resolveValue(getProperty(propName))); + } + + } + + public static String resolveValue(String value) { + if (value == null) { + return null; + } + + Pattern p = Pattern.compile("\\$\\{(\\w+)((?:\\:\\-)([^\\}]*))?\\}"); + Matcher m = p.matcher(value); + + StringBuffer sb = new StringBuffer(); + while (m.find()) { + String envVarName = null == m.group(1) ? m.group(2) : m.group(1); + String envVarDefault = null == m.group(3) ? "" : m.group(3); + String envVarValue = System.getenv(envVarName); + + m.appendReplacement(sb, + null == envVarValue ? Matcher.quoteReplacement(envVarDefault) : Matcher.quoteReplacement(envVarValue)); + } + m.appendTail(sb); + return sb.toString(); + + } +} diff --git a/core/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/EnvPropertiesTest.java b/core/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/EnvPropertiesTest.java new file mode 100644 index 000000000..bee432577 --- /dev/null +++ b/core/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/EnvPropertiesTest.java @@ -0,0 +1,59 @@ +package org.onap.ccsdk.sli.core.utils.common; + +import static org.junit.Assert.*; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Properties; + +import org.junit.Before; +import org.junit.Test; + +public class EnvPropertiesTest { + + @Test + public void loadStreamTest() throws IOException { + InputStream testStr = getClass().getResourceAsStream("/svclogic.properties"); + + Properties props = new EnvProperties(); + props.load(testStr); + + assertEquals("jdbc", props.getProperty("org.onap.ccsdk.sli.dbtype")); + String dbUrl = "jdbc:derby:memory:"+System.getenv("MYSQL_DATABASE")+";create=true"; + assertEquals(dbUrl, props.getProperty("org.onap.ccsdk.sli.jdbc.url")); + assertEquals("org.apache.derby.jdbc.EmbeddedDriver", props.getProperty("org.onap.ccsdk.sli.jdbc.driver")); + assertEquals(System.getenv("MYSQL_DATABASE"), props.getProperty("org.onap.ccsdk.sli.jdbc.database")); + assertEquals(System.getenv("MYSQL_USER"), props.getProperty("org.onap.ccsdk.sli.jdbc.user") ); + assertEquals(System.getenv("MYSQL_PASSWORD"), props.getProperty("org.onap.ccsdk.sli.jdbc.password")); + } + + @Test + public void loadReaderTest() throws IOException { + InputStream testStr = getClass().getResourceAsStream("/svclogic.properties"); + BufferedReader testReader = new BufferedReader(new InputStreamReader(testStr)); + + Properties props = new EnvProperties(); + props.load(testReader); + + assertEquals("jdbc", props.getProperty("org.onap.ccsdk.sli.dbtype")); + String dbUrl = "jdbc:derby:memory:"+System.getenv("MYSQL_DATABASE")+";create=true"; + assertEquals(dbUrl, props.getProperty("org.onap.ccsdk.sli.jdbc.url")); + assertEquals("org.apache.derby.jdbc.EmbeddedDriver", props.getProperty("org.onap.ccsdk.sli.jdbc.driver")); + assertEquals(System.getenv("MYSQL_DATABASE"), props.getProperty("org.onap.ccsdk.sli.jdbc.database")); + assertEquals(System.getenv("MYSQL_USER"), props.getProperty("org.onap.ccsdk.sli.jdbc.user")); + assertEquals(System.getenv("MYSQL_PASSWORD"), props.getProperty("org.onap.ccsdk.sli.jdbc.password")); + } + + @Test + public void setPropertyTest() { + Properties props = new EnvProperties(); + + props.setProperty("path", "${PATH}"); + props.setProperty("dummy", "${UNSET_DUMMY:-dummyvalue}"); + assertEquals(System.getenv("PATH"), props.getProperty("path")); + assertEquals("dummyvalue", props.getProperty("dummy")); + } + +} diff --git a/core/utils/provider/src/test/resources/svclogic.properties b/core/utils/provider/src/test/resources/svclogic.properties new file mode 100644 index 000000000..0d62389f2 --- /dev/null +++ b/core/utils/provider/src/test/resources/svclogic.properties @@ -0,0 +1,27 @@ +### +# ============LICENSE_START======================================================= +# ONAP : CCSDK +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights +# reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +### + +org.onap.ccsdk.sli.dbtype = jdbc +org.onap.ccsdk.sli.jdbc.url=jdbc:derby:memory:${MYSQL_DATABASE};create=true +org.onap.ccsdk.sli.jdbc.driver=${MYSQL_DRIVER:-org.apache.derby.jdbc.EmbeddedDriver} +org.onap.ccsdk.sli.jdbc.database = ${MYSQL_DATABASE} +org.onap.ccsdk.sli.jdbc.user = ${MYSQL_USER} +org.onap.ccsdk.sli.jdbc.password = ${MYSQL_PASSWORD} diff --git a/northbound/daexim-offsite-backup/provider/src/main/java/org/onap/ccsdk/sli/northbound/daeximoffsitebackup/DaeximOffsiteBackupProvider.java b/northbound/daexim-offsite-backup/provider/src/main/java/org/onap/ccsdk/sli/northbound/daeximoffsitebackup/DaeximOffsiteBackupProvider.java index 7ee2a91d7..3d32c7d74 100755 --- a/northbound/daexim-offsite-backup/provider/src/main/java/org/onap/ccsdk/sli/northbound/daeximoffsitebackup/DaeximOffsiteBackupProvider.java +++ b/northbound/daexim-offsite-backup/provider/src/main/java/org/onap/ccsdk/sli/northbound/daeximoffsitebackup/DaeximOffsiteBackupProvider.java @@ -48,6 +48,7 @@ import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; import javax.annotation.Nonnull; import org.eclipse.jdt.annotation.NonNull; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.binding.api.DataTreeChangeListener; import org.opendaylight.mdsal.binding.api.RpcProviderService; @@ -112,7 +113,7 @@ public class DaeximOffsiteBackupProvider implements AutoCloseable, DaeximOffsite private void loadProperties() { LOG.info("Loading properties from " + PROPERTIES_FILE); if(properties == null) - properties = new Properties(); + properties = new EnvProperties(); File propertiesFile = new File(PROPERTIES_FILE); if(!propertiesFile.exists()) { LOG.warn("Properties file (" + PROPERTIES_FILE + ") not found. Using default properties."); diff --git a/northbound/daexim-offsite-backup/provider/src/main/java/org/onap/ccsdk/sli/northbound/daeximoffsitebackup/DaeximOffsiteBackupUtil.java b/northbound/daexim-offsite-backup/provider/src/main/java/org/onap/ccsdk/sli/northbound/daeximoffsitebackup/DaeximOffsiteBackupUtil.java index 7adb2fa1b..d53d2fcae 100755 --- a/northbound/daexim-offsite-backup/provider/src/main/java/org/onap/ccsdk/sli/northbound/daeximoffsitebackup/DaeximOffsiteBackupUtil.java +++ b/northbound/daexim-offsite-backup/provider/src/main/java/org/onap/ccsdk/sli/northbound/daeximoffsitebackup/DaeximOffsiteBackupUtil.java @@ -33,7 +33,7 @@ import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.daeximoffsiteb import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.daeximoffsitebackup.rev180926.RetrieveDataOutputBuilder; import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper; - +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,7 +43,7 @@ public class DaeximOffsiteBackupUtil extends MdsalHelper { public static void loadProperties() { File file = new File(PROPERTIES_FILE); - Properties properties = new Properties(); + Properties properties = new EnvProperties(); InputStream input = null; if(file.isFile() && file.canRead()) { try { diff --git a/northbound/daexim-offsite-backup/provider/src/main/resources/daexim-offsite-backup.properties b/northbound/daexim-offsite-backup/provider/src/main/resources/daexim-offsite-backup.properties index 51efc1f1e..3a0ce3591 100755 --- a/northbound/daexim-offsite-backup/provider/src/main/resources/daexim-offsite-backup.properties +++ b/northbound/daexim-offsite-backup/provider/src/main/resources/daexim-offsite-backup.properties @@ -20,9 +20,9 @@ # Example properties file daeximDirectory=/opt/opendaylight/current/daexim/ -credentials=admin:enc:YWRtaW4xMjM= +credentials=${ODL_USER}:${ODL_PASSWORD} nexusUrl=http://localhost:8081/nexus/content/repositories/ podName=UNKNOWN_ODL file.operational=odl_backup_operational.json file.models=odl_backup_models.json -file.config=odl_backup_config.json \ No newline at end of file +file.config=odl_backup_config.json diff --git a/northbound/daexim-offsite-backup/provider/src/test/resources/daexim-offsite-backup.properties b/northbound/daexim-offsite-backup/provider/src/test/resources/daexim-offsite-backup.properties index b69027906..bb1f28a0c 100755 --- a/northbound/daexim-offsite-backup/provider/src/test/resources/daexim-offsite-backup.properties +++ b/northbound/daexim-offsite-backup/provider/src/test/resources/daexim-offsite-backup.properties @@ -18,9 +18,9 @@ # ============LICENSE_END========================================================= daeximDirectory=/opt/opendaylight/current/daexim/ -credentials=admin:admin123 +credentials=${ODL_USER}:${ODL_PASSWORD} nexusUrl=http://localhost:8081/nexus/content/repositories/ podName=UNKNOWN_ODL file.operational=odl_backup_operational.json file.models=odl_backup_models.json -file.config=odl_backup_config.json \ No newline at end of file +file.config=odl_backup_config.json diff --git a/northbound/dmaap-listener/pom.xml b/northbound/dmaap-listener/pom.xml index 702ad369e..0d245a341 100755 --- a/northbound/dmaap-listener/pom.xml +++ b/northbound/dmaap-listener/pom.xml @@ -142,7 +142,19 @@ - + + org.apache.maven.plugins + maven-surefire-plugin + + + test + test + ABC123 + admin + admin + + + diff --git a/northbound/dmaap-listener/src/main/java/org/onap/ccsdk/sli/northbound/dmaapclient/DmaapListener.java b/northbound/dmaap-listener/src/main/java/org/onap/ccsdk/sli/northbound/dmaapclient/DmaapListener.java index 18c00d563..1c10b68e7 100755 --- a/northbound/dmaap-listener/src/main/java/org/onap/ccsdk/sli/northbound/dmaapclient/DmaapListener.java +++ b/northbound/dmaap-listener/src/main/java/org/onap/ccsdk/sli/northbound/dmaapclient/DmaapListener.java @@ -26,6 +26,8 @@ import java.io.FileInputStream; import java.util.LinkedList; import java.util.List; import java.util.Properties; + +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,7 +40,7 @@ public class DmaapListener { public static void main(String[] args) { - Properties properties = new Properties(); + Properties properties = new EnvProperties(); // Use EnvProperties to resolve env variables in values String propFileName = DMAAP_LISTENER_PROPERTIES; String propPath = null; String propDir = System.getProperty(SDNC_CONFIG_DIR); diff --git a/northbound/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestDmaapListener.java b/northbound/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestDmaapListener.java index 943ef0204..48eaa699d 100644 --- a/northbound/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestDmaapListener.java +++ b/northbound/dmaap-listener/src/test/java/org/onap/ccsdk/sli/northbound/dmaapclient/TestDmaapListener.java @@ -8,6 +8,7 @@ import java.util.Properties; import org.junit.Before; import org.junit.Test; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -24,7 +25,7 @@ public class TestDmaapListener { @Test public void test() { - Properties properties = new Properties(); + Properties properties = new EnvProperties(); String propFileName = DMAAP_LISTENER_PROPERTIES; String propPath = null; String propDir = DMAAP_LISTENER_PROPERTIES_DIR; diff --git a/northbound/dmaap-listener/src/test/resources/dmaap-consumer-1.properties b/northbound/dmaap-listener/src/test/resources/dmaap-consumer-1.properties index ae83ef8c2..5ec838f31 100755 --- a/northbound/dmaap-listener/src/test/resources/dmaap-consumer-1.properties +++ b/northbound/dmaap-listener/src/test/resources/dmaap-consumer-1.properties @@ -8,10 +8,10 @@ Partner = SubContextPath =/ Protocol =http MethodType =GET -username =test -password =test +username =${DMAAP_USER} +password =${DMAAP_PASSWORD} contenttype =application/json -authKey=ABC123 +authKey=${DMAAP_AUTHKEY} authDate=2016-05-10T13:13:50-0700 host=localhost:3904 topic=ccsdk-topic @@ -29,7 +29,7 @@ AFT_DME2_ROUNDTRIP_TIMEOUT_MS=240000 AFT_DME2_EP_READ_TIMEOUT_MS=50000 sessionstickinessrequired=NO DME2preferredRouterFilePath=src/test/resources/dmaap-listener.preferredRoute.txt -sdnc.odl.user=admin -sdnc.odl.password=admin +sdnc.odl.user=${ODL_USER} +sdnc.odl.password=${ODL_PASSWORD} sdnc.odl.url-base=http://localhost:8282/restconf/operations diff --git a/northbound/dmaap-listener/src/test/resources/dmaap-consumer-a1Adapter-policy-1.properties b/northbound/dmaap-listener/src/test/resources/dmaap-consumer-a1Adapter-policy-1.properties index edb7c453e..63bc4426d 100644 --- a/northbound/dmaap-listener/src/test/resources/dmaap-consumer-a1Adapter-policy-1.properties +++ b/northbound/dmaap-listener/src/test/resources/dmaap-consumer-a1Adapter-policy-1.properties @@ -9,10 +9,10 @@ routeOffer=MR1 SubContextPath =/ Protocol =http MethodType =GET -username =admin -password =admin +username =${DMAAP_USER} +password =${DMAAP_PASSWORD} contenttype =application/json -authKey=fs20cKwalJ6ry4kX:7Hqm6BDZK47IKxGRkOPFk33qMYs= +authKey=${DMAAP_AUTHKEY} authDate=2019-04-09T04:28:40-05:00 host=message-router.onap:3904 topic=A1-P @@ -30,6 +30,6 @@ AFT_DME2_ROUNDTRIP_TIMEOUT_MS=240000 AFT_DME2_EP_READ_TIMEOUT_MS=50000 sessionstickinessrequired=NO DME2preferredRouterFilePath=/opt/onap/sdnc/data/properties/dmaap-listener.preferredRoute.txt -sdnc.odl.user=admin -sdnc.odl.password=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U +sdnc.odl.user=${ODL_USER} +sdnc.odl.password=${ODL_PASSWORD} sdnc.odl.url-base=http://sdnc.onap:8282/restconf/operations diff --git a/northbound/dmaap-listener/src/test/resources/dmaap-consumer-cMNotify-1.properties b/northbound/dmaap-listener/src/test/resources/dmaap-consumer-cMNotify-1.properties index aae34a26f..b399d27f1 100644 --- a/northbound/dmaap-listener/src/test/resources/dmaap-consumer-cMNotify-1.properties +++ b/northbound/dmaap-listener/src/test/resources/dmaap-consumer-cMNotify-1.properties @@ -9,10 +9,10 @@ routeOffer=MR1 SubContextPath =/ Protocol =http MethodType =GET -username =admin -password =admin +username =${DMAAP_USER} +password =${DMAAP_PASSWORD} contenttype =application/json -authKey=fs20cKwalJ6ry4kX:7Hqm6BDZK47IKxGRkOPFk33qMYs= +authKey=${DMAAP_AUTHKEY} authDate=2019-04-09T04:28:40-05:00 host=message-router.onap:3904 topic=CM-NOTIFICATION @@ -30,6 +30,6 @@ AFT_DME2_ROUNDTRIP_TIMEOUT_MS=240000 AFT_DME2_EP_READ_TIMEOUT_MS=50000 sessionstickinessrequired=NO DME2preferredRouterFilePath=/opt/onap/sdnc/data/properties/dmaap-listener.preferredRoute.txt -sdnc.odl.user=admin -sdnc.odl.password=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U +sdnc.odl.user=${ODL_USER} +sdnc.odl.password=${ODL_PASSWORD} sdnc.odl.url-base=http://sdnc.onap:8282/restconf/operations diff --git a/northbound/dmaap-listener/src/test/resources/dmaap-consumer-esrsysteminfo.properties b/northbound/dmaap-listener/src/test/resources/dmaap-consumer-esrsysteminfo.properties index 9f5cfe71f..785d636bb 100644 --- a/northbound/dmaap-listener/src/test/resources/dmaap-consumer-esrsysteminfo.properties +++ b/northbound/dmaap-listener/src/test/resources/dmaap-consumer-esrsysteminfo.properties @@ -8,10 +8,10 @@ Partner = SubContextPath =/ Protocol =https MethodType =GET -username =test -password =test +username =${DMAAP_USER} +password =${DMAAP_PASSWORD} contenttype =application/json -authKey=ABC123 +authKey=${DMAAP_AUTHKEY} authDate=2016-05-10T13:13:50-0700 host=localhost:3904 topic=AAI-EVENT @@ -29,6 +29,6 @@ AFT_DME2_ROUNDTRIP_TIMEOUT_MS=240000 AFT_DME2_EP_READ_TIMEOUT_MS=50000 sessionstickinessrequired=NO DME2preferredRouterFilePath=src/test/resources/dmaap-listener.preferredRoute.txt -sdnc.odl.user=admin -sdnc.odl.password=admin +sdnc.odl.user=${ODL_USER} +sdnc.odl.password=${ODL_PASSWORD} sdnc.odl.url-base=http://localhost:8181/restconf/operations \ No newline at end of file diff --git a/northbound/dmaap-listener/src/test/resources/dmaap-consumer-generic-vnf.properties b/northbound/dmaap-listener/src/test/resources/dmaap-consumer-generic-vnf.properties index 710a7c7c9..d0e187d08 100644 --- a/northbound/dmaap-listener/src/test/resources/dmaap-consumer-generic-vnf.properties +++ b/northbound/dmaap-listener/src/test/resources/dmaap-consumer-generic-vnf.properties @@ -8,10 +8,10 @@ Partner = SubContextPath =/ Protocol =https MethodType =GET -username =test -password =test +username =${DMAAP_USER} +password =${DMAAP_PASSWORD} contenttype =application/json -authKey=ABC123 +authKey=${DMAAP_AUTHKEY} authDate=2016-05-10T13:13:50-0700 host=localhost:3904 topic=AAI-EVENT @@ -29,6 +29,6 @@ AFT_DME2_ROUNDTRIP_TIMEOUT_MS=240000 AFT_DME2_EP_READ_TIMEOUT_MS=50000 sessionstickinessrequired=NO DME2preferredRouterFilePath=src/test/resources/dmaap-listener.preferredRoute.txt -sdnc.odl.user=admin -sdnc.odl.password=admin -sdnc.odl.url-base=http://localhost:8181/restconf/operations \ No newline at end of file +sdnc.odl.user=${ODL_USER} +sdnc.odl.password=${ODL_PASSWORD} +sdnc.odl.url-base=http://localhost:8181/restconf/operations diff --git a/northbound/dmaap-listener/src/test/resources/dmaap-consumer-pserver.properties b/northbound/dmaap-listener/src/test/resources/dmaap-consumer-pserver.properties index 9f5cfe71f..2fb525e89 100644 --- a/northbound/dmaap-listener/src/test/resources/dmaap-consumer-pserver.properties +++ b/northbound/dmaap-listener/src/test/resources/dmaap-consumer-pserver.properties @@ -8,10 +8,10 @@ Partner = SubContextPath =/ Protocol =https MethodType =GET -username =test -password =test +username =${DMAAP_USER} +password =${DMAAP_PASSWORD} contenttype =application/json -authKey=ABC123 +authKey=${DMAAP_AUTHKEY} authDate=2016-05-10T13:13:50-0700 host=localhost:3904 topic=AAI-EVENT @@ -29,6 +29,6 @@ AFT_DME2_ROUNDTRIP_TIMEOUT_MS=240000 AFT_DME2_EP_READ_TIMEOUT_MS=50000 sessionstickinessrequired=NO DME2preferredRouterFilePath=src/test/resources/dmaap-listener.preferredRoute.txt -sdnc.odl.user=admin -sdnc.odl.password=admin -sdnc.odl.url-base=http://localhost:8181/restconf/operations \ No newline at end of file +sdnc.odl.user=${ODL_USER} +sdnc.odl.password=${ODL_PASSWORD} +sdnc.odl.url-base=http://localhost:8181/restconf/operations diff --git a/northbound/lcm/provider/pom.xml b/northbound/lcm/provider/pom.xml index bd6f762d0..57c75fe7c 100755 --- a/northbound/lcm/provider/pom.xml +++ b/northbound/lcm/provider/pom.xml @@ -89,4 +89,31 @@ test + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + dummyUser + dummyPassword + dummyDatabase + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + dummyUser + dummyPassword + dummyDatabase + + + + + diff --git a/northbound/lcm/provider/src/test/java/org/onap/ccsdk/sli/northbound/TestLcmProvider.java b/northbound/lcm/provider/src/test/java/org/onap/ccsdk/sli/northbound/TestLcmProvider.java index 85325cb56..09cf97cc4 100644 --- a/northbound/lcm/provider/src/test/java/org/onap/ccsdk/sli/northbound/TestLcmProvider.java +++ b/northbound/lcm/provider/src/test/java/org/onap/ccsdk/sli/northbound/TestLcmProvider.java @@ -20,6 +20,7 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; import org.onap.ccsdk.sli.core.sli.provider.SvcLogicClassResolver; import org.onap.ccsdk.sli.core.sli.provider.SvcLogicPropertiesProviderImpl; import org.onap.ccsdk.sli.core.sli.provider.SvcLogicServiceImpl; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.mdsal.dom.api.DOMDataBroker; @@ -134,7 +135,7 @@ public class TestLcmProvider { // Load svclogic.properties and get a SvcLogicStore InputStream propStr = TestLcmProvider.class.getResourceAsStream("/svclogic.properties"); - Properties svcprops = new Properties(); + Properties svcprops = new EnvProperties(); svcprops.load(propStr); SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(svcprops); diff --git a/northbound/lcm/provider/src/test/resources/svclogic.properties b/northbound/lcm/provider/src/test/resources/svclogic.properties index 426960f76..85818d7b6 100644 --- a/northbound/lcm/provider/src/test/resources/svclogic.properties +++ b/northbound/lcm/provider/src/test/resources/svclogic.properties @@ -20,8 +20,8 @@ ### org.onap.ccsdk.sli.dbtype = jdbc -org.onap.ccsdk.sli.jdbc.url=jdbc:derby:memory:sdnctl;create=true +org.onap.ccsdk.sli.jdbc.url=jdbc:derby:memory:${MYSQL_DATABASE};create=true org.onap.ccsdk.sli.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver -org.onap.ccsdk.sli.jdbc.database = sdnctl -org.onap.ccsdk.sli.jdbc.user = test -org.onap.ccsdk.sli.jdbc.password = test +org.onap.ccsdk.sli.jdbc.database = ${MYSQL_DATABASE} +org.onap.ccsdk.sli.jdbc.user = ${MYSQL_USER} +org.onap.ccsdk.sli.jdbc.password = ${MYSQL_PASSWORD} diff --git a/northbound/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebConfiguration.java b/northbound/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebConfiguration.java index 0088a14a8..4efc29b77 100644 --- a/northbound/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebConfiguration.java +++ b/northbound/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebConfiguration.java @@ -30,6 +30,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Properties; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.onap.sdc.api.consumer.IConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -119,7 +120,7 @@ public class SdncUebConfiguration implements IConfiguration{ + propFile); } - Properties props = new Properties(); + Properties props = new EnvProperties(); props.load(new FileInputStream(propFile)); asdcAddress = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.asdc-address"); diff --git a/northbound/ueb-listener/src/test/resources/ueb-listener.properties b/northbound/ueb-listener/src/test/resources/ueb-listener.properties index c017cbd7b..9cce1a7ba 100755 --- a/northbound/ueb-listener/src/test/resources/ueb-listener.properties +++ b/northbound/ueb-listener/src/test/resources/ueb-listener.properties @@ -2,10 +2,10 @@ org.onap.ccsdk.sli.northbound.uebclient.asdc-address=localhost:1234 org.onap.ccsdk.sli.northbound.uebclient.consumer-group=ccsdk1 org.onap.ccsdk.sli.northbound.uebclient.consumer-id=localhost_ccsdk1 org.onap.ccsdk.sli.northbound.uebclient.environment-name=UNITTEST -org.onap.ccsdk.sli.northbound.uebclient.password=123456 -org.onap.ccsdk.sli.northbound.uebclient.user=test -org.onap.ccsdk.sli.northbound.uebclient.sdnc-user=test -org.onap.ccsdk.sli.northbound.uebclient.sdnc-passwd=test +org.onap.ccsdk.sli.northbound.uebclient.password=${ASDC_PASSWORD} +org.onap.ccsdk.sli.northbound.uebclient.user=${ASDC_USER} +org.onap.ccsdk.sli.northbound.uebclient.sdnc-user=${ODL_USER} +org.onap.ccsdk.sli.northbound.uebclient.sdnc-passwd=${ODL_PASSWORD} org.onap.ccsdk.sli.northbound.uebclient.asdc-api-base-url=http://localhost:8282/restconf/operations/ org.onap.ccsdk.sli.northbound.uebclient.asdc-api-namespace=org:onap:ccsdk org.onap.ccsdk.sli.northbound.uebclient.spool.incoming=src/test/resources/incoming diff --git a/plugins/grToolkit/provider/pom.xml b/plugins/grToolkit/provider/pom.xml index 5c77331c0..b44436697 100755 --- a/plugins/grToolkit/provider/pom.xml +++ b/plugins/grToolkit/provider/pom.xml @@ -118,6 +118,26 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + + admin + admin + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + admin + admin + + + diff --git a/plugins/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java b/plugins/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java index 5a8730bff..8da2f09ae 100755 --- a/plugins/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java +++ b/plugins/grToolkit/provider/src/main/java/org/onap/ccsdk/sli/plugins/grtoolkit/GrToolkitProvider.java @@ -45,6 +45,7 @@ import org.apache.commons.lang.StringUtils; import org.json.JSONArray; import org.json.JSONObject; import org.onap.ccsdk.sli.core.dblib.DbLibService; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.onap.ccsdk.sli.plugins.grtoolkit.connection.ConnectionManager; import org.onap.ccsdk.sli.plugins.grtoolkit.connection.ConnectionResponse; import org.onap.ccsdk.sli.plugins.grtoolkit.data.AdminHealth; @@ -183,7 +184,7 @@ public class GrToolkitProvider implements AutoCloseable, GrToolkitService, DataT */ private void setProperties() { log.info("Loading properties from {}", PROPERTIES_FILE); - properties = new Properties(); + properties = new EnvProperties(); File propertiesFile = new File(PROPERTIES_FILE); if(!propertiesFile.exists()) { log.warn("setProperties(): Properties file not found."); diff --git a/plugins/grToolkit/provider/src/main/resources/gr-toolkit.properties b/plugins/grToolkit/provider/src/main/resources/gr-toolkit.properties index e3463df08..bce40620e 100755 --- a/plugins/grToolkit/provider/src/main/resources/gr-toolkit.properties +++ b/plugins/grToolkit/provider/src/main/resources/gr-toolkit.properties @@ -24,7 +24,7 @@ adm.fqdn= adm.healthcheck=/healthcheck adm.port.http=8181 adm.port.ssl=8443 -controller.credentials=admin:admin +controller.credentials=${ODL_USER}:${ODL_PASSWORD} controller.useSsl=true controller.port.http=8181 controller.port.ssl=8443 diff --git a/plugins/grToolkit/provider/src/test/resources/gr-toolkit.properties b/plugins/grToolkit/provider/src/test/resources/gr-toolkit.properties index 52b19bf51..d3b15e70e 100755 --- a/plugins/grToolkit/provider/src/test/resources/gr-toolkit.properties +++ b/plugins/grToolkit/provider/src/test/resources/gr-toolkit.properties @@ -24,7 +24,7 @@ adm.fqdn=localhost adm.healthcheck=/adm/healthcheck adm.port.http=9999 adm.port.ssl=19999 -controller.credentials=admin:admin +controller.credentials=${ODL_USER}:${ODL_PASSWORD} controller.useSsl=false controller.port.http=9999 controller.port.ssl=19999 diff --git a/plugins/grToolkit/provider/src/test/resources/single/gr-toolkit.properties b/plugins/grToolkit/provider/src/test/resources/single/gr-toolkit.properties index cc7820e90..040f082df 100755 --- a/plugins/grToolkit/provider/src/test/resources/single/gr-toolkit.properties +++ b/plugins/grToolkit/provider/src/test/resources/single/gr-toolkit.properties @@ -23,7 +23,7 @@ adm.fqdn=localhost adm.healthcheck=/adm/healthcheck adm.port.http=9999 adm.port.ssl=19999 -controller.credentials=admin:admin +controller.credentials=${ODL_USER}:${ODL_PASSWORD} controller.useSsl=false controller.port.http=9999 controller.port.ssl=19999 diff --git a/plugins/grToolkit/provider/src/test/resources/six/gr-toolkit.properties b/plugins/grToolkit/provider/src/test/resources/six/gr-toolkit.properties index 54c9af742..f078634d3 100755 --- a/plugins/grToolkit/provider/src/test/resources/six/gr-toolkit.properties +++ b/plugins/grToolkit/provider/src/test/resources/six/gr-toolkit.properties @@ -23,7 +23,7 @@ adm.fqdn=localhost adm.healthcheck=/adm/healthcheck adm.port.http=9999 adm.port.ssl=19999 -controller.credentials=admin:admin +controller.credentials=${ODL_USER}:${ODK_PASSWORD} controller.useSsl=false controller.port.http=9999 controller.port.ssl=19999 diff --git a/plugins/grToolkit/provider/src/test/resources/three/gr-toolkit.properties b/plugins/grToolkit/provider/src/test/resources/three/gr-toolkit.properties index cc7820e90..040f082df 100755 --- a/plugins/grToolkit/provider/src/test/resources/three/gr-toolkit.properties +++ b/plugins/grToolkit/provider/src/test/resources/three/gr-toolkit.properties @@ -23,7 +23,7 @@ adm.fqdn=localhost adm.healthcheck=/adm/healthcheck adm.port.http=9999 adm.port.ssl=19999 -controller.credentials=admin:admin +controller.credentials=${ODL_USER}:${ODL_PASSWORD} controller.useSsl=false controller.port.http=9999 controller.port.ssl=19999 diff --git a/plugins/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java b/plugins/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java index b4bc84747..d5bf4d1dc 100644 --- a/plugins/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java +++ b/plugins/properties-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/prop/PropertiesNode.java @@ -32,6 +32,7 @@ import java.util.Set; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,7 +42,7 @@ public class PropertiesNode implements SvcLogicJavaPlugin { public void readProperties(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { Parameters param = getParameters(paramMap); - Properties prop = new Properties(); + Properties prop = new EnvProperties(); try { File file = new File(param.fileName); try (InputStream in = new FileInputStream(file)) { @@ -63,14 +64,14 @@ public class PropertiesNode implements SvcLogicJavaPlugin { String name = (String) key; String value = prop.getProperty(name); if (value != null && value.trim().length() > 0) { - ctx.setAttribute(pfx + name, getObfuscatedVal(value.trim())); + ctx.setAttribute(pfx + name, EnvProperties.resolveValue(value.trim())); log.info("+++ " + pfx + name + ": [" + maskPassword(pfx + name, value) + "]"); } } } if (mm != null) { for (Map.Entry entry : mm.entrySet()) { - ctx.setAttribute(pfx + entry.getKey(), getObfuscatedVal(entry.getValue())); + ctx.setAttribute(pfx + entry.getKey(), EnvProperties.resolveValue(entry.getValue())); log.info("+++ " + pfx + entry.getKey() + ": [" + maskPassword(pfx + entry.getKey(), entry.getValue()) + "]"); } @@ -81,7 +82,7 @@ public class PropertiesNode implements SvcLogicJavaPlugin { String name = (String) key; String value = prop.getProperty(name); if (value != null && value.trim().length() > 0) { - ctx.setAttribute(pfx + name, getObfuscatedVal(value.trim())); + ctx.setAttribute(pfx + name, EnvProperties.resolveValue(value.trim())); log.info("+++ " + pfx + name + ": [" + maskPassword(pfx + name, value) + "]"); } } @@ -92,7 +93,8 @@ public class PropertiesNode implements SvcLogicJavaPlugin { } } - /* Unobfuscate param value */ + /* Unobfuscate param value + * No longer needed - use EnvProperties.resolveValue instead private static String getObfuscatedVal(String paramValue) { String resValue = paramValue; if (paramValue != null && paramValue.startsWith("${") && paramValue.endsWith("}")) @@ -110,6 +112,7 @@ public class PropertiesNode implements SvcLogicJavaPlugin { } return resValue; } + */ /* * Getting extension has to do the following "" --> "" "name" --> "" "name.txt" --> "txt" diff --git a/plugins/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/plugins/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java index 3d7042493..e42dfa484 100755 --- a/plugins/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java +++ b/plugins/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java @@ -81,6 +81,7 @@ import org.glassfish.jersey.media.multipart.file.FileDataBodyPart; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.onap.logging.filter.base.HttpURLConnectionMetricUtil; import org.onap.logging.filter.base.MetricLogClientFilter; import org.onap.logging.filter.base.ONAPComponents; @@ -129,7 +130,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin { } try (FileInputStream in = new FileInputStream(configDir + "/" + UEB_PROPERTIES_FILE_NAME)) { - Properties props = new Properties(); + Properties props = new EnvProperties(); props.load(in); uebServers = props.getProperty("servers"); log.info("UEB support enabled"); -- cgit 1.2.3-korg