- del test_vnfd["df"][0]["lcm-operations-configuration"][
- "operate-vnf-op-config"
- ]["day1-2"][0]["execution-environment-list"][0]["juju"]
- with self.subTest(i=6, t="Check Input Validation: mgmt-cp"):
- tmp = test_vnfd["mgmt-cp"]
- del test_vnfd["mgmt-cp"]
- try:
- with self.assertRaises(
- EngineException, msg="Accepted VNFD without management interface"
- ) 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(
- "'{}' is a mandatory field and it is not defined".format(
- "mgmt-cp"
- )
- ),
- norm(str(e.exception)),
- "Wrong exception text",
- )
- finally:
- test_vnfd["mgmt-cp"] = tmp
- with self.subTest(i=7, t="Check Input Validation: mgmt-cp connection point"):
- tmp = test_vnfd["mgmt-cp"]
- test_vnfd["mgmt-cp"] = "wrong-cp"
- try:
- with self.assertRaises(
- EngineException, msg="Accepted wrong mgmt-cp connection point"
- ) 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(
- "mgmt-cp='{}' must match an existing ext-cpd".format(
- test_vnfd["mgmt-cp"]
- )
- ),
- norm(str(e.exception)),
- "Wrong exception text",
- )
- finally:
- test_vnfd["mgmt-cp"] = tmp
- with self.subTest(i=8, t="Check Input Validation: vdu int-cpd"):
- ext_cpd = test_vnfd["ext-cpd"][1]
- tmp = ext_cpd["int-cpd"]["cpd"]
- ext_cpd["int-cpd"]["cpd"] = "wrong-cpd"
- try:
- with self.assertRaises(
- EngineException,
- msg="Accepted wrong ext-cpd internal connection point",
- ) 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(
- "ext-cpd[id='{}']:int-cpd must match an existing vdu int-cpd".format(
- ext_cpd["id"]
- )
- ),
- norm(str(e.exception)),
- "Wrong exception text",
- )
- finally:
- ext_cpd["int-cpd"]["cpd"] = tmp
- with self.subTest(i=9, t="Check Input Validation: Duplicated VLD"):
- test_vnfd["int-virtual-link-desc"].insert(0, {"id": "internal"})
- try:
- with self.assertRaises(
- EngineException, msg="Accepted duplicated VLD name"
- ) 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(
- "identifier id '{}' is not unique".format(
- test_vnfd["int-virtual-link-desc"][0]["id"]
- )
- ),
- norm(str(e.exception)),
- "Wrong exception text",
- )
- finally:
- del test_vnfd["int-virtual-link-desc"][0]
- with self.subTest(i=10, t="Check Input Validation: vdu int-virtual-link-desc"):
- vdu = test_vnfd["vdu"][0]
- int_cpd = vdu["int-cpd"][1]
- tmp = int_cpd["int-virtual-link-desc"]
- int_cpd["int-virtual-link-desc"] = "non-existing-int-virtual-link-desc"
- try:
- with self.assertRaises(
- EngineException, msg="Accepted int-virtual-link-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[id='{}']:int-cpd[id='{}']:int-virtual-link-desc='{}' must match an existing "
- "int-virtual-link-desc".format(
- vdu["id"], int_cpd["id"], int_cpd["int-virtual-link-desc"]
- )
- ),
- norm(str(e.exception)),
- "Wrong exception text",
- )
- finally:
- int_cpd["int-virtual-link-desc"] = tmp
- with self.subTest(i=11, t="Check Input Validation: virtual-link-profile)"):
- fake_ivld_profile = {"id": "fake-profile-ref", "flavour": "fake-flavour"}
- df = test_vnfd["df"][0]
- df["virtual-link-profile"] = [fake_ivld_profile]
- try:
- with self.assertRaises(
- EngineException, msg="Accepted non-existent Profile Ref"
- ) 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='{}']:virtual-link-profile='{}' must match an existing "
- "int-virtual-link-desc".format(
- df["id"], fake_ivld_profile["id"]
- )
- ),
- norm(str(e.exception)),
- "Wrong exception text",
- )
- finally:
- del df["virtual-link-profile"]
- with self.subTest(
- i=12, t="Check Input Validation: scaling-criteria monitoring-param-ref"
- ):
- vdu = test_vnfd["vdu"][1]
- affected_df = test_vnfd["df"][0]
- sa = affected_df["scaling-aspect"][0]
- sp = sa["scaling-policy"][0]
- sc = sp["scaling-criteria"][0]
- tmp = vdu.pop("monitoring-parameter")
- try:
- with self.assertRaises(
- EngineException,
- msg="Accepted non-existent Scaling 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",