Add tests for policy schema validation 46/14146/2
authorsaul.gill <saul.gill@est.tech>
Mon, 10 Feb 2025 16:43:59 +0000 (16:43 +0000)
committersaul.gill <saul.gill@est.tech>
Wed, 12 Feb 2025 14:55:47 +0000 (14:55 +0000)
Issue-ID: CCSDK-3996
Change-Id: I6ed4e43d834e05d29c92f11c202028b8e8b50c9a
Signed-off-by: saul.gill <saul.gill@est.tech>
test/auto-test/FTC100.sh
test/auto-test/testdata/STD2/pi_qos2_bad_template.json [new file with mode: 0644]
test/common/test_env-onap-oslo.sh
test/common/test_env-oran-k-release.sh
test/simulator-group/a1pms/application.yaml

index e04489c..d76b2e7 100755 (executable)
@@ -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 (file)
index 0000000..6050f7f
--- /dev/null
@@ -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
index 8a5bdc7..ef34b68 100644 (file)
@@ -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
index 32e9ac1..70382fb 100644 (file)
@@ -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
index 4667a4e..b37019f 100644 (file)
@@ -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