aboutsummaryrefslogtreecommitdiffstats
path: root/csit/resources/tests
diff options
context:
space:
mode:
Diffstat (limited to 'csit/resources/tests')
-rw-r--r--csit/resources/tests/api-test.robot2
-rw-r--r--csit/resources/tests/data/onap.policy.opa.pdp.decision.badRequest.json2
-rw-r--r--csit/resources/tests/data/onap.policy.opa.pdp.decision.request.json1
-rw-r--r--csit/resources/tests/data/onap.policy.opa.pdp.decision.requestIndeterminate.json2
-rw-r--r--csit/resources/tests/data/onap.policy.opa.pdp.decision.requestfailure.json1
-rw-r--r--csit/resources/tests/opa-pdp-test.robot53
6 files changed, 60 insertions, 1 deletions
diff --git a/csit/resources/tests/api-test.robot b/csit/resources/tests/api-test.robot
index 29c2fba4..e1b8fd47 100644
--- a/csit/resources/tests/api-test.robot
+++ b/csit/resources/tests/api-test.robot
@@ -16,7 +16,7 @@ Healthcheck
RetrievePolicyTypes
[Documentation] Retrieve all policy types
- FetchPolicyTypes /policy/api/v1/policytypes 37
+ FetchPolicyTypes /policy/api/v1/policytypes 38
CreateTCAPolicyTypeV1
[Documentation] Create an existing policy type with modification and keeping the same version should result in error.
diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.decision.badRequest.json b/csit/resources/tests/data/onap.policy.opa.pdp.decision.badRequest.json
new file mode 100644
index 00000000..b92aa88e
--- /dev/null
+++ b/csit/resources/tests/data/onap.policy.opa.pdp.decision.badRequest.json
@@ -0,0 +1,2 @@
+{"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/data/onap.policy.opa.pdp.decision.request.json b/csit/resources/tests/data/onap.policy.opa.pdp.decision.request.json
new file mode 100644
index 00000000..66132ea7
--- /dev/null
+++ b/csit/resources/tests/data/onap.policy.opa.pdp.decision.request.json
@@ -0,0 +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"}}
diff --git a/csit/resources/tests/data/onap.policy.opa.pdp.decision.requestIndeterminate.json b/csit/resources/tests/data/onap.policy.opa.pdp.decision.requestIndeterminate.json
new file mode 100644
index 00000000..352ddb55
--- /dev/null
+++ b/csit/resources/tests/data/onap.policy.opa.pdp.decision.requestIndeterminate.json
@@ -0,0 +1,2 @@
+{"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"}}
+
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
new file mode 100644
index 00000000..e9aea14a
--- /dev/null
+++ b/csit/resources/tests/data/onap.policy.opa.pdp.decision.requestfailure.json
@@ -0,0 +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"}}
diff --git a/csit/resources/tests/opa-pdp-test.robot b/csit/resources/tests/opa-pdp-test.robot
new file mode 100644
index 00000000..908314f8
--- /dev/null
+++ b/csit/resources/tests/opa-pdp-test.robot
@@ -0,0 +1,53 @@
+*** Settings ***
+Library RequestsLibrary
+Library Collections
+Library OperatingSystem
+Library Process
+Library json
+Resource common-library.robot
+
+*** Variables ***
+${OPA_PDP_HOST} /policy/pdpx/v1/healthcheck
+${url} /policy/pdpx/v1/decision
+
+*** Test Cases ***
+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
+*** Keywords ***
+PdpxGetReq
+ [Documentation] Verify the response of Health Check is Successful
+ [Arguments] ${url} ${status}
+ ${hcauth}= PolicyAdminAuth
+ ${resp}= PerformGetRequest ${POLICY_OPA_IP} ${url} 200 null ${hcauth}
+ Should Be Equal As Strings ${resp} ${status}
+
+DecisionRequest
+ [Arguments] ${jsonfile} ${keyword} ${status}
+ ${postjson}= Get file ${CURDIR}/data/${jsonfile}
+ ${resp}= DecisionPostReq ${postjson} ${status} abbrev=true
+ Should Contain ${resp.text} ${keyword}
+
+DecisionPostReq
+ [Arguments] ${postjson} ${status} ${abbr}
+ ${expectedStatus}= Set Variable ${status}
+ ${hcauth}= PolicyAdminAuth
+ ${resp}= PerformPostRequest ${POLICY_OPA_IP} ${url} ${expectedStatus} ${postjson} ${abbr} ${hcauth}
+ RETURN ${resp}