From: saul.gill Date: Mon, 10 Feb 2025 16:43:59 +0000 (+0000) Subject: Add tests for policy schema validation X-Git-Tag: l-release~4 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=8b522d82bbf09aa551fc74d00318e6f7fad3a799;p=nonrtric.git Add tests for policy schema validation Issue-ID: CCSDK-3996 Change-Id: I6ed4e43d834e05d29c92f11c202028b8e8b50c9a Signed-off-by: saul.gill --- diff --git a/test/auto-test/FTC100.sh b/test/auto-test/FTC100.sh index e04489c1..d76b2e74 100755 --- a/test/auto-test/FTC100.sh +++ b/test/auto-test/FTC100.sh @@ -2,7 +2,7 @@ # ============LICENSE_START=============================================== # Copyright (C) 2020-2023 Nordix Foundation. All rights reserved. -# Copyright (C) 2023 OpenInfra Foundation Europe. All rights reserved. +# Modifications Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved. # ======================================================================== # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -498,6 +498,14 @@ for version in $(seq 2 $VERSIONS_TO_RUN); do a1pms_api_post_policy_v3 201 NOSERVICE ricsim_g2_1 NOTYPE 5100 NOTRANSIENT testdata/STD/pi1_template.json a1pms_api_post_policy_v3 201 NOSERVICE ricsim_g3_1 STD_QOS2_0.1.0 5200 NOTRANSIENT testdata/STD2/pi_qos2_template.json + + if [ -n "$A1PMS_VALIDATE_INSTANCE_SCHEMA" ] && [ "$A1PMS_VALIDATE_INSTANCE_SCHEMA" = "true" ]; then + # Test for schema validation at create - should fail + a1pms_api_post_policy_v3 400 NOSERVICE ricsim_g3_1 STD_QOS2_0.1.0 5200 NOTRANSIENT testdata/STD2/pi_qos2_bad_template.json + else + deviation "TR10 - policy create instance schema validation added after oslo, so not tested here - test combo $interface and $__httpx" + fi + fi a1pms_api_put_service 201 "service10" 3600 "$CR_SERVICE_APP_PATH_0/1" @@ -639,6 +647,13 @@ for version in $(seq 2 $VERSIONS_TO_RUN); do a1pms_api_put_policy_v3 200 5200 testdata/STD2/pi_qos2_template.json + if [ -n "$A1PMS_VALIDATE_INSTANCE_SCHEMA" ] && [ "$A1PMS_VALIDATE_INSTANCE_SCHEMA" = "true" ]; then + # Test for schema validation at update - should fail + a1pms_api_put_policy_v3 400 5200 testdata/STD2/pi_qos2_bad_template.json + else + deviation "TR10 - policy update instance schema validation added after oslo, so not tested here - test combo $interface and $__httpx" + fi + if [[ $interface != *"DMAAP"* ]]; then a1pms_api_put_policy_v3 400 2000 testdata/OSC/pi_bad_template.json fi diff --git a/test/auto-test/testdata/STD2/pi_qos2_bad_template.json b/test/auto-test/testdata/STD2/pi_qos2_bad_template.json new file mode 100644 index 00000000..6050f7f0 --- /dev/null +++ b/test/auto-test/testdata/STD2/pi_qos2_bad_template.json @@ -0,0 +1,15 @@ +{ + "scope": { + "qosId": "qosXXX", + "randomField": "bad" + }, + "qosObjectives": { + "priorityLevel": "XXX", + "priorityLev": "XXX", + "qosId": "qosXXX", + "non": "compliant" + }, + "incorrectObject": { + "isCompliant": "no" + } +} \ No newline at end of file diff --git a/test/common/test_env-onap-oslo.sh b/test/common/test_env-onap-oslo.sh index 8a5bdc7f..ef34b680 100644 --- a/test/common/test_env-onap-oslo.sh +++ b/test/common/test_env-onap-oslo.sh @@ -1,7 +1,7 @@ #!/bin/bash # ============LICENSE_START=============================================== -# Copyright (C) 2024 OpenInfra Foundation Europe. All rights reserved. +# Copyright (C) 2024-2025 OpenInfra Foundation Europe. All rights reserved. # ======================================================================== # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -209,6 +209,7 @@ A1PMS_CONTAINER_MNT_DIR="/var/policy-management-service" # Mounted dir in the A1PMS_FEATURE_LEVEL="NO-DMAAP ADAPTER-CLASS" # Space separated list of features A1PMS_ADAPTER_CLASS="" # Class name set by override file A1PMS_ADAPTER_POLICY_NAME="" # Policy name set by override file +A1PMS_VALIDATE_INSTANCE_SCHEMA="true" # Whether or not to perform schema validation on policy instance objects ICS_APP_NAME="informationservice" # Name for ICS container ICS_DISPLAY_NAME="Enrichment Coordinator Service" # Display name for ICS container diff --git a/test/common/test_env-oran-k-release.sh b/test/common/test_env-oran-k-release.sh index 32e9ac12..70382fbb 100644 --- a/test/common/test_env-oran-k-release.sh +++ b/test/common/test_env-oran-k-release.sh @@ -295,6 +295,7 @@ A1PMS_ADAPTER_CLASS="" # Class name set by o A1PMS_ADAPTER_POLICY_TYPE="" # Policy type set by override file A1PMS_NOSDNC_ADAPTER_CLASS="" # Class name set by override file A1PMS_SDNC_ADAPTER_CLASS="" # Class name set by override file +A1PMS_VALIDATE_INSTANCE_SCHEMA="true" # Whether or not to perform schema validation on policy instance objects ICS_APP_NAME="informationservice" # Name for ICS container ICS_DISPLAY_NAME="Information Coordinator Service" # Display name for ICS container diff --git a/test/simulator-group/a1pms/application.yaml b/test/simulator-group/a1pms/application.yaml index 4667a4e0..b37019fa 100644 --- a/test/simulator-group/a1pms/application.yaml +++ b/test/simulator-group/a1pms/application.yaml @@ -1,14 +1,16 @@ ################################################################################ # Copyright (c) 2020 Nordix Foundation. # +# Modifications Copyright (C) 2025 OpenInfra Foundation Europe. # +# All rights reserved. # # # -# Licensed under the Apache License, Version 2.0 (the \"License\"); # +# Licensed under the Apache License, Version 2.0 (the \"License\"); # # you may not use this file except in compliance with the License. # # You may obtain a copy of the License at # # # # http://www.apache.org/licenses/LICENSE-2.0 # # # # Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an \"AS IS\" BASIS, # +# distributed under the License is distributed on an \"AS IS\" BASIS, # # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # # limitations under the License. # @@ -109,4 +111,5 @@ app: http.proxy-host: $A1PMS_HTTP_PROXY_CONFIG_HOST_NAME http.proxy-port: $A1PMS_HTTP_PROXY_CONFIG_PORT http.proxy-type: HTTP + validate-policy-instance-schema: FAIL auth-token-file: $A1PMS_SIDECAR_JWT_FILE \ No newline at end of file