aboutsummaryrefslogtreecommitdiffstats
path: root/csit
diff options
context:
space:
mode:
authorsrinivasyanamadala <srinivas.yanamadala@techmahindra.com>2025-02-10 10:21:31 +0100
committerSrinivas Yanamadala <srinivas.yanamadala@techmahindra.com>2025-02-11 14:38:23 +0000
commit726faa724804ee355f24e87daea367d098de9185 (patch)
tree569a7cbf7170991885dd289dc6a908e02498ca11 /csit
parent21a37d5a0b3e7489f888184dc5ef32f2316aef6e (diff)
Updated csit tests for Decision parameter changesHEADmaster
Issue-ID: POLICY-5261 Change-Id: Ib8f5b4295d05cdced4f7196d57595b0a3f448060 Signed-off-by: srinivasyanamadala <srinivas.yanamadala@techmahindra.com>
Diffstat (limited to 'csit')
-rw-r--r--csit/resources/tests/data/onap.policy.opa.pdp.decision.empty_filter_response.json61
-rw-r--r--csit/resources/tests/data/onap.policy.opa.pdp.decision.filter_response.json23
-rw-r--r--csit/resources/tests/data/onap.policy.opa.pdp.decision.request.json2
-rw-r--r--csit/resources/tests/data/onap.policy.opa.pdp.decision.request.output.json5
-rw-r--r--csit/resources/tests/data/onap.policy.opa.pdp.decision.request_filter.json (renamed from csit/resources/tests/data/onap.policy.opa.pdp.decision.requestIndeterminate.json)3
-rw-r--r--csit/resources/tests/data/onap.policy.opa.pdp.decision.request_filter_empty.json (renamed from csit/resources/tests/data/onap.policy.opa.pdp.decision.badRequest.json)3
-rw-r--r--csit/resources/tests/data/onap.policy.opa.pdp.decision.requestfailure.json1
-rw-r--r--csit/resources/tests/opa-pdp-test.robot59
8 files changed, 127 insertions, 30 deletions
diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.decision.empty_filter_response.json b/csit/resources/tests/data/onap.policy.opa.pdp.decision.empty_filter_response.json
new file mode 100644
index 00000000..040f0624
--- /dev/null
+++ b/csit/resources/tests/data/onap.policy.opa.pdp.decision.empty_filter_response.json
@@ -0,0 +1,61 @@
+{
+ "output": {
+ "allow": true,
+ "role_grants": {
+ "billing": [
+ {
+ "action": "read",
+ "type": "finance"
+ },
+ {
+ "action": "update",
+ "type": "finance"
+ }
+ ],
+ "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"
+ }
+ ]
+ },
+ "user_is_admin": true,
+ "user_is_granted": [],
+ "user_roles": {
+ "alice": ["admin"],
+ "bob": ["employee", "billing"],
+ "eve": ["customer"]
+ }
+ },
+ "policyName": "role"
+}
diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.decision.filter_response.json b/csit/resources/tests/data/onap.policy.opa.pdp.decision.filter_response.json
new file mode 100644
index 00000000..d19f5fed
--- /dev/null
+++ b/csit/resources/tests/data/onap.policy.opa.pdp.decision.filter_response.json
@@ -0,0 +1,23 @@
+{
+ "output": {
+ "role_grants": {
+ "billing": [
+ {"action": "read", "type": "finance"},
+ {"action": "update", "type": "finance"}
+ ],
+ "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"}
+ ]
+ }
+ },
+ "policyName": "role"
+}
diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.decision.request.json b/csit/resources/tests/data/onap.policy.opa.pdp.decision.request.json
index 66132ea7..748a5529 100644
--- a/csit/resources/tests/data/onap.policy.opa.pdp.decision.request.json
+++ b/csit/resources/tests/data/onap.policy.opa.pdp.decision.request.json
@@ -1 +1 @@
-{"onapName":"CDS","onapComponent":"CDS","onapInstance":"CDS","currentDate": "2024-11-22", "currentTime": "2024-11-22T11:34:56Z", "timeZone": "UTC", "timeOffset": "+05:30", "currentDateTime": "2024-11-22T12:08:00Z", "policyName":"role/allow","input":{"user":"alice","action":"write","object":"id123","type":"dog"}}
+{"onapName":"CDS","onapComponent":"CDS","onapInstance":"CDS","currentDate": "2024-11-22", "currentTime": "2024-11-22T11:34:56Z", "timeZone": "UTC", "timeOffset": "+05:30", "currentDateTime": "2024-11-22T12:08:00Z", "policyName":"role","input":{"user":"alice","action":"write","object":"id123","type":"dog"}}
diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.decision.request.output.json b/csit/resources/tests/data/onap.policy.opa.pdp.decision.request.output.json
new file mode 100644
index 00000000..bf035c4b
--- /dev/null
+++ b/csit/resources/tests/data/onap.policy.opa.pdp.decision.request.output.json
@@ -0,0 +1,5 @@
+{
+ "errorMessage": "Policy Filter is nil.",
+ "policyName": "",
+ "responseCode": "bad_request"
+}
diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.decision.requestIndeterminate.json b/csit/resources/tests/data/onap.policy.opa.pdp.decision.request_filter.json
index 352ddb55..1a621c26 100644
--- a/csit/resources/tests/data/onap.policy.opa.pdp.decision.requestIndeterminate.json
+++ b/csit/resources/tests/data/onap.policy.opa.pdp.decision.request_filter.json
@@ -1,2 +1 @@
-{"onapName":"CDS","onapComponent":"CDS","onapInstance":"CDS","currentDate": "2024-11-22", "currentTime": "2024-11-22T11:34:56Z", "timeZone": "UTC", "timeOffset": "+05:30", "currentDateTime": "2024-11-22T12:08:00Z", "policyName":"role1/allow","input":{"user":"alice","action":"write","object":"id123","type":"dog"}}
-
+{"onapName":"CDS","onapComponent":"CDS","onapInstance":"CDS","currentDate": "2024-11-22", "currentTime": "2024-11-22T11:34:56Z", "timeZone": "UTC", "timeOffset": "+05:30", "currentDateTime": "2024-11-22T12:08:00Z", "policyName":"role","policyFilter": ["role_grants"],"input":{"user":"alice","action":"write","object":"id123","type":"dog"}}
diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.decision.badRequest.json b/csit/resources/tests/data/onap.policy.opa.pdp.decision.request_filter_empty.json
index b92aa88e..fec2ba48 100644
--- a/csit/resources/tests/data/onap.policy.opa.pdp.decision.badRequest.json
+++ b/csit/resources/tests/data/onap.policy.opa.pdp.decision.request_filter_empty.json
@@ -1,2 +1 @@
-{"onapName":"CDS","onapComponent":"CDS","onapInstance":"CDS","currentDate": "2024-11-22", "currentTime": "2024-11-22T11:34:56Z", "timeZone": "UTC", "timeOffset": "+05:30", "currentDateTime": "2024-11-22T12:08:00Z" "policyName":"role/allow","input":{"user":"carol","action":"write","object":"id123","type":"dog"}}
-
+{"onapName":"CDS","onapComponent":"CDS","onapInstance":"CDS","currentDate": "2024-11-22", "currentTime": "2024-11-22T11:34:56Z", "timeZone": "UTC", "timeOffset": "+05:30", "currentDateTime": "2024-11-22T12:08:00Z", "policyName":"role","policyFilter": [""],"input":{"user":"alice","action":"write","object":"id123","type":"dog"}}
diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.decision.requestfailure.json b/csit/resources/tests/data/onap.policy.opa.pdp.decision.requestfailure.json
deleted file mode 100644
index e9aea14a..00000000
--- a/csit/resources/tests/data/onap.policy.opa.pdp.decision.requestfailure.json
+++ /dev/null
@@ -1 +0,0 @@
-{"onapName":"CDS","onapComponent":"CDS","onapInstance":"CDS","currentDate": "2024-11-22", "currentTime": "2024-11-22T11:34:56Z", "timeZone": "UTC", "timeOffset": "+05:30", "currentDateTime": "2024-11-22T12:08:00Z", "policyName":"role/allow","input":{"user":"carol","action":"write","object":"id123","type":"dog"}}
diff --git a/csit/resources/tests/opa-pdp-test.robot b/csit/resources/tests/opa-pdp-test.robot
index a6d4c6d2..8e059ffd 100644
--- a/csit/resources/tests/opa-pdp-test.robot
+++ b/csit/resources/tests/opa-pdp-test.robot
@@ -15,22 +15,18 @@ Healthcheck
[Documentation] Verify OPA PDP health check
PdpxGetReq ${OPA_PDP_HOST} <Response [200]>
-RetrieveSuccessfulRequest
- [Documentation] Get Decision Request Successful for Opa Pdp
- DecisionRequest onap.policy.opa.pdp.decision.request.json PERMIT 200
-
-RetrieveDenyRequest
- [Documentation] Get Decision Request DENY for Opa Pdp
- DecisionRequest onap.policy.opa.pdp.decision.requestfailure.json DENY 200
-
-*** comments ***
-| RetrieveFailureRequest
-| |[Documentation] | Get Decision Request INDETERMINATE for Opa Pdp ***
-| | |DecisionRequest onap.policy.opa.pdp.decision.requestIndeterminate.json INDETERMINATE 200 ***
-
-RetrieveFailureBadRequest
- [Documentation] Get Decision Request Failure Bad Request for Opa Pdp
- DecisionRequest onap.policy.opa.pdp.decision.badRequest.json BAD_REQUEST 400
+ValidatingPolicyWithoutPolicyFilter
+ [Documentation] Validating the policy without giving policy filter
+ ValidatePolicyResponseWithoutFilter onap.policy.opa.pdp.decision.request.json 400 onap.policy.opa.pdp.decision.request.output.json
+
+ValidatingPolicyWithPolicyFilter
+ [Documentation] Validating the policy with policy filter
+ ValidatePolicyResponse onap.policy.opa.pdp.decision.request_filter.json 200 onap.policy.opa.pdp.decision.filter_response.json
+
+ValidatingPolicyWithEmptyPolicyFilter
+ [Documentation] Validating the policy with empty policy filter
+ ValidatePolicyResponse onap.policy.opa.pdp.decision.request_filter_empty.json 200 onap.policy.opa.pdp.decision.empty_filter_response.json
+
*** Keywords ***
PdpxGetReq
[Documentation] Verify the response of Health Check is Successful
@@ -39,15 +35,30 @@ PdpxGetReq
${resp}= PerformGetRequest ${POLICY_OPA_IP} ${url} 200 null ${hcauth}
Should Be Equal As Strings ${resp} ${status}
-DecisionRequest
- [Arguments] ${jsonfile} ${keyword} ${status}
+ValidatePolicyResponse
+ [Documentation] Validating the output for the policy
+ [Arguments] ${jsonfile} ${status} ${jsonfile1}
+ ${expectedStatus}= Set Variable ${status}
${postjson}= Get file ${CURDIR}/data/${jsonfile}
- ${resp}= DecisionPostReq ${postjson} ${status} abbrev=true
- Should Contain ${resp.text} ${keyword}
+ ${expected_data}= Get file ${CURDIR}/data/${jsonfile1}
+ ${hcauth}= PolicyAdminAuth
+ ${resp}= PerformPostRequest ${POLICY_OPA_IP} ${url} ${expectedStatus} ${postjson} abbrev=true ${hcauth}
+ ${response_data}= Get From Dictionary ${resp.json()} output
+ ${expected_value}= Evaluate json.loads('''${expected_data}''') json
+ ${expected_output}= Get From Dictionary ${expected_value} output
+ Dictionaries Should Be Equal ${response_data} ${expected_output}
-DecisionPostReq
- [Arguments] ${postjson} ${status} ${abbr}
+ValidatePolicyResponseWithoutFilter
+ [Documentation] Validating the output for the policy
+ [Arguments] ${jsonfile} ${status} ${jsonfile1}
${expectedStatus}= Set Variable ${status}
+ ${postjson}= Get file ${CURDIR}/data/${jsonfile}
+ ${expected_data}= Get file ${CURDIR}/data/${jsonfile1}
${hcauth}= PolicyAdminAuth
- ${resp}= PerformPostRequest ${POLICY_OPA_IP} ${url} ${expectedStatus} ${postjson} ${abbr} ${hcauth}
- RETURN ${resp}
+ ${resp}= PerformPostRequest ${POLICY_OPA_IP} ${url} ${expectedStatus} ${postjson} abbrev=true ${hcauth}
+ ${response_data}= Get From Dictionary ${resp.json()} responseCode
+ ${expected_value}= Evaluate json.loads('''${expected_data}''') json
+ ${expected_output}= Get From Dictionary ${expected_value} responseCode
+ Should Be Equal As Strings ${response_data} ${expected_output}
+
+