Use of yaml.safe_load instead of yaml.load 24/12424/2
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Tue, 2 Aug 2022 15:19:14 +0000 (17:19 +0200)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Tue, 16 Aug 2022 15:53:21 +0000 (17:53 +0200)
Change-Id: Ic508f205abfd0b71362d3f124b0ec2c4d8f0a17c
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
osm_lcm/tests/test_ns.py

index d7192c9..1441e72 100644 (file)
@@ -122,19 +122,19 @@ class TestMyNS(asynctest.TestCase):
         print("kwargs > {}".format(kwargs))
         if args:
             if "update" in args:
-                ro_ns_desc = yaml.load(
-                    descriptors.ro_update_action_text, Loader=yaml.Loader
+                ro_ns_desc = yaml.safe_load(
+                    descriptors.ro_update_action_text
                 )
                 while True:
                     yield ro_ns_desc
         if kwargs.get("delete"):
-            ro_ns_desc = yaml.load(
-                descriptors.ro_delete_action_text, Loader=yaml.Loader
+            ro_ns_desc = yaml.safe_load(
+                descriptors.ro_delete_action_text
             )
             while True:
                 yield ro_ns_desc
 
-        ro_ns_desc = yaml.load(descriptors.ro_ns_text, Loader=yaml.Loader)
+        ro_ns_desc = yaml.safe_load(descriptors.ro_ns_text)
 
         # if ip address provided, replace descriptor
         ip_addresses = getenv("OSMLCMTEST_NS_IPADDRESS", "")
@@ -177,34 +177,34 @@ class TestMyNS(asynctest.TestCase):
 
             self.db = Database({"database": {"driver": "memory"}}).instance.db
             self.db.create_list(
-                "vnfds", yaml.load(descriptors.db_vnfds_text, Loader=yaml.Loader)
+                "vnfds", yaml.safe_load(descriptors.db_vnfds_text)
             )
             self.db.create_list(
                 "vnfds_revisions",
-                yaml.load(descriptors.db_vnfds_revisions_text, Loader=yaml.Loader),
+                yaml.safe_load(descriptors.db_vnfds_revisions_text),
             )
             self.db.create_list(
-                "nsds", yaml.load(descriptors.db_nsds_text, Loader=yaml.Loader)
+                "nsds", yaml.safe_load(descriptors.db_nsds_text)
             )
             self.db.create_list(
-                "nsrs", yaml.load(descriptors.db_nsrs_text, Loader=yaml.Loader)
+                "nsrs", yaml.safe_load(descriptors.db_nsrs_text)
             )
             self.db.create_list(
                 "vim_accounts",
-                yaml.load(descriptors.db_vim_accounts_text, Loader=yaml.Loader),
+                yaml.safe_load(descriptors.db_vim_accounts_text),
             )
             self.db.create_list(
                 "k8sclusters",
-                yaml.load(descriptors.db_k8sclusters_text, Loader=yaml.Loader),
+                yaml.safe_load(descriptors.db_k8sclusters_text),
             )
             self.db.create_list(
-                "nslcmops", yaml.load(descriptors.db_nslcmops_text, Loader=yaml.Loader)
+                "nslcmops", yaml.safe_load(descriptors.db_nslcmops_text)
             )
             self.db.create_list(
-                "vnfrs", yaml.load(descriptors.db_vnfrs_text, Loader=yaml.Loader)
+                "vnfrs", yaml.safe_load(descriptors.db_vnfrs_text)
             )
-            self.db_vim_accounts = yaml.load(
-                descriptors.db_vim_accounts_text, Loader=yaml.Loader
+            self.db_vim_accounts = yaml.safe_load(
+                descriptors.db_vim_accounts_text
             )
 
         # Mock kafka