Michael Mokry | 88f4d47 | 2019-03-04 12:00:05 -0600 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Library Collections |
| 3 | Library RequestsLibrary |
| 4 | Library OperatingSystem |
| 5 | Library json |
| 6 | |
| 7 | *** Test Cases *** |
| 8 | Healthcheck |
| 9 | [Documentation] Runs Policy Xacml PDP Health check |
| 10 | ${auth}= Create List healthcheck zb!XztG34 |
Michael Mokry | ed8bae5 | 2019-03-12 15:10:53 -0500 | [diff] [blame] | 11 | Log Creating session https://${POLICY_PDPX_IP}:6969 |
| 12 | ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth} |
Michael Mokry | 88f4d47 | 2019-03-04 12:00:05 -0600 | [diff] [blame] | 13 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 14 | ${resp}= Get Request policy /policy/pdpx/v1/healthcheck headers=${headers} |
| 15 | Log Received response from policy ${resp.text} |
| 16 | Should Be Equal As Strings ${resp.status_code} 200 |
| 17 | Should Be Equal As Strings ${resp.json()['code']} 200 |
| 18 | |
| 19 | Statistics |
| 20 | [Documentation] Runs Policy Xacml PDP Statistics |
| 21 | ${auth}= Create List healthcheck zb!XztG34 |
Michael Mokry | ed8bae5 | 2019-03-12 15:10:53 -0500 | [diff] [blame] | 22 | Log Creating session https://${POLICY_PDPX_IP}:6969 |
| 23 | ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth} |
Michael Mokry | 88f4d47 | 2019-03-04 12:00:05 -0600 | [diff] [blame] | 24 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 25 | ${resp}= Get Request policy /policy/pdpx/v1/statistics headers=${headers} |
| 26 | Log Received response from policy ${resp.text} |
| 27 | Should Be Equal As Strings ${resp.status_code} 200 |
| 28 | Should Be Equal As Strings ${resp.json()['code']} 200 |
Michael Mokry | b4f6962 | 2019-05-13 13:09:17 -0500 | [diff] [blame] | 29 | |
| 30 | ExecuteXacmlPolicy |
| 31 | Wait Until Keyword Succeeds 2 min 5 sec CreateMonitorPolicyType |
| 32 | Wait Until Keyword Succeeds 2 min 5 sec CreateNewMonitorPolicy |
| 33 | Wait Until Keyword Succeeds 2 min 5 sec DeployMonitorPolicy |
| 34 | Wait Until Keyword Succeeds 2 min 10 sec GetDecision |
| 35 | |
| 36 | *** Keywords *** |
| 37 | |
| 38 | CreateMonitorPolicyType |
| 39 | [Documentation] Create Monitoring Policy Type |
| 40 | ${auth}= Create List healthcheck zb!XztG34 |
| 41 | ${postjson}= Get file ${CURDIR}/data/onap.policies.monitoring.cdap.tca.hi.lo.app.json |
| 42 | Log Creating session https://${POLICY_API_IP}:6969 |
| 43 | ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth} |
| 44 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 45 | ${resp}= Post Request policy /policy/api/v1/policytypes data=${postjson} headers=${headers} |
| 46 | Log Received response from policy2 ${resp.text} |
| 47 | Should Be Equal As Strings ${resp.status_code} 200 |
| 48 | ${postjsonobject} To Json ${postjson} |
| 49 | Dictionary Should Contain Key ${resp.json()} tosca_definitions_version |
| 50 | Dictionary Should Contain Key ${postjsonobject} tosca_definitions_version |
| 51 | |
| 52 | CreateNewMonitorPolicy |
| 53 | [Documentation] Create a new Monitoring policy |
| 54 | ${auth}= Create List healthcheck zb!XztG34 |
| 55 | ${postjson}= Get file ${CURDIR}/data/vCPE.policy.monitoring.input.tosca.json |
| 56 | Log Creating session https://${POLICY_API_IP}:6969 |
| 57 | ${session}= Create Session policy https://${POLICY_API_IP}:6969 auth=${auth} |
| 58 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 59 | ${resp}= Post Request policy /policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0/policies data=${postjson} headers=${headers} |
| 60 | Log Received response from policy4 ${resp.text} |
| 61 | ${postjsonobject} To Json ${postjson} |
| 62 | Should Be Equal As Strings ${resp.status_code} 200 |
| 63 | Dictionary Should Contain Key ${resp.json()} tosca_definitions_version |
| 64 | Dictionary Should Contain Key ${postjsonobject} tosca_definitions_version |
| 65 | |
| 66 | DeployMonitorPolicy |
| 67 | [Documentation] Runs Policy PAP to deploy a policy |
| 68 | ${auth}= Create List healthcheck zb!XztG34 |
| 69 | ${postjson}= Get file ${CURDIR}/data/vCPE.policy.monitoring.input.tosca.deploy.json |
| 70 | Log Creating session https://${POLICY_PAP_IP}:6969 |
| 71 | ${session}= Create Session policy https://${POLICY_PAP_IP}:6969 auth=${auth} |
| 72 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 73 | ${resp}= Post Request policy /policy/pap/v1/pdps/policies data=${postjson} headers=${headers} |
| 74 | Log Received response from policy5 ${resp.text} |
| 75 | ${postjsonobject} To Json ${postjson} |
| 76 | Should Be Equal As Strings ${resp.status_code} 200 |
| 77 | |
| 78 | GetStatisticsAfterDeployed |
| 79 | [Documentation] Runs Policy Xacml PDP Statistics after policy is deployed |
| 80 | ${auth}= Create List healthcheck zb!XztG34 |
| 81 | Log Creating session https://${POLICY_PDPX_IP}:6969 |
| 82 | ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth} |
| 83 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 84 | ${resp}= Get Request policy /policy/pdpx/v1/statistics headers=${headers} |
| 85 | Log Received response from policy ${resp.text} |
| 86 | Should Be Equal As Strings ${resp.status_code} 200 |
| 87 | Should Be Equal As Strings ${resp.json()['code']} 200 |
| 88 | Should Be Equal As Strings ${resp.json()['totalPoliciesCount'] 1 |
| 89 | |
| 90 | GetDecision |
| 91 | [Documentation] Get Decision from Policy Xacml PDP |
| 92 | ${auth}= Create List healthcheck zb!XztG34 |
| 93 | ${postjson}= Get file ${CURDIR}/data/onap.policy.monitoring.decision.request.json |
| 94 | Log Creating session https://${POLICY_PDPX_IP}:6969 |
| 95 | ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth} |
| 96 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 97 | ${resp}= Post Request policy /policy/pdpx/v1/decision data=${postjson} headers=${headers} |
| 98 | Log Received response from policy ${resp.text} |
| 99 | Should Be Equal As Strings ${resp.status_code} 200 |
| 100 | |
| 101 | GetStatisticsAfterDecision |
| 102 | [Documentation] Runs Policy Xacml PDP Statistics after Decision request |
| 103 | ${auth}= Create List healthcheck zb!XztG34 |
| 104 | Log Creating session https://${POLICY_PDPX_IP}:6969 |
| 105 | ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth} |
| 106 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 107 | ${resp}= Get Request policy /policy/pdpx/v1/statistics headers=${headers} |
| 108 | Log Received response from policy ${resp.text} |
| 109 | Should Be Equal As Strings ${resp.status_code} 200 |
| 110 | Should Be Equal As Strings ${resp.json()['code']} 200 |
| 111 | Should Be Equal As Strings ${resp.json()['totalDecisionsCount'] 1 |
| 112 | |
| 113 | UndeployMonitorPolicy |
| 114 | [Documentation] Runs Policy PAP to undeploy a policy |
| 115 | ${auth}= Create List healthcheck zb!XztG34 |
| 116 | Log Creating session https://${POLICY_PAP_IP}:6969 |
| 117 | ${session}= Create Session policy https://${POLICY_PAP_IP}:6969 auth=${auth} |
| 118 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 119 | ${resp}= Delete Request policy /policy/pap/v1/pdps/policies/onap.restart.tca headers=${headers} |
| 120 | Log Received response from policy ${resp.text} |
| 121 | Should Be Equal As Strings ${resp.status_code} 200 |
| 122 | |
| 123 | GetStatisticsAfterUndeploy |
| 124 | [Documentation] Runs Policy Xacml PDP Statistics after policy is undeployed |
| 125 | ${auth}= Create List healthcheck zb!XztG34 |
| 126 | Log Creating session https://${POLICY_PDPX_IP}:6969 |
| 127 | ${session}= Create Session policy https://${POLICY_PDPX_IP}:6969 auth=${auth} |
| 128 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 129 | ${resp}= Get Request policy /policy/pdpx/v1/statistics headers=${headers} |
| 130 | Log Received response from policy ${resp.text} |
| 131 | Should Be Equal As Strings ${resp.status_code} 200 |
| 132 | Should Be Equal As Strings ${resp.json()['code']} 200 |
| 133 | Should Be Equal As Strings ${resp.json()['totalPoliciesCount'] 0 |
| 134 | |
| 135 | |