+ @patch("osm_nbi.descriptor_topics.shutil")
+ @patch("osm_nbi.descriptor_topics.os.rename")
+ def test_new_vnfd_check_input_validation_healing_criteria_vdu_id(
+ self, mock_rename, mock_shutil
+ ):
+ """Testing input validation during new vnfd creation
+ for healing criteria with invalid vdu-id"""
+ did, test_vnfd = self.prepare_vnfd_creation()
+ test_vnfd = self.prepare_test_vnfd(test_vnfd)
+ test_vnfd["df"][0]["healing-aspect"][0]["healing-policy"][0][
+ "vdu-id"
+ ] = "vduid1"
+ affected_df = test_vnfd["df"][0]
+ ha = affected_df["healing-aspect"][0]
+ hp = ha["healing-policy"][0]
+ hp_vdu_id = hp["vdu-id"]
+
+ with self.assertRaises(
+ EngineException, msg="Accepted invalid Healing Group Policy Criteria"
+ ) as e:
+ self.topic.upload_content(
+ fake_session, did, test_vnfd, {}, {"Content-Type": []}
+ )
+ self.assertEqual(
+ e.exception.http_code,
+ HTTPStatus.UNPROCESSABLE_ENTITY,
+ "Wrong HTTP status code",
+ )
+ self.assertIn(
+ norm(
+ "df[id='{}']:healing-aspect[id='{}']:healing-policy"
+ "[name='{}']: "
+ "vdu-id='{}' not defined in vdu".format(
+ affected_df["id"],
+ ha["id"],
+ hp["event-name"],
+ hp_vdu_id,
+ )
+ ),
+ norm(str(e.exception)),
+ "Wrong exception text",
+ )
+
+ @patch("osm_nbi.descriptor_topics.shutil")
+ @patch("osm_nbi.descriptor_topics.os.rename")
+ def test_new_vnfd_check_input_validation_alarm_criteria_monitoring_param_ref(
+ self, mock_rename, mock_shutil
+ ):
+ """Testing input validation during new vnfd creation
+ for alarm with invalid monitoring parameter reference"""
+ did, test_vnfd = self.prepare_vnfd_creation()
+ test_vnfd = self.prepare_test_vnfd(test_vnfd)
+ test_vnfd["vdu"][1]["alarm"][0]["vnf-monitoring-param-ref"] = "unit_test_alarm"
+ vdu = test_vnfd["vdu"][1]
+ alarm = vdu["alarm"][0]
+ alarm_monitoring_param = alarm["vnf-monitoring-param-ref"]
+
+ with self.assertRaises(
+ EngineException, msg="Accepted invalid Alarm Criteria"
+ ) as e:
+ self.topic.upload_content(
+ fake_session, did, test_vnfd, {}, {"Content-Type": []}
+ )
+ self.assertEqual(
+ e.exception.http_code,
+ HTTPStatus.UNPROCESSABLE_ENTITY,
+ "Wrong HTTP status code",
+ )
+ self.assertIn(
+ norm(
+ "vdu[id='{}']:alarm[id='{}']:"
+ "vnf-monitoring-param-ref='{}' not defined in any monitoring-param".format(
+ vdu["id"],
+ alarm["alarm-id"],
+ alarm_monitoring_param,
+ )
+ ),
+ norm(str(e.exception)),
+ "Wrong exception text",
+ )
+
+ @patch("osm_nbi.descriptor_topics.shutil")
+ @patch("osm_nbi.descriptor_topics.os.rename")
+ def test_new_vnfd_check_input_validation_storage_reference_criteria(
+ self, mock_rename, mock_shutil
+ ):
+ """Testing input validation during new vnfd creation
+ for invalid virtual-storge-desc reference"""
+ did, test_vnfd = self.prepare_vnfd_creation()
+ test_vnfd = self.prepare_test_vnfd(test_vnfd)
+ test_vnfd["vdu"][1]["virtual-storage-desc"] = "unit_test_storage"
+ vdu = test_vnfd["vdu"][1]
+ vsd_ref = vdu["virtual-storage-desc"]
+
+ with self.assertRaises(
+ EngineException, msg="Accepted invalid virtual-storage-desc"
+ ) as e:
+ self.topic.upload_content(
+ fake_session, did, test_vnfd, {}, {"Content-Type": []}
+ )
+ self.assertEqual(
+ e.exception.http_code,
+ HTTPStatus.UNPROCESSABLE_ENTITY,
+ "Wrong HTTP status code",
+ )
+ self.assertIn(
+ norm(
+ "vdu[virtual-storage-desc='{}']"
+ "not defined in vnfd".format(
+ vsd_ref,
+ )
+ ),
+ norm(str(e.exception)),
+ "Wrong exception text",
+ )
+
+ @patch("osm_nbi.descriptor_topics.shutil")
+ @patch("osm_nbi.descriptor_topics.os.rename")
+ def test_new_vnfd_check_input_validation_compute_reference_criteria(
+ self, mock_rename, mock_shutil
+ ):
+ """Testing input validation during new vnfd creation
+ for invalid virtual-compute-desc reference"""
+ did, test_vnfd = self.prepare_vnfd_creation()
+ test_vnfd = self.prepare_test_vnfd(test_vnfd)
+ test_vnfd["vdu"][1]["virtual-compute-desc"] = "unit_test_compute"
+ vdu = test_vnfd["vdu"][1]
+ vcd_ref = vdu["virtual-compute-desc"]
+
+ with self.assertRaises(
+ EngineException, msg="Accepted invalid virtual-compute-desc"
+ ) as e:
+ self.topic.upload_content(
+ fake_session, did, test_vnfd, {}, {"Content-Type": []}
+ )
+ self.assertEqual(
+ e.exception.http_code,
+ HTTPStatus.UNPROCESSABLE_ENTITY,
+ "Wrong HTTP status code",
+ )
+ self.assertIn(
+ norm(
+ "vdu[virtual-compute-desc='{}']"
+ "not defined in vnfd".format(
+ vcd_ref,
+ )
+ ),
+ norm(str(e.exception)),
+ "Wrong exception text",
+ )
+