From 32fd1f3c1e22dbeb69e3cc150a6fb1b72ea0ed53 Mon Sep 17 00:00:00 2001 From: muraliparthatechm Date: Wed, 18 Dec 2024 18:15:17 +0100 Subject: Update CSIT with opa-pdp (docker-compose env) Issue-ID: POLICY-5211 Change-Id: I8b75e6e850fae171fbc75fc67cb59171a78df4e0 Signed-off-by: muraliparthatechm --- csit/resources/tests/api-test.robot | 2 +- .../onap.policy.opa.pdp.decision.badRequest.json | 2 + .../data/onap.policy.opa.pdp.decision.request.json | 1 + ...licy.opa.pdp.decision.requestIndeterminate.json | 2 + ...nap.policy.opa.pdp.decision.requestfailure.json | 1 + csit/resources/tests/opa-pdp-test.robot | 53 ++++++++++++++++++++++ 6 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 csit/resources/tests/data/onap.policy.opa.pdp.decision.badRequest.json create mode 100644 csit/resources/tests/data/onap.policy.opa.pdp.decision.request.json create mode 100644 csit/resources/tests/data/onap.policy.opa.pdp.decision.requestIndeterminate.json create mode 100644 csit/resources/tests/data/onap.policy.opa.pdp.decision.requestfailure.json create mode 100644 csit/resources/tests/opa-pdp-test.robot (limited to 'csit/resources/tests') 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} + +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} -- cgit 1.2.3-korg