diff options
author | Jim Hahn <jrh3@att.com> | 2021-05-10 15:36:30 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2021-05-10 16:01:03 -0400 |
commit | 3486a9218bc8d396dce8cdde32d0b1e38490bacf (patch) | |
tree | 32e95d25b23591bc7f5aa03965b4f658b3bca156 /csit | |
parent | 4fe6a2eb96c93ed7cd7e4ff18e9560d519e0ee9a (diff) |
Merge csits into docker/csit
Decided to move CSIT test source code from the individual repos into
the docker repo. This review modifies the scripts to begin the process,
and includes the CSIT code from xacml-pdp, as the first one to move.
Note: while the xacml-pdp files are new to the docker repo, they are
not actually new, thus their licenses were retained.
Issue-ID: POLICY-3299
Change-Id: I7cce548ceec38c9c1615af883f08eb118e84d132
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'csit')
-rwxr-xr-x | csit/prepare-csit.sh | 4 | ||||
-rwxr-xr-x | csit/run-project-csit.sh | 75 | ||||
-rw-r--r-- | csit/xacml-pdp/plans/setup.sh | 57 | ||||
-rw-r--r-- | csit/xacml-pdp/plans/teardown.sh | 20 | ||||
-rw-r--r-- | csit/xacml-pdp/plans/testplan.txt | 3 | ||||
-rw-r--r-- | csit/xacml-pdp/tests/data/onap.policy.guard.decision.request.json | 16 | ||||
-rw-r--r-- | csit/xacml-pdp/tests/data/onap.policy.monitoring.decision.request.json | 9 | ||||
-rw-r--r-- | csit/xacml-pdp/tests/data/onap.policy.naming.decision.request.json | 13 | ||||
-rw-r--r-- | csit/xacml-pdp/tests/data/onap.policy.optimization.decision.request.json | 15 | ||||
-rw-r--r-- | csit/xacml-pdp/tests/data/vCPE.policy.input.tosca.deploy.json | 5 | ||||
-rw-r--r-- | csit/xacml-pdp/tests/xacml-pdp-test.robot | 159 |
11 files changed, 339 insertions, 37 deletions
diff --git a/csit/prepare-csit.sh b/csit/prepare-csit.sh index b15aa4ee..018a9b50 100755 --- a/csit/prepare-csit.sh +++ b/csit/prepare-csit.sh @@ -22,9 +22,7 @@ if [ -z "$WORKSPACE" ]; then export WORKSPACE=`git rev-parse --show-toplevel` fi -TESTPLANDIR=${WORKSPACE}/${TESTPLAN} - -# Assume that if ROBOT_VENV is set and virtualenv with system site packages can be activated, +# Assume that if ROBOT_VENV is set and virtualenv with system site packages can be activated, # ci-management/jjb/integration/include-raw-integration-install-robotframework.sh has already # been executed diff --git a/csit/run-project-csit.sh b/csit/run-project-csit.sh index 07b9dea2..e9c75851 100755 --- a/csit/run-project-csit.sh +++ b/csit/run-project-csit.sh @@ -27,17 +27,17 @@ function on_exit(){ rc=$? if [[ ${WORKSPACE} ]]; then if [[ ${WORKDIR} ]]; then - rsync -av "$WORKDIR/" "$WORKSPACE/csit/archives/$TESTPLAN" + rsync -av "${WORKDIR}/" "${WORKSPACE}/csit/archives/${PROJECT}" fi # Record list of active docker containers - docker ps --format "{{.Image}}" > "$WORKSPACE/csit/archives/$TESTPLAN/_docker-images.log" + docker ps --format "{{.Image}}" > "${WORKSPACE}/csit/archives/${PROJECT}/_docker-images.log" # show memory consumption after all docker instances initialized - docker_stats | tee "$WORKSPACE/csit/archives/$TESTPLAN/_sysinfo-2-after-robot.txt" + docker_stats | tee "${WORKSPACE}/csit/archives/${PROJECT}/_sysinfo-2-after-robot.txt" fi # Run teardown script plan if it exists - cd "${TESTPLANDIR}/csit/plans/" - TEARDOWN="${TESTPLANDIR}/csit/plans/teardown.sh" + cd "${TESTPLANDIR}/plans/" + TEARDOWN="${TESTPLANDIR}/plans/teardown.sh" if [ -f "${TEARDOWN}" ]; then echo "Running teardown script ${TEARDOWN}" source_safely "${TEARDOWN}" @@ -72,7 +72,7 @@ function docker_stats(){ # save current set options function save_set() { RUN_CSIT_SAVE_SET="$-" - RUN_CSIT_SHELLOPTS="$SHELLOPTS" + RUN_CSIT_SHELLOPTS="${SHELLOPTS}" } # load the saved set options @@ -80,10 +80,10 @@ function load_set() { _setopts="$-" # bash shellopts - for i in $(echo "$SHELLOPTS" | tr ':' ' ') ; do + for i in $(echo "${SHELLOPTS}" | tr ':' ' ') ; do set +o ${i} done - for i in $(echo "$RUN_CSIT_SHELLOPTS" | tr ':' ' ') ; do + for i in $(echo "${RUN_CSIT_SHELLOPTS}" | tr ':' ' ') ; do set -o ${i} done @@ -132,7 +132,7 @@ then exit 1 fi -if [ -z "$WORKSPACE" ]; then +if [ -z "${WORKSPACE}" ]; then export WORKSPACE=$(git rev-parse --show-toplevel) fi @@ -145,29 +145,36 @@ export ROBOT_VARIABLES= source ${SCRIPTS}/get-branch-mariadb.sh export PROJECT="${1}" -rm -rf ${WORKSPACE}/${PROJECT} -mkdir ${WORKSPACE}/${PROJECT} + cd ${WORKSPACE} -# get the plan from git clone -if ! `git clone -b ${GERRIT_BRANCH} --single-branch https://github.com/onap/policy-${PROJECT}.git ${PROJECT}` ; then - echo "repo not found: policy/${PROJECT}" - exit 1 -fi +case "${PROJECT}" in +xacml-pdp) + export TESTPLANDIR="${WORKSPACE}/csit/${PROJECT}" + ;; +*) + export TESTPLANDIR="${WORKSPACE}/${PROJECT}/csit" -if [ -f "${WORKSPACE}/${1}/csit/plans/testplan.txt" ]; then - export TESTPLAN="${1}" -else - echo "testplan not found: ${WORKSPACE}/${1}/csit/plans/testplan.txt" - exit 2 -fi + rm -rf ${WORKSPACE}/${PROJECT} + mkdir ${WORKSPACE}/${PROJECT} -export TESTOPTIONS="${2}" + # get the plan from git clone + if ! `git clone -b ${GERRIT_BRANCH} --single-branch https://github.com/onap/policy-${PROJECT}.git ${PROJECT}` ; then + echo "repo not found: policy/${PROJECT}" + exit 1 + fi -rm -rf "$WORKSPACE/csit/archives/$TESTPLAN" -mkdir -p "$WORKSPACE/csit/archives/$TESTPLAN" + if [ ! -f "${TESTPLANDIR}/plans/testplan.txt" ]; then + echo "testplan not found: ${TESTPLANDIR}/plans/testplan.txt" + exit 2 + fi + ;; +esac -TESTPLANDIR="${WORKSPACE}/${TESTPLAN}" +export TESTOPTIONS="${2}" + +rm -rf "${WORKSPACE}/csit/archives/${PROJECT}" +mkdir -p "${WORKSPACE}/csit/archives/${PROJECT}" # Run installation of prerequired libraries source_safely "${SCRIPTS}/prepare-csit.sh" @@ -187,29 +194,29 @@ cp ${SCRIPTS}/config/ks.jks ${SCRIPTS}/config/drools/custom/policy-keystore cp ${SCRIPTS}/config/ks.jks ${SCRIPTS}/config/drools-apps/custom/policy-keystore # Run setup script plan if it exists -cd "${TESTPLANDIR}/csit/plans/" -SETUP="${TESTPLANDIR}/csit/plans/setup.sh" +cd "${TESTPLANDIR}/plans/" +SETUP="${TESTPLANDIR}/plans/setup.sh" if [ -f "${SETUP}" ]; then echo "Running setup script ${SETUP}" source_safely "${SETUP}" fi # show memory consumption after all docker instances initialized -docker_stats | tee "$WORKSPACE/csit/archives/$TESTPLAN/_sysinfo-1-after-setup.txt" +docker_stats | tee "${WORKSPACE}/csit/archives/${PROJECT}/_sysinfo-1-after-setup.txt" # Run test plan -cd "$WORKDIR" +cd "${WORKDIR}" echo "Reading the testplan:" -cat "${TESTPLANDIR}/csit/plans/testplan.txt" | egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' | sed "s|^|${TESTPLANDIR}/csit/tests/|" > testplan.txt +cat "${TESTPLANDIR}/plans/testplan.txt" | egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' | sed "s|^|${TESTPLANDIR}/tests/|" > testplan.txt cat testplan.txt SUITES=$( xargs -a testplan.txt ) echo ROBOT_VARIABLES="${ROBOT_VARIABLES}" echo "Starting Robot test suites ${SUITES} ..." relax_set -python -m robot.run -N ${TESTPLAN} -v WORKSPACE:/tmp ${ROBOT_VARIABLES} ${SUITES} +python -m robot.run -N ${PROJECT} -v WORKSPACE:/tmp ${ROBOT_VARIABLES} ${SUITES} RESULT=$? load_set -echo "RESULT: $RESULT" +echo "RESULT: ${RESULT}" # Note that the final steps are done in on_exit function after this exit! -exit $RESULT +exit ${RESULT} diff --git a/csit/xacml-pdp/plans/setup.sh b/csit/xacml-pdp/plans/setup.sh new file mode 100644 index 00000000..21d88213 --- /dev/null +++ b/csit/xacml-pdp/plans/setup.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# ============LICENSE_START======================================================= +# Copyright (C) 2020-2021 AT&T Intellectual Property. 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. +# 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, +# 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. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= +source ${SCRIPTS}/get-branch-mariadb.sh + +echo "Uninstall docker-py and reinstall docker." +pip uninstall -y docker-py +pip uninstall -y docker +pip install -U docker==2.7.0 + +sudo apt-get -y install libxml2-utils +bash ${SCRIPTS}/get-models-examples.sh + +source ${SCRIPTS}/detmVers.sh + +docker-compose -f ${SCRIPTS}/docker-compose-all.yml up -d xacml-pdp + +unset http_proxy https_proxy + +POLICY_API_IP=`get-instance-ip.sh policy-api` +MARIADB_IP=`get-instance-ip.sh mariadb` +POLICY_PDPX_IP=`get-instance-ip.sh policy-xacml-pdp` +SIM_IP=`get-instance-ip.sh policy.api.simpledemo.onap.org` +POLICY_PAP_IP=`get-instance-ip.sh policy-pap` + +echo PDP IP IS ${POLICY_PDPX_IP} +echo API IP IS ${POLICY_API_IP} +echo PAP IP IS ${POLICY_PAP_IP} +echo MARIADB IP IS ${MARIADB_IP} +echo SIM_IP IS ${SIM_IP} + +# wait for the app to start up +${SCRIPTS}/wait_for_port.sh ${POLICY_PDPX_IP} 6969 + +DATA2=${WORKSPACE}/models/models-examples/src/main/resources/policies + +ROBOT_VARIABLES="" +ROBOT_VARIABLES="${ROBOT_VARIABLES} -v SCR_DMAAP:${SCRIPTS}" +ROBOT_VARIABLES="${ROBOT_VARIABLES} -v DATA2:${DATA2}" +ROBOT_VARIABLES="${ROBOT_VARIABLES} -v POLICY_PDPX_IP:${POLICY_PDPX_IP}" +ROBOT_VARIABLES="${ROBOT_VARIABLES} -v POLICY_API_IP:${POLICY_API_IP}" +ROBOT_VARIABLES="${ROBOT_VARIABLES} -v POLICY_PAP_IP:${POLICY_PAP_IP}" diff --git a/csit/xacml-pdp/plans/teardown.sh b/csit/xacml-pdp/plans/teardown.sh new file mode 100644 index 00000000..e101973f --- /dev/null +++ b/csit/xacml-pdp/plans/teardown.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# ============LICENSE_START======================================================= +# Copyright (C) 2019-2021 AT&T Intellectual Property. 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. +# 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, +# 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. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +docker-compose -f ${SCRIPTS}/docker-compose-all.yml down -v diff --git a/csit/xacml-pdp/plans/testplan.txt b/csit/xacml-pdp/plans/testplan.txt new file mode 100644 index 00000000..b24929f4 --- /dev/null +++ b/csit/xacml-pdp/plans/testplan.txt @@ -0,0 +1,3 @@ +# Test suites are relative paths under [policy/xacml-pdp.git]/tests/. +# Place the suites in run order. +xacml-pdp-test.robot diff --git a/csit/xacml-pdp/tests/data/onap.policy.guard.decision.request.json b/csit/xacml-pdp/tests/data/onap.policy.guard.decision.request.json new file mode 100644 index 00000000..ee90feaa --- /dev/null +++ b/csit/xacml-pdp/tests/data/onap.policy.guard.decision.request.json @@ -0,0 +1,16 @@ +{ + "ONAPName": "Guard", + "ONAPComponent": "Guard-component", + "ONAPInstance": "Guard-component-instance", + "requestId": "unique-request-guard-1", + "action": "guard", + "resource": { + "guard": { + "actor": "APPC", + "operation": "ModifyConfig", + "target": "f17face5-69cb-4c88-9e0b-7426db7edddd", + "requestId": "c7c6a4aa-bb61-4a15-b831-ba1472dd4a65", + "clname": "ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a" + } + } +} diff --git a/csit/xacml-pdp/tests/data/onap.policy.monitoring.decision.request.json b/csit/xacml-pdp/tests/data/onap.policy.monitoring.decision.request.json new file mode 100644 index 00000000..053fa36d --- /dev/null +++ b/csit/xacml-pdp/tests/data/onap.policy.monitoring.decision.request.json @@ -0,0 +1,9 @@ +{ + "ONAPName": "DCAE", + "ONAPComponent": "PolicyHandler", + "ONAPInstance": "622431a4-9dea-4eae-b443-3b2164639c64", + "action": "configure", + "resource": { + "policy-id": "onap.restart.tca" + } +} diff --git a/csit/xacml-pdp/tests/data/onap.policy.naming.decision.request.json b/csit/xacml-pdp/tests/data/onap.policy.naming.decision.request.json new file mode 100644 index 00000000..3833a241 --- /dev/null +++ b/csit/xacml-pdp/tests/data/onap.policy.naming.decision.request.json @@ -0,0 +1,13 @@ +{ + "ONAPName": "SDNC", + "ONAPComponent": "SDNC-component", + "ONAPInstance": "SDNC-component-instance", + "requestId": "unique-request-sdnc-1", + "action": "naming", + "resource": { + "nfRole": [], + "naming-type": [], + "property-name": [], + "policy-type": ["onap.policies.Naming"] + } +} diff --git a/csit/xacml-pdp/tests/data/onap.policy.optimization.decision.request.json b/csit/xacml-pdp/tests/data/onap.policy.optimization.decision.request.json new file mode 100644 index 00000000..d997099c --- /dev/null +++ b/csit/xacml-pdp/tests/data/onap.policy.optimization.decision.request.json @@ -0,0 +1,15 @@ +{ + "ONAPName": "OOF", + "ONAPComponent": "OOF-component", + "ONAPInstance": "OOF-component-instance", + "context" : { + "subscriberName": [] + }, + "action": "optimize", + "resource": { + "scope": [], + "services": [], + "resources": [], + "geography": [] + } +} diff --git a/csit/xacml-pdp/tests/data/vCPE.policy.input.tosca.deploy.json b/csit/xacml-pdp/tests/data/vCPE.policy.input.tosca.deploy.json new file mode 100644 index 00000000..7ace047b --- /dev/null +++ b/csit/xacml-pdp/tests/data/vCPE.policy.input.tosca.deploy.json @@ -0,0 +1,5 @@ +{"policies":[ + {"policy-id":"onap.restart.tca"}, + {"policy-id":"OSDF_CASABLANCA.Affinity_Default"} + ] +} diff --git a/csit/xacml-pdp/tests/xacml-pdp-test.robot b/csit/xacml-pdp/tests/xacml-pdp-test.robot new file mode 100644 index 00000000..e27972ba --- /dev/null +++ b/csit/xacml-pdp/tests/xacml-pdp-test.robot @@ -0,0 +1,159 @@ +*** Settings *** +Library Collections +Library RequestsLibrary +Library OperatingSystem +Library Process +Library json + +*** Test Cases *** +Healthcheck + [Documentation] Verify policy xacml-pdp health check + ${resp}= PeformGetRequest /policy/pdpx/v1/healthcheck 200 + Should Be Equal As Strings ${resp.json()['code']} 200 + +Statistics + [Documentation] Verify policy xacml-pdp statistics + ${resp}= PeformGetRequest /policy/pdpx/v1/statistics 200 + Should Be Equal As Strings ${resp.json()['code']} 200 + +MakeTopics + [Documentation] Creates the Policy topics + ${result}= Run Process ${SCR_DMAAP}/make_topic.sh POLICY-PDP-PAP + Should Be Equal As Integers ${result.rc} 0 + +ExecuteXacmlPolicy + Wait Until Keyword Succeeds 0 min 15 sec CreateMonitorPolicy + Wait Until Keyword Succeeds 0 min 15 sec CreateOptimizationPolicy + Wait Until Keyword Succeeds 0 min 15 sec GetDefaultDecision + Wait Until Keyword Succeeds 0 min 15 sec DeployPolicies + Wait Until Keyword Succeeds 0 min 15 sec GetStatisticsAfterDeployed + Wait Until Keyword Succeeds 0 min 15 sec GetAbbreviatedDecisionResult + Wait Until Keyword Succeeds 0 min 15 sec GetMonitoringDecision + Wait Until Keyword Succeeds 0 min 15 sec GetNamingDecision + Wait Until Keyword Succeeds 0 min 15 sec GetOptimizationDecision + Wait Until Keyword Succeeds 0 min 15 sec GetStatisticsAfterDecision + Wait Until Keyword Succeeds 0 min 15 sec UndeployMonitorPolicy + Wait Until Keyword Succeeds 0 min 15 sec GetStatisticsAfterUndeploy + +*** Keywords *** + +CreateMonitorPolicy + [Documentation] Create a Monitoring policy + CreatePolicy /policy/api/v1/policytypes/onap.policies.monitoring.tcagen2/versions/1.0.0/policies 200 vCPE.policy.monitoring.input.tosca.json onap.restart.tca 1.0.0 + +CreateOptimizationPolicy + [Documentation] Create an Optimization policy + CreatePolicy /policy/api/v1/policytypes/onap.policies.optimization.resource.AffinityPolicy/versions/1.0.0/policies 200 vCPE.policies.optimization.input.tosca.json OSDF_CASABLANCA.Affinity_Default 1.0.0 + +GetDefaultDecision + [Documentation] Get Default Decision with no policies in Xacml PDP + ${resp}= PerformPostRequest /policy/pdpx/v1/decision abbrev=true ${POLICY_PDPX_IP} 200 onap.policy.guard.decision.request.json ${CURDIR}/data + ${status}= Get From Dictionary ${resp.json()} status + Should Be Equal As Strings ${status} Permit + +DeployPolicies + [Documentation] Runs Policy PAP to deploy a policy + ${resp}= PerformPostRequest /policy/pap/v1/pdps/policies null ${POLICY_PAP_IP} 202 vCPE.policy.input.tosca.deploy.json ${CURDIR}/data + Sleep 5s + ${result}= Run Process ${SCR_DMAAP}/wait_topic.sh POLICY-PDP-PAP + ... responseTo xacml ACTIVE onap.restart.tca + +GetStatisticsAfterDeployed + [Documentation] Verify policy xacml-pdp statistics after policy is deployed + ${resp}= PeformGetRequest /policy/pdpx/v1/statistics 200 + Should Be Equal As Strings ${resp.json()['code']} 200 + Should Be Equal As Strings ${resp.json()['totalPoliciesCount']} 3 + +GetAbbreviatedDecisionResult + [Documentation] Get Decision with abbreviated results from Policy Xacml PDP + ${resp}= PerformPostRequest /policy/pdpx/v1/decision abbrev=true ${POLICY_PDPX_IP} 200 onap.policy.monitoring.decision.request.json ${CURDIR}/data + ${policy}= Get From Dictionary ${resp.json()['policies']} onap.restart.tca + Dictionary Should Contain Key ${policy} type + Dictionary Should Contain Key ${policy} metadata + Dictionary Should Not Contain Key ${policy} type_version + Dictionary Should Not Contain Key ${policy} properties + Dictionary Should Not Contain Key ${policy} name + Dictionary Should Not Contain Key ${policy} version + +GetMonitoringDecision + [Documentation] Get Decision from Monitoring Policy Xacml PDP + ${resp}= PerformPostRequest /policy/pdpx/v1/decision null ${POLICY_PDPX_IP} 200 onap.policy.monitoring.decision.request.json ${CURDIR}/data + ${policy}= Get From Dictionary ${resp.json()['policies']} onap.restart.tca + Dictionary Should Contain Key ${policy} type + Dictionary Should Contain Key ${policy} metadata + Dictionary Should Contain Key ${policy} type_version + Dictionary Should Contain Key ${policy} properties + Dictionary Should Contain Key ${policy} name + Dictionary Should Contain Key ${policy} version + +GetNamingDecision + [Documentation] Get Decision from Naming Policy Xacml PDP + ${resp}= PerformPostRequest /policy/pdpx/v1/decision null ${POLICY_PDPX_IP} 200 onap.policy.naming.decision.request.json ${CURDIR}/data + ${policy}= Get From Dictionary ${resp.json()['policies']} SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP + Dictionary Should Contain Key ${policy} type + Dictionary Should Contain Key ${policy} type_version + Dictionary Should Contain Key ${policy} properties + Dictionary Should Contain Key ${policy} name + +GetOptimizationDecision + [Documentation] Get Decision from Optimization Policy Xacml PDP + ${resp}= PerformPostRequest /policy/pdpx/v1/decision null ${POLICY_PDPX_IP} 200 onap.policy.optimization.decision.request.json ${CURDIR}/data + ${policy}= Get From Dictionary ${resp.json()['policies']} OSDF_CASABLANCA.Affinity_Default + Dictionary Should Contain Key ${policy} type + Dictionary Should Contain Key ${policy} type_version + Dictionary Should Contain Key ${policy} properties + Dictionary Should Contain Key ${policy} name + +GetStatisticsAfterDecision + [Documentation] Runs Policy Xacml PDP Statistics after Decision request + ${resp}= PeformGetRequest /policy/pdpx/v1/statistics 200 + Should Be Equal As Strings ${resp.json()['code']} 200 + Should Be Equal As Strings ${resp.json()['permitDecisionsCount']} 4 + Should Be Equal As Strings ${resp.json()['notApplicableDecisionsCount']} 1 + +UndeployMonitorPolicy + [Documentation] Runs Policy PAP to undeploy a policy + PeformDeleteRequest /policy/pap/v1/pdps/policies/onap.restart.tca 202 + +GetStatisticsAfterUndeploy + [Documentation] Runs Policy Xacml PDP Statistics after policy is undeployed + ${resp}= PeformGetRequest /policy/pdpx/v1/statistics 200 + Should Be Equal As Strings ${resp.json()['code']} 200 + Should Be Equal As Strings ${resp.json()['totalPoliciesCount']} 2 + +CreatePolicy + [Arguments] ${url} ${expectedstatus} ${jsonfile} ${policyname} ${policyversion} + [Documentation] Create the specific policy + ${resp}= PerformPostRequest ${url} null ${POLICY_API_IP} ${expectedstatus} ${jsonfile} ${DATA2} + Run Keyword If ${expectedstatus}==200 Dictionary Should Contain Key ${resp.json()['topology_template']['policies'][0]} ${policyname} + Run Keyword If ${expectedstatus}==200 Should Be Equal As Strings ${resp.json()['topology_template']['policies'][0]['${policyname}']['version']} ${policyversion} + +PerformPostRequest + [Arguments] ${url} ${params} ${hostname} ${expectedstatus} ${jsonfile} ${filepath} + ${auth}= Create List healthcheck zb!XztG34 + ${postjson}= Get file ${filepath}/${jsonfile} + Log Creating session https://${hostname}:6969 + ${session}= Create Session policy https://${hostname}:6969 auth=${auth} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json + ${resp}= POST On Session policy ${url} params=${params} data=${postjson} headers=${headers} expected_status=${expectedstatus} + Log Received response from policy ${resp.text} + [return] ${resp} + +PeformGetRequest + [Arguments] ${url} ${expectedstatus} + ${auth}= Create List healthcheck zb!XztG34 + Log Creating session https://${POLICY_PDPX_IP}:6969 + ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json + ${resp}= GET On Session policy ${url} headers=${headers} expected_status=${expectedstatus} + Log Received response from policy ${resp.text} + [return] ${resp} + +PeformDeleteRequest + [Arguments] ${url} ${expectedstatus} + ${auth}= Create List healthcheck zb!XztG34 + Log Creating session https://${POLICY_PAP_IP}:6969 + ${session}= Create Session policy https://${POLICY_PAP_IP}:6969 auth=${auth} + ${headers}= Create Dictionary Accept=application/json Content-Type=application/json + ${resp}= DELETE On Session policy ${url} headers=${headers} expected_status=${expectedstatus} + Log Received response from policy ${resp.text} |