Update CSIT with opa-pdp for testcases, Cleanup,Added predeployment 74/140574/2
authorMurali Parthasarathy K <muraliparthasarathy.k@techmahindra.com>
Tue, 25 Mar 2025 06:49:09 +0000 (07:49 +0100)
committerMurali Parthasarathy K <muraliparthasarathy.k@techmahindra.com>
Tue, 25 Mar 2025 15:57:03 +0000 (16:57 +0100)
Issue-ID: POLICY-5225
Change-Id: I54459edce6ed9a2da491e2041901b8cec194c4f5
Signed-off-by: Murali Parthasarathy K <muraliparthasarathy.k@techmahindra.com>
41 files changed:
compose/compose.yaml
compose/config/api/apiParameters.yaml
compose/config/api/groups.json
compose/config/opa-pdp/data/abac/data.json [deleted file]
compose/config/opa-pdp/data/account/data.json [deleted file]
compose/config/opa-pdp/data/action/data.json [deleted file]
compose/config/opa-pdp/data/blacklist/data.json [new file with mode: 0644]
compose/config/opa-pdp/data/cell/consistency/data.json [new file with mode: 0644]
compose/config/opa-pdp/data/monitor/data.json [new file with mode: 0644]
compose/config/opa-pdp/data/organization/data.json [deleted file]
compose/config/opa-pdp/groups.json [deleted file]
compose/config/opa-pdp/policies/abac/policy.rego [deleted file]
compose/config/opa-pdp/policies/access_method/policy.rego [moved from compose/config/opa-pdp/policies/example/policy.rego with 89% similarity]
compose/config/opa-pdp/policies/account/policy.rego [deleted file]
compose/config/opa-pdp/policies/action/policy.rego [deleted file]
compose/config/opa-pdp/policies/blacklist/policy.rego [new file with mode: 0644]
compose/config/opa-pdp/policies/cell/consistency/policy.rego [new file with mode: 0644]
compose/config/opa-pdp/policies/cell/consistency/topology/policy.rego [new file with mode: 0644]
compose/config/opa-pdp/policies/data/abac/data.json [deleted file]
compose/config/opa-pdp/policies/data/account/data.json [deleted file]
compose/config/opa-pdp/policies/data/action/data.json [deleted file]
compose/config/opa-pdp/policies/data/organization/data.json [deleted file]
compose/config/opa-pdp/policies/data/role/data.json [deleted file]
compose/config/opa-pdp/policies/monitor/policy.rego [new file with mode: 0644]
compose/config/opa-pdp/policies/organization/policy.rego [deleted file]
compose/config/pap/groups.json
compose/get-versions.sh
csit/resources/tests/api-test.robot
csit/resources/tests/common-library.robot
csit/resources/tests/data/onap.policy.opa.pdp.data-empty.json
csit/resources/tests/data/onap.policy.opa.pdp.decision.zone-incorrect-policyfilter.json
csit/resources/tests/data/onap.policy.opa.pdp.decision.zone-incorrect-policyname.json
csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.abac-incorrect-policyfilter.json
csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.abac-incorrect-policyname.json
csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.abac-pemit-policy.json
csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.vehicle-incorect-policyfilter.json
csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.vehicle-incorect-policyname.json
csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.vehicle_input.json
csit/resources/tests/data/onap.policy.policy.opa.pdp.decision.zone-policy-input.json
csit/resources/tests/pap-test.robot
csit/run-project-csit.sh

index 9059e63..c7a2e79 100644 (file)
@@ -77,6 +77,7 @@ services:
       - simulator
       - kafka
       - pap
+      - opa-pdp
     ports:
       - ${APEX_PORT}:6969
       - ${APEX_EVENTS_PORT}:23324
index 6d92a29..4b0b20f 100644 (file)
@@ -71,6 +71,7 @@ policy-preload:
   - policytypes/onap.policies.controlloop.operational.common.Drools.yaml
   - policytypes/onap.policies.native.opa.yaml
   policies:
+  - policies/opa.policy.slice.capacity.check.tosca.yaml
   - policies/sdnc.policy.naming.input.tosca.yaml
 
 management:
index 6ee30e1..5bbc0a7 100644 (file)
           "currentInstanceCount": 0,
           "desiredInstanceCount": 1,
           "policies": []
+        },
+       {
+      "name": "opaGroup",
+      "pdpGroupState": "ACTIVE",
+      "properties": {},
+      "pdpSubgroups": [
+        {
+          "pdpType": "opa",
+          "desiredInstanceCount": 1,
+          "properties": {},
+          "supportedPolicyTypes": [
+            {
+              "name": "onap.policies.native.opa",
+              "version": "1.0.0"
+            }
+          ],
+          "policies": [
+            {
+              "name": "slice.capacity.check",
+              "version": "1.0.0"
+            }
+          ]
         }
       ]
     }
+      ]
+    }
   ]
 }
diff --git a/compose/config/opa-pdp/data/abac/data.json b/compose/config/opa-pdp/data/abac/data.json
deleted file mode 100644 (file)
index 77b5668..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-{
-    "sensor_data": [
-        {
-            "id": "0001",
-            "location": "Sri Lanka",
-            "temperature": "28 C",
-            "precipitation": "1000 mm",
-            "windspeed": "5.5 m/s",
-            "humidity": "40%",
-            "particle_density": "1.3 g/l",
-            "timestamp": "2024-02-26"
-        },
-        {
-            "id": "0002",
-            "location": "Colombo",
-            "temperature": "30 C",
-            "precipitation": "1200 mm",
-            "windspeed": "6.0 m/s",
-            "humidity": "45%",
-            "particle_density": "1.5 g/l",
-            "timestamp": "2024-02-26"
-        },
-        {
-            "id": "0003",
-            "location": "Kandy",
-            "temperature": "25 C",
-            "precipitation": "800 mm",
-            "windspeed": "4.5 m/s",
-            "humidity": "60%",
-            "particle_density": "1.1 g/l",
-            "timestamp": "2024-02-26"
-        },
-        {
-            "id": "0004",
-            "location": "Galle",
-            "temperature": "35 C",
-            "precipitation": "500 mm",
-            "windspeed": "7.2 m/s",
-            "humidity": "30%",
-            "particle_density": "1.8 g/l",
-            "timestamp": "2024-02-27"
-        },
-        {
-            "id": "0005",
-            "location": "Jaffna",
-            "temperature": "-5 C",
-            "precipitation": "300 mm",
-            "windspeed": "3.8 m/s",
-            "humidity": "20%",
-            "particle_density": "0.9 g/l",
-            "timestamp": "2024-02-27"
-        },
-        {
-            "id": "0006",
-            "location": "Trincomalee",
-            "temperature": "20 C",
-            "precipitation": "1000 mm",
-            "windspeed": "5.0 m/s",
-            "humidity": "55%",
-            "particle_density": "1.2 g/l",
-            "timestamp": "2024-02-28"
-        },
-        {
-            "id": "0007",
-            "location": "Nuwara Eliya",
-            "temperature": "25 C",
-            "precipitation": "600 mm",
-            "windspeed": "4.0 m/s",
-            "humidity": "50%",
-            "particle_density": "1.3 g/l",
-            "timestamp": "2024-02-28"
-        },
-        {
-            "id": "0008",
-            "location": "Anuradhapura",
-            "temperature": "28 C",
-            "precipitation": "700 mm",
-            "windspeed": "5.8 m/s",
-            "humidity": "40%",
-            "particle_density": "1.4 g/l",
-            "timestamp": "2024-02-29"
-        },
-        {
-            "id": "0009",
-            "location": "Matara",
-            "temperature": "32 C",
-            "precipitation": "900 mm",
-            "windspeed": "6.5 m/s",
-            "humidity": "65%",
-            "particle_density": "1.6 g/l",
-            "timestamp": "2024-02-29"
-        }
-    ]
-}
diff --git a/compose/config/opa-pdp/data/account/data.json b/compose/config/opa-pdp/data/account/data.json
deleted file mode 100644 (file)
index df263d3..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-{
-  "account_attributes":{
-    "11111":{
-      "owner":"alice",
-      "amount":10000
-    },
-    "22222":{
-      "owner":"bob",
-      "amount":10000
-    },
-    "33333":{
-      "owner":"cam",
-      "amount":10000
-    }
-  }
-}
diff --git a/compose/config/opa-pdp/data/action/data.json b/compose/config/opa-pdp/data/action/data.json
deleted file mode 100644 (file)
index 99145b7..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-{
-    "user_roles": {
-        "alice": [
-            "admin"
-        ],
-        "bob": [
-            "editor"
-        ],
-        "charlie": [
-            "viewer"
-        ]
-    },
-    "role_permissions": {
-        "admin": {
-            "actions": [
-                "read",
-                "write",
-                "delete"
-            ],
-            "resources": [
-                "server",
-                "database"
-            ]
-        },
-        "editor": {
-            "actions": [
-                "read",
-                "write"
-            ],
-            "resources": [
-                "server"
-            ]
-        },
-        "viewer": {
-            "actions": [
-                "read"
-            ],
-            "resources": [
-                "server"
-            ]
-        }
-    }
-}
diff --git a/compose/config/opa-pdp/data/blacklist/data.json b/compose/config/opa-pdp/data/blacklist/data.json
new file mode 100644 (file)
index 0000000..9fd6233
--- /dev/null
@@ -0,0 +1,6 @@
+{
+    "blacklist" : [
+    "the-vfmodule-where-root-is-true",
+     "another-vfmodule-where-root-is-true"
+]
+}
diff --git a/compose/config/opa-pdp/data/cell/consistency/data.json b/compose/config/opa-pdp/data/cell/consistency/data.json
new file mode 100644 (file)
index 0000000..1f823a1
--- /dev/null
@@ -0,0 +1,5 @@
+{
+  "allowedCellId" : 445611193265040129,
+  "minPCI": 1,
+  "maxPCI": 3000
+}
diff --git a/compose/config/opa-pdp/data/monitor/data.json b/compose/config/opa-pdp/data/monitor/data.json
new file mode 100644 (file)
index 0000000..f28f73c
--- /dev/null
@@ -0,0 +1,13 @@
+{ "domain": "measurementsForVfScaling",
+  "metricsPerEventName": [{
+          "eventName": "Measurement_vGMUX",
+          "controlLoopSchemaType": "VNF",
+          "policyScope": "DCAE",
+          "policyName": "DCAE.Config_tca-hi-lo",
+           "policyVersion": "v0.0.1",
+           "thresholds" : [{"version": "1.0.2",
+            "closedLoopControlName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e",
+            "thresholdValue": 0
+             }]
+}]
+}
diff --git a/compose/config/opa-pdp/data/organization/data.json b/compose/config/opa-pdp/data/organization/data.json
deleted file mode 100644 (file)
index 35fe4a1..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-{
-    "acls": [
-        {
-            "user": "alice",
-            "actions": [
-                "edit",
-                "read"
-            ],
-            "component": "component_A",
-            "project": "project_A",
-            "organization": "org_A"
-        },
-        {
-            "user": "bob",
-            "actions": ["read"],
-            "organization": "org_A"
-        },
-        {
-            "user": "bob",
-            "action": ["edit"],
-            "component": "component_A",
-            "project": "project_B",
-            "organization": "org_A"
-        },
-        {
-            "user": "charlie",
-            "action": ["read"],
-            "project": "project_B",
-            "organization": "org_A"
-        }
-    ]
-}
diff --git a/compose/config/opa-pdp/groups.json b/compose/config/opa-pdp/groups.json
deleted file mode 100644 (file)
index ef4ee5f..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-{
-  "groups": [
-    {
-      "name": "opaGroup",
-      "version": "1.0.0",
-      "description": "The default group that registers all supported policy types and pdps.",
-      "pdpGroupState": "ACTIVE",
-      "pdpSubgroups": [
-        {
-          "pdpType": "opa",
-          "desiredInstanceCount": 1,
-          "properties": {},
-          "supportedPolicyTypes": [
-            {
-              "name": "onap.policies.native.opa",
-              "version": "1.0.0"
-            }
-          ],
-          "policies": []
-        }
-      ]
-    }
-  ]
-}
diff --git a/compose/config/opa-pdp/policies/abac/policy.rego b/compose/config/opa-pdp/policies/abac/policy.rego
deleted file mode 100644 (file)
index 9dc6ea9..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-package abac
-
-import rego.v1
-
-default allow := false
-
-allow if {
- viewable_sensor_data
- action_is_read
-}
-
-action_is_read if "read" in input.actions
-
-viewable_sensor_data contains view_data if {
- some sensor_data in data.abac.sensor_data
- sensor_data.timestamp >= input.time_period.from
- sensor_data.timestamp < input.time_period.to
-
- view_data := {datatype: sensor_data[datatype] | datatype in input.datatypes}
-}
diff --git a/compose/config/opa-pdp/policies/account/policy.rego b/compose/config/opa-pdp/policies/account/policy.rego
deleted file mode 100644 (file)
index f99e8eb..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-package account
-
-import rego.v1
-
-default allow := false
-
-allow if {
- creditor_is_valid
- debtor_is_valid
- period_is_valid
- amount_is_valid
-}
-creditor_is_valid if data.account.account_attributes[input.creditor_account].owner == input.creditor
-debtor_is_valid if data.account.account_attributes[input.debtor_account].owner == input.debtor
-
-period_is_valid if input.period <= 30
-amount_is_valid if data.account.account_attributes[input.debtor_account].amount >= input.amount
diff --git a/compose/config/opa-pdp/policies/action/policy.rego b/compose/config/opa-pdp/policies/action/policy.rego
deleted file mode 100644 (file)
index 300fe50..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-package action
-
-import rego.v1
-
-# By default, deny requests.
-default allow := false
-
-
-# Allow the action if admin role is granted permission to perform the action.
-allow if {
-    some i
-    data.action.user_roles[input.user][i] == role
-    some j
-    data.action.role_permissions[role].actions[j] == input.action
-    some k
-    data.action.role_permissions[role].resources[k] == input.type
-}
-#       * Rego comparison to other systems: https://www.openpolicyagent.org/docs/latest/comparison-to-other-systems/
-#       * Rego Iteration: https://www.openpolicyagent.org/docs/latest/#iteration
-
-
diff --git a/compose/config/opa-pdp/policies/blacklist/policy.rego b/compose/config/opa-pdp/policies/blacklist/policy.rego
new file mode 100644 (file)
index 0000000..b285593
--- /dev/null
@@ -0,0 +1,18 @@
+package blacklist
+import future.keywords.in
+import rego.v1
+
+# Define a rule to check if the operation should be allowed
+module_allow[module] := false if {
+    some module in input.vfmodule
+    not validate(module)
+}
+
+module_allow[module] := true if{
+        some module in input.vfmodule
+    validate(module)
+}
+
+validate(module) if {
+        module in data.node.blacklist.blacklist
+}
diff --git a/compose/config/opa-pdp/policies/cell/consistency/policy.rego b/compose/config/opa-pdp/policies/cell/consistency/policy.rego
new file mode 100644 (file)
index 0000000..6137df7
--- /dev/null
@@ -0,0 +1,17 @@
+package cell.consistency
+import rego.v1
+default allow = false
+# Rule to check cell consistency
+check_cell_consistency if {
+    input.cell != data.node.cell.consistency.allowedCellId
+}
+# Rule to allow if PCI is within range 1-3000
+allow_if_pci_in_range  if {
+    input.PCI >= data.node.cellconsistency.minPCI
+    input.PCI <= data.node.cellconsistency.maxPCI
+}
+# Main rule to determine the final decision
+allow  if{
+    check_cell_consistency
+    allow_if_pci_in_range
+}
diff --git a/compose/config/opa-pdp/policies/cell/consistency/topology/policy.rego b/compose/config/opa-pdp/policies/cell/consistency/topology/policy.rego
new file mode 100644 (file)
index 0000000..dccfac6
--- /dev/null
@@ -0,0 +1,6 @@
+package cell.consistency.topology
+import rego.v1
+# Rule to check cell consistency
+check_cell_consistency if {
+    input.cell != data.node.cell.consistency.allowedCellId
+}
diff --git a/compose/config/opa-pdp/policies/data/abac/data.json b/compose/config/opa-pdp/policies/data/abac/data.json
deleted file mode 100644 (file)
index 77b5668..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-{
-    "sensor_data": [
-        {
-            "id": "0001",
-            "location": "Sri Lanka",
-            "temperature": "28 C",
-            "precipitation": "1000 mm",
-            "windspeed": "5.5 m/s",
-            "humidity": "40%",
-            "particle_density": "1.3 g/l",
-            "timestamp": "2024-02-26"
-        },
-        {
-            "id": "0002",
-            "location": "Colombo",
-            "temperature": "30 C",
-            "precipitation": "1200 mm",
-            "windspeed": "6.0 m/s",
-            "humidity": "45%",
-            "particle_density": "1.5 g/l",
-            "timestamp": "2024-02-26"
-        },
-        {
-            "id": "0003",
-            "location": "Kandy",
-            "temperature": "25 C",
-            "precipitation": "800 mm",
-            "windspeed": "4.5 m/s",
-            "humidity": "60%",
-            "particle_density": "1.1 g/l",
-            "timestamp": "2024-02-26"
-        },
-        {
-            "id": "0004",
-            "location": "Galle",
-            "temperature": "35 C",
-            "precipitation": "500 mm",
-            "windspeed": "7.2 m/s",
-            "humidity": "30%",
-            "particle_density": "1.8 g/l",
-            "timestamp": "2024-02-27"
-        },
-        {
-            "id": "0005",
-            "location": "Jaffna",
-            "temperature": "-5 C",
-            "precipitation": "300 mm",
-            "windspeed": "3.8 m/s",
-            "humidity": "20%",
-            "particle_density": "0.9 g/l",
-            "timestamp": "2024-02-27"
-        },
-        {
-            "id": "0006",
-            "location": "Trincomalee",
-            "temperature": "20 C",
-            "precipitation": "1000 mm",
-            "windspeed": "5.0 m/s",
-            "humidity": "55%",
-            "particle_density": "1.2 g/l",
-            "timestamp": "2024-02-28"
-        },
-        {
-            "id": "0007",
-            "location": "Nuwara Eliya",
-            "temperature": "25 C",
-            "precipitation": "600 mm",
-            "windspeed": "4.0 m/s",
-            "humidity": "50%",
-            "particle_density": "1.3 g/l",
-            "timestamp": "2024-02-28"
-        },
-        {
-            "id": "0008",
-            "location": "Anuradhapura",
-            "temperature": "28 C",
-            "precipitation": "700 mm",
-            "windspeed": "5.8 m/s",
-            "humidity": "40%",
-            "particle_density": "1.4 g/l",
-            "timestamp": "2024-02-29"
-        },
-        {
-            "id": "0009",
-            "location": "Matara",
-            "temperature": "32 C",
-            "precipitation": "900 mm",
-            "windspeed": "6.5 m/s",
-            "humidity": "65%",
-            "particle_density": "1.6 g/l",
-            "timestamp": "2024-02-29"
-        }
-    ]
-}
diff --git a/compose/config/opa-pdp/policies/data/account/data.json b/compose/config/opa-pdp/policies/data/account/data.json
deleted file mode 100644 (file)
index df263d3..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-{
-  "account_attributes":{
-    "11111":{
-      "owner":"alice",
-      "amount":10000
-    },
-    "22222":{
-      "owner":"bob",
-      "amount":10000
-    },
-    "33333":{
-      "owner":"cam",
-      "amount":10000
-    }
-  }
-}
diff --git a/compose/config/opa-pdp/policies/data/action/data.json b/compose/config/opa-pdp/policies/data/action/data.json
deleted file mode 100644 (file)
index 99145b7..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-{
-    "user_roles": {
-        "alice": [
-            "admin"
-        ],
-        "bob": [
-            "editor"
-        ],
-        "charlie": [
-            "viewer"
-        ]
-    },
-    "role_permissions": {
-        "admin": {
-            "actions": [
-                "read",
-                "write",
-                "delete"
-            ],
-            "resources": [
-                "server",
-                "database"
-            ]
-        },
-        "editor": {
-            "actions": [
-                "read",
-                "write"
-            ],
-            "resources": [
-                "server"
-            ]
-        },
-        "viewer": {
-            "actions": [
-                "read"
-            ],
-            "resources": [
-                "server"
-            ]
-        }
-    }
-}
diff --git a/compose/config/opa-pdp/policies/data/organization/data.json b/compose/config/opa-pdp/policies/data/organization/data.json
deleted file mode 100644 (file)
index 35fe4a1..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-{
-    "acls": [
-        {
-            "user": "alice",
-            "actions": [
-                "edit",
-                "read"
-            ],
-            "component": "component_A",
-            "project": "project_A",
-            "organization": "org_A"
-        },
-        {
-            "user": "bob",
-            "actions": ["read"],
-            "organization": "org_A"
-        },
-        {
-            "user": "bob",
-            "action": ["edit"],
-            "component": "component_A",
-            "project": "project_B",
-            "organization": "org_A"
-        },
-        {
-            "user": "charlie",
-            "action": ["read"],
-            "project": "project_B",
-            "organization": "org_A"
-        }
-    ]
-}
diff --git a/compose/config/opa-pdp/policies/data/role/data.json b/compose/config/opa-pdp/policies/data/role/data.json
deleted file mode 100644 (file)
index 88ac41b..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-{
-    "user_roles": {
-        "alice": [
-            "admin"
-        ],
-        "bob": [
-            "employee",
-            "billing"
-        ],
-        "eve": [
-            "customer"
-        ]
-    },
-    "role_grants": {
-        "customer": [
-            {
-                "action": "read",
-                "type": "dog"
-            },
-            {
-                "action": "read",
-                "type": "cat"
-            },
-            {
-                "action": "adopt",
-                "type": "dog"
-            },
-            {
-                "action": "adopt",
-                "type": "cat"
-            }
-        ],
-        "employee": [
-            {
-                "action": "read",
-                "type": "dog"
-            },
-            {
-                "action": "read",
-                "type": "cat"
-            },
-            {
-                "action": "update",
-                "type": "dog"
-            },
-            {
-                "action": "update",
-                "type": "cat"
-            }
-        ],
-        "billing": [
-            {
-                "action": "read",
-                "type": "finance"
-            },
-            {
-                "action": "update",
-                "type": "finance"
-            }
-        ]
-    }
-}
-
diff --git a/compose/config/opa-pdp/policies/monitor/policy.rego b/compose/config/opa-pdp/policies/monitor/policy.rego
new file mode 100644 (file)
index 0000000..b3d9aaa
--- /dev/null
@@ -0,0 +1,39 @@
+package monitor
+
+# Policy allows if a matching threshold is met
+result contains output if {
+    input.domain = data.node.monitor.domain
+    some events  in data.node.monitor.metricsPerEventName
+    events.eventName == input.eventName
+    events.controlLoopSchemaType == input.controlLoopSchemaType
+    events.policyScope == input.policyScope
+    events.policyName == input.policyName
+    events.policyVersion == input.policyVersion
+    some value in events.thresholds
+    input.controlname == value.closedLoopControlName
+    input.version == value.version
+    input.thresholdValue == value.thresholdValue
+    output := {
+        "severity" : "MAJOR",
+        "closedLoopEventStatus" : "ABATED"
+        }
+}
+
+# Policy allows if a matching threshold is met
+result contains output if {
+    input.domain = data.node.monitor.domain
+    some events  in data.node.monitor.metricsPerEventName
+    events.eventName == input.eventName
+    events.controlLoopSchemaType == input.controlLoopSchemaType
+    events.policyScope == input.policyScope
+    events.policyName == input.policyName
+    events.policyVersion == input.policyVersion
+    some value in events.thresholds
+    input.controlname == value.closedLoopControlName
+    input.version == value.version
+    input.thresholdValue > value.thresholdValue
+    output := {
+        "severity" : "CRITICAL",
+        "closedLoopEventStatus" : "ONSET"
+        }
+}
diff --git a/compose/config/opa-pdp/policies/organization/policy.rego b/compose/config/opa-pdp/policies/organization/policy.rego
deleted file mode 100644 (file)
index 31e7fb6..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-package organization
-
-import rego.v1
-
-default allow := false
-
-# organization level access
-allow if {
- some acl in data.organization.acls
- acl.user == input.user
- acl.organization == input.organization
- acl.project == input.project
- acl.component == input.component
-
- some action in acl.actions
- action == input.action
-}
-
-# project level access
-allow if {
- some acl in data.organization.acls
- acl.user == input.user
- acl.organization == input.organization
- acl.project == input.project
-
- some action in acl.actions
- action == input.action
-}
-
-# component level access
-allow if {
- some acl in data.organization.acls
- acl.user == input.user
- acl.organization == input.organization
-
- some action in acl.actions
- action == input.action
-}
index bd5c286..e9a9e9a 100644 (file)
           "policies": []
         }
       ]
+    },
+    {
+      "name": "opaGroup",
+      "pdpGroupState": "ACTIVE",
+      "properties": {},
+      "pdpSubgroups": [
+        {
+          "pdpType": "opa",
+          "desiredInstanceCount": 1,
+          "properties": {},
+          "supportedPolicyTypes": [
+            {
+              "name": "onap.policies.native.opa",
+              "version": "1.0.0"
+            }
+          ],
+          "policies": [
+            {
+              "name": "slice.capacity.check",
+              "version": "1.0.0"
+            }
+          ]
+        }
+      ]
     }
   ]
 }
index 2de4e7f..cb8b83a 100755 (executable)
@@ -142,7 +142,8 @@ else
     getDockerVersion xacml-pdp
     export POLICY_XACML_PDP_VERSION="$docker_image_version"
 
-    export POLICY_OPA_PDP_VERSION="1.0.2-SNAPSHOT"
+    getDockerVersion opa-pdp
+    export POLICY_OPA_PDP_VERSION="$docker_image_version"
 
     getDockerVersion distribution
     export POLICY_DISTRIBUTION_VERSION="$docker_image_version"
index e1b8fd4..a6130db 100644 (file)
@@ -60,7 +60,7 @@ RetrievePoliciesOfType
 
 RetrieveAllPolicies
     [Documentation]  Retrieve all policies
-    FetchPolicies  /policy/api/v1/policies  3
+    FetchPolicies  /policy/api/v1/policies  4
 
 RetrieveSpecificPolicy
     [Documentation]    Retrieve a policy named 'onap.restart.tca' and version '1.0.0' using generic api
index 89a9c72..12939a7 100644 (file)
@@ -102,7 +102,7 @@ CreateNodeTemplate
 
 QueryPdpGroups
     [Documentation]    Verify pdp group query - suphosts upto 2 groups
-    [Arguments]  ${groupsLength}  ${group1Name}  ${group1State}  ${policiesLengthInGroup1}  ${group2Name}  ${group2State}  ${policiesLengthInGroup2}
+    [Arguments]  ${groupsLength}  ${group1Name}  ${group1State}  ${policiesLengthInGroup1}  ${group2Name}  ${group2State}  ${policiesLengthInGroup2}  ${group3Name}  ${group3State}  ${policiesLengthInGroup3}
     ${policyadmin}=  PolicyAdminAuth
     ${resp}=  PerformGetRequest  ${POLICY_PAP_IP}  /policy/pap/v1/pdps  200  null  ${policyadmin}
     Length Should Be  ${resp.json()['groups']}  ${groupsLength}
@@ -112,6 +112,9 @@ QueryPdpGroups
     Run Keyword If  ${groupsLength}>1  Should Be Equal As Strings  ${resp.json()['groups'][1]['name']}  ${group2Name}
     Run Keyword If  ${groupsLength}>1  Should Be Equal As Strings  ${resp.json()['groups'][1]['pdpGroupState']}  ${group2State}
     Run Keyword If  ${groupsLength}>1  Length Should Be  ${resp.json()['groups'][1]['pdpSubgroups'][0]['policies']}  ${policiesLengthInGroup2}
+    Run Keyword If  ${groupsLength}>2  Should Be Equal As Strings  ${resp.json()['groups'][2]['name']}  ${group3Name}
+    Run Keyword If  ${groupsLength}>2  Should Be Equal As Strings  ${resp.json()['groups'][2]['pdpGroupState']}  ${group3State}
+    Run Keyword If  ${groupsLength}>2  Length Should Be  ${resp.json()['groups'][2]['pdpSubgroups'][0]['policies']}  ${policiesLengthInGroup3}
 
 QueryPolicyAudit
     [Arguments]  ${url}  ${expectedstatus}  ${pdpGroup}  ${pdpType}  ${policyName}  ${expectedAction}
index 432476a..cd74b41 100644 (file)
@@ -1,5 +1,14 @@
 {
   "data": {
+    "node": {
+      "slice": {
+        "capacity": {
+          "check": {
+            "threshold": 70
+          }
+        }
+      }
+    },
     "system": {
       "version": {
         "build_commit": "",
index 1c7f8b8..ab124b6 100644 (file)
@@ -2,13 +2,24 @@
   "onapName": "CDS",
   "onapComponent": "CDS",
   "onapInstance": "CDS",
-  "currentDate": "2024-11-22",
+  "currentDate": "2025-01-17",
+  "currentTime": "08:26:41.857Z",
+  "timeZone": "UTC",
+  "timeOffset": "+05:30",
+  "currentDateTime": "2025-01-17T08:26:41.857Z",
   "policyName": "zoneB",
-  "policyFilter": ["has_ze_access"],
+  "policyFilter": [
+    "has_ze_access"
+  ],
   "input": {
-    "actions": ["view"],
+    "actions": [
+      "view"
+    ],
     "log_id": "log1",
-    "datatypes": ["access", "user"],
+    "datatypes": [
+      "access",
+      "user"
+    ],
     "time_period": {
       "from": "2024-11-01T09:00:00Z",
       "to": "2024-11-01T10:00:00Z"
@@ -16,4 +27,3 @@
     "zone_id": "zoneA"
   }
 }
-
index dfa088b..199b10d 100644 (file)
@@ -2,13 +2,24 @@
   "onapName": "CDS",
   "onapComponent": "CDS",
   "onapInstance": "CDS",
-  "currentDate": "2024-11-22",
+  "currentDate": "2025-01-17",
+  "currentTime": "08:26:41.857Z",
+  "timeZone": "UTC",
+  "timeOffset": "+05:30",
+  "currentDateTime": "2025-01-17T08:26:41.857Z",
   "policyName": "zoeB",
-  "policyFilter": ["has_zone_access"],
+  "policyFilter": [
+    "has_zone_access"
+  ],
   "input": {
-    "actions": ["view"],
+    "actions": [
+      "view"
+    ],
     "log_id": "log1",
-    "datatypes": ["access", "user"],
+    "datatypes": [
+      "access",
+      "user"
+    ],
     "time_period": {
       "from": "2024-11-01T09:00:00Z",
       "to": "2024-11-01T10:00:00Z"
@@ -16,4 +27,3 @@
     "zone_id": "zoneA"
   }
 }
-
index 223dddb..80b49f8 100644 (file)
@@ -2,12 +2,25 @@
   "onapName": "CDS",
   "onapComponent": "CDS",
   "onapInstance": "CDS",
-  "currentDate": "2024-11-22",
+  "currentDate": "2025-01-17",
+  "currentTime": "08:26:41.857Z",
+  "timeZone": "UTC",
+  "timeOffset": "+05:30",
+  "currentDateTime": "2025-01-17T08:26:41.857Z",
   "policyName": "abac",
-  "policyFilter": ["viewable_sesor_data"],
+  "policyFilter": [
+    "viewable_sesor_data"
+  ],
   "input": {
-    "actions": ["read"],
-    "datatypes": ["location", "temperature", "precipitation", "windspeed"],
+    "actions": [
+      "read"
+    ],
+    "datatypes": [
+      "location",
+      "temperature",
+      "precipitation",
+      "windspeed"
+    ],
     "time_period": {
       "from": "2024-02-27",
       "to": "2024-02-29"
index a1628bb..095f3d6 100644 (file)
@@ -2,12 +2,25 @@
   "onapName": "CDS",
   "onapComponent": "CDS",
   "onapInstance": "CDS",
-  "currentDate": "2024-11-22",
+  "currentDate": "2025-01-17",
+  "currentTime": "08:26:41.857Z",
+  "timeZone": "UTC",
+  "timeOffset": "+05:30",
+  "currentDateTime": "2025-01-17T08:26:41.857Z",
   "policyName": "abc",
-  "policyFilter": ["viewable_sensor_data"],
+  "policyFilter": [
+    "viewable_sensor_data"
+  ],
   "input": {
-    "actions": ["read"],
-    "datatypes": ["location", "temperature", "precipitation", "windspeed"],
+    "actions": [
+      "read"
+    ],
+    "datatypes": [
+      "location",
+      "temperature",
+      "precipitation",
+      "windspeed"
+    ],
     "time_period": {
       "from": "2024-02-27",
       "to": "2024-02-29"
index fadf05b..9471eec 100644 (file)
@@ -1,16 +1,29 @@
 {
-    "onapName": "CDS",
-    "onapComponent": "CDS",
-    "onapInstance": "CDS",
-    "currentDate": "2024-11-22",
-    "policyName": "abac",
-    "policyFilter": ["viewable_sensor_data"],
-    "input": {
-        "actions": ["read"],
-        "datatypes": ["location", "temperature", "precipitation", "windspeed"],
-        "time_period": {
-            "from": "2024-02-27",
-            "to": "2024-02-29"
-        }
+  "onapName": "CDS",
+  "onapComponent": "CDS",
+  "onapInstance": "CDS",
+  "currentDate": "2025-01-17",
+  "currentTime": "08:26:41.857Z",
+  "timeZone": "UTC",
+  "timeOffset": "+05:30",
+  "currentDateTime": "2025-01-17T08:26:41.857Z",
+  "policyName": "abac",
+  "policyFilter": [
+    "viewable_sensor_data"
+  ],
+  "input": {
+    "actions": [
+      "read"
+    ],
+    "datatypes": [
+      "location",
+      "temperature",
+      "precipitation",
+      "windspeed"
+    ],
+    "time_period": {
+      "from": "2024-02-27",
+      "to": "2024-02-29"
     }
+  }
 }
index 290fd60..a3efb3c 100644 (file)
@@ -2,14 +2,24 @@
   "onapName": "CDS",
   "onapComponent": "CDS",
   "onapInstance": "CDS",
-  "currentDate": "2024-11-22",
+  "currentDate": "2025-01-17",
+  "currentTime": "08:26:41.857Z",
+  "timeZone": "UTC",
+  "timeOffset": "+05:30",
+  "currentDateTime": "2025-01-17T08:26:41.857Z",
   "policyName": "vehicle",
-  "policyFilter": ["user_has_vecle_access"],
+  "policyFilter": [
+    "user_has_vecle_access"
+  ],
   "input": {
-    "actions": ["use"],
+    "actions": [
+      "use"
+    ],
     "user": "user1",
     "vehicle_id": "v1",
-    "attributes": ["type", "status"]
+    "attributes": [
+      "type",
+      "status"
+    ]
   }
 }
-
index b5f50b6..aaa8f41 100644 (file)
@@ -2,14 +2,24 @@
   "onapName": "CDS",
   "onapComponent": "CDS",
   "onapInstance": "CDS",
-  "currentDate": "2024-11-22",
+  "currentDate": "2025-01-17",
+  "currentTime": "08:26:41.857Z",
+  "timeZone": "UTC",
+  "timeOffset": "+05:30",
+  "currentDateTime": "2025-01-17T08:26:41.857Z",
   "policyName": "vehile",
-  "policyFilter": ["user_has_vehicle_access"],
+  "policyFilter": [
+    "user_has_vehicle_access"
+  ],
   "input": {
-    "actions": ["use"],
+    "actions": [
+      "use"
+    ],
     "user": "user1",
     "vehicle_id": "v1",
-    "attributes": ["type", "status"]
+    "attributes": [
+      "type",
+      "status"
+    ]
   }
 }
-
index 4ea1638..999a76e 100644 (file)
@@ -2,13 +2,24 @@
   "onapName": "CDS",
   "onapComponent": "CDS",
   "onapInstance": "CDS",
-  "currentDate": "2024-11-22",
+  "currentDate": "2025-01-17",
+  "currentTime": "08:26:41.857Z",
+  "timeZone": "UTC",
+  "timeOffset": "+05:30",
+  "currentDateTime": "2025-01-17T08:26:41.857Z",
   "policyName": "vehicle",
-  "policyFilter": ["user_has_vehicle_access"],
+  "policyFilter": [
+    "user_has_vehicle_access"
+  ],
   "input": {
-    "actions": ["use"],
+    "actions": [
+      "use"
+    ],
     "user": "user1",
     "vehicle_id": "v1",
-    "attributes": ["type", "status"]
+    "attributes": [
+      "type",
+      "status"
+    ]
   }
 }
index 0dca9cd..13618ed 100644 (file)
@@ -2,13 +2,24 @@
   "onapName": "CDS",
   "onapComponent": "CDS",
   "onapInstance": "CDS",
-  "currentDate": "2024-11-22",
+  "currentDate": "2025-01-17",
+  "currentTime": "08:26:41.857Z",
+  "timeZone": "UTC",
+  "timeOffset": "+05:30",
+  "currentDateTime": "2025-01-17T08:26:41.857Z",
   "policyName": "zoneB",
-  "policyFilter": ["has_zone_access"],
+  "policyFilter": [
+    "has_zone_access"
+  ],
   "input": {
-    "actions": ["view"],
+    "actions": [
+      "view"
+    ],
     "log_id": "log1",
-    "datatypes": ["access", "user"],
+    "datatypes": [
+      "access",
+      "user"
+    ],
     "time_period": {
       "from": "2024-11-01T09:00:00Z",
       "to": "2024-11-01T10:00:00Z"
index e66820c..7021a14 100644 (file)
@@ -38,7 +38,7 @@ Healthcheck
 
 Consolidated Healthcheck
     [Documentation]  Verify policy consolidated health check
-    sleep  20
+    sleep  60
     ${resp}=  GetReq  /policy/pap/v1/components/healthcheck
     Should Be Equal As Strings  ${resp.json()['healthy']}  True
 
@@ -48,7 +48,7 @@ Metrics
     ${resp}=  GetMetrics  ${POLICY_PAP_IP}  ${auth}  /policy/pap/v1/
     Should Contain  ${resp.text}  http_server_requests_seconds_count{error="none",exception="none",method="GET",outcome="SUCCESS",status="200",uri="/healthcheck"}
     Should Contain  ${resp.text}  http_server_requests_seconds_count{error="none",exception="none",method="GET",outcome="SUCCESS",status="200",uri="/components/healthcheck"} 1
-    Should Contain  ${resp.text}  spring_data_repository_invocations_seconds_count{exception="None",method="save",repository="PdpGroupRepository",state="SUCCESS"} 1
+    Should Contain  ${resp.text}  spring_data_repository_invocations_seconds_count{exception="None",method="save",repository="PdpGroupRepository",state="SUCCESS"} 2
     Should Contain  ${resp.text}  spring_data_repository_invocations_seconds_count{exception="None",method="findByKeyName",repository="PdpGroupRepository",state="SUCCESS"} 1
     Should Contain  ${resp.text}  spring_data_repository_invocations_seconds_count{exception="None",method="findAll",repository="PolicyStatusRepository",state="SUCCESS"}
 
@@ -60,7 +60,7 @@ AddPdpGroup
 
 QueryPdpGroupsBeforeActivation
     [Documentation]  Verify PdpGroups before activation
-    QueryPdpGroups  2  defaultGroup  ACTIVE  0  testGroup  PASSIVE  0
+    QueryPdpGroups  3  defaultGroup  ACTIVE  0  opaGroup   ACTIVE   1   testGroup  PASSIVE  0
 
 ActivatePdpGroup
     [Documentation]  Change the state of PdpGroup named 'testGroup' to ACTIVE
@@ -69,7 +69,7 @@ ActivatePdpGroup
 
 QueryPdpGroupsAfterActivation
     [Documentation]  Verify PdpGroups after activation
-    QueryPdpGroups  2  defaultGroup  ACTIVE  0  testGroup  ACTIVE  0
+    QueryPdpGroups  3  defaultGroup  ACTIVE  0  opaGroup   ACTIVE   1   testGroup  ACTIVE  0
 
 DeployPdpGroups
     [Documentation]  Deploy policies in PdpGroups
@@ -79,7 +79,7 @@ DeployPdpGroups
 
 QueryPdpGroupsAfterDeploy
     [Documentation]  Verify PdpGroups after undeploy
-    QueryPdpGroups  2  defaultGroup  ACTIVE  0  testGroup  ACTIVE  1
+    QueryPdpGroups  3  defaultGroup  ACTIVE  0  opaGroup   ACTIVE   1   testGroup  ACTIVE  1
 
 QueryPolicyAuditAfterDeploy
     [Documentation]  Verify policy audit record after deploy
@@ -101,7 +101,7 @@ UndeployPolicyWithMetadataSet
 
 QueryPdpGroupsAfterUndeploy
     [Documentation]  Verify PdpGroups after undeploy
-    QueryPdpGroups  2  defaultGroup  ACTIVE  0  testGroup  ACTIVE  0
+    QueryPdpGroups  3  defaultGroup  ACTIVE  0  opaGroup   ACTIVE   1   testGroup  ACTIVE  0
 
 QueryPolicyAuditAfterUnDeploy
     [Documentation]   Verify policy audit record after undeploy
@@ -123,4 +123,4 @@ DeletePdpGroups
 
 QueryPdpGroupsAfterDelete
     [Documentation]    Verify PdpGroups after delete
-    QueryPdpGroups  1  defaultGroup  ACTIVE  0  null  null  null
+    QueryPdpGroups  2  defaultGroup  ACTIVE  0  opaGroup   ACTIVE   1   null   null   null
index ad3f41c..f5bb890 100755 (executable)
@@ -128,11 +128,13 @@ function setup_api() {
 
 function setup_pap() {
     export ROBOT_FILES="pap-test.robot pap-slas.robot"
+    export PROJECT="pap"
     source "${DOCKER_COMPOSE_DIR}"/start-compose.sh apex-pdp --grafana
     echo "Waiting 1 minute for policy-pap to start..."
     sleep 60
     check_rest_endpoint "${PAP_PORT}"
     check_rest_endpoint "${APEX_PORT}"
+    check_rest_endpoint "${OPA_PDP_PORT}"
     apex_healthcheck
 }