diff options
-rw-r--r-- | INFO.yaml | 16 | ||||
-rwxr-xr-x | components/pm-subscription-handler/pmsh_service/mod/pmsh_utils.py | 5 | ||||
-rw-r--r-- | components/pm-subscription-handler/pmsh_service/mod/sub_schema.json | 11 | ||||
-rw-r--r-- | components/pm-subscription-handler/tests/test_pmsh_utils.py | 38 |
4 files changed, 61 insertions, 9 deletions
@@ -51,6 +51,16 @@ committers: company: 'Nokia' id: 'rjanecze' timezone: 'Europe/Warsaw' + - name: 'Joanna Jeremicz' + email: 'joanna.jeremicz@nokia.com' + company: 'Nokia' + id: 'joannajeremicz' + timezone: 'Europe/Warsaw' + - name: 'Tomasz Wróbel' + email: 'tomasz.wrobel@nokia.com' + company: 'Nokia' + id: 'twrobel' + timezone: 'Europe/Warsaw' tsc: approval: 'https://lists.onap.org/pipermail/onap-tsc' changes: @@ -96,3 +106,9 @@ tsc: - type: 'Removal' name: 'Joseph O Leary' link: 'https://lists.onap.org/g/onap-tsc/message/7419' + - type: 'Addition' + name: 'Tomasz Wróbel' + link: 'https://lists.onap.org/g/onap-tsc/message/7583' + - type: 'Addition' + name: 'Joanna Jeremicz' + link: 'https://lists.onap.org/g/onap-tsc/message/7583' diff --git a/components/pm-subscription-handler/pmsh_service/mod/pmsh_utils.py b/components/pm-subscription-handler/pmsh_service/mod/pmsh_utils.py index 7b91a307..a5fc86e6 100755 --- a/components/pm-subscription-handler/pmsh_service/mod/pmsh_utils.py +++ b/components/pm-subscription-handler/pmsh_service/mod/pmsh_utils.py @@ -128,10 +128,7 @@ class AppConfig: sub_data = self.subscription.__dict__ validate(instance=sub_data, schema=self.sub_schema) nf_filter = sub_data["nfFilter"] - for filter_name in nf_filter: - if len(nf_filter[filter_name]) > 0: - break - else: + if not [filter_name for filter_name, val in nf_filter.items() if len(val) > 0]: raise ValidationError("At least one filter within nfFilter must not be empty") logger.debug("Subscription schema is valid.") diff --git a/components/pm-subscription-handler/pmsh_service/mod/sub_schema.json b/components/pm-subscription-handler/pmsh_service/mod/sub_schema.json index 7a1da5bb..18d48174 100644 --- a/components/pm-subscription-handler/pmsh_service/mod/sub_schema.json +++ b/components/pm-subscription-handler/pmsh_service/mod/sub_schema.json @@ -51,11 +51,12 @@ } } }, - "required":[ - "nfNames", - "modelInvariantIDs", - "modelVersionIDs", - "modelNames" + "additionalProperties": false, + "anyOf": [ + {"required" : ["nfNames"]}, + {"required" : ["modelInvariantIDs"]}, + {"required" : ["modelVersionIDs"]}, + {"required" : ["modelNames"]} ] }, "measurementGroups":{ diff --git a/components/pm-subscription-handler/tests/test_pmsh_utils.py b/components/pm-subscription-handler/tests/test_pmsh_utils.py index 1711e013..53d4fe64 100644 --- a/components/pm-subscription-handler/tests/test_pmsh_utils.py +++ b/components/pm-subscription-handler/tests/test_pmsh_utils.py @@ -165,6 +165,44 @@ class PmshUtilsTestCase(BaseClassSetup): with self.assertRaises(ValidationError): self.app_conf.validate_sub_schema() + def test_utils_validate_config_subscription_nfFilter_not_empty(self): + self.app_conf.subscription.nfFilter = { + "nfNames": [ + + ], + "modelInvariantIDs": [ + + ], + "modelVersionIDs": [ + + ], + "modelNames": [ + + ] + } + with self.assertRaises(ValidationError): + self.app_conf.validate_sub_schema() + + @patch('mod.logger.debug') + def test_utils_validate_config_subscription_nfFilter_with_empty_property(self, mock_logger): + self.app_conf.subscription.nfFilter = { + "nfNames": [ + "^pnf.*", + "^vnf.*" + ], + "modelInvariantIDs": [ + "7129e420-d396-4efb-af02-6b83499b12f8" + ], + "modelVersionIDs": [ + + ], + "modelNames": [ + "pnf102" + ] + } + self.app_conf.validate_sub_schema() + mock_logger.assert_called_with("Subscription schema is valid.") + def test_utils_validate_config_subscription_where_measurementTypes_is_empty(self): self.app_conf.subscription.measurementGroups = [{ "measurementGroup": { |