Fix multiple minor security vulnerabilities
[osm/LCM.git] / osm_lcm / tests / test_lcm_helm_conn.py
index 3730162..b4af5a3 100644 (file)
@@ -23,6 +23,7 @@ from osm_lcm.lcm_helm_conn import LCMHelmConn
 from asynctest.mock import Mock
 from osm_lcm.data_utils.database.database import Database
 from osm_lcm.data_utils.filesystem.filesystem import Filesystem
+from osm_lcm.data_utils.lcm_config import VcaConfig
 
 __author__ = "Isabel Lloret <illoret@indra.es>"
 
@@ -54,9 +55,8 @@ class TestLcmHelmConn(asynctest.TestCase):
         lcm_helm_conn.K8sHelm3Connector = asynctest.Mock(
             lcm_helm_conn.K8sHelm3Connector
         )
-        self.helm_conn = LCMHelmConn(
-            loop=self.loop, vca_config=vca_config, log=self.logger
-        )
+        vca_config = VcaConfig(vca_config)
+        self.helm_conn = LCMHelmConn(vca_config=vca_config, log=self.logger)
 
     @asynctest.fail_on(active_handles=True)
     async def test_create_execution_environment(self):
@@ -87,14 +87,14 @@ class TestLcmHelmConn(asynctest.TestCase):
         )
         self.assertEqual(
             ee_id,
-            "{}:{}.{}".format("helm-v3", "osm", helm_chart_id),
-            "Check ee_id format: <helm-version>:<default namespace>.<helm_chart-id>",
+            "{}:{}.{}".format("helm-v3", namespace, helm_chart_id),
+            "Check ee_id format: <helm-version>:<NS ID>.<helm_chart-id>",
         )
         self.helm_conn._k8sclusterhelm3.install.assert_called_once_with(
             "myk8s_id",
             kdu_model="/helm_sample_charm",
             kdu_instance=helm_chart_id,
-            namespace="osm",
+            namespace=namespace,
             db_dict=db_dict,
             params=None,
             timeout=None,
@@ -104,7 +104,6 @@ class TestLcmHelmConn(asynctest.TestCase):
     async def test_get_ee_ssh_public__key(self):
         ee_id = "osm.helm_sample_charm_0001"
         db_dict = {}
-        lcm_helm_conn.socket.gethostbyname = asynctest.Mock()
         mock_pub_key = "ssh-rsapubkey"
         self.db.get_one.return_value = {"_admin": {"helm-chart": {"id": "myk8s_id"}}}
         self.helm_conn._get_ssh_key = asynctest.CoroutineMock(return_value=mock_pub_key)
@@ -115,7 +114,6 @@ class TestLcmHelmConn(asynctest.TestCase):
 
     @asynctest.fail_on(active_handles=True)
     async def test_execute_primitive(self):
-        lcm_helm_conn.socket.gethostbyname = asynctest.Mock()
         ee_id = "osm.helm_sample_charm_0001"
         primitive_name = "sleep"
         params = {}
@@ -129,7 +127,6 @@ class TestLcmHelmConn(asynctest.TestCase):
     @asynctest.fail_on(active_handles=True)
     async def test_execute_config_primitive(self):
         self.logger.debug("Execute config primitive")
-        lcm_helm_conn.socket.gethostbyname = asynctest.Mock()
         ee_id = "osm.helm_sample_charm_0001"
         primitive_name = "config"
         params = {"ssh-host-name": "host1"}