a.sreekumar | 60d6a08 | 2021-08-20 17:39:53 +0100 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Library Collections |
| 3 | Library RequestsLibrary |
| 4 | Library OperatingSystem |
| 5 | Library json |
| 6 | |
a.sreekumar | 60d6a08 | 2021-08-20 17:39:53 +0100 | [diff] [blame] | 7 | *** Keywords *** |
| 8 | |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 9 | PolicyAdminAuth |
| 10 | ${policyadmin}= Create list policyadmin zb!XztG34 |
| 11 | [return] ${policyadmin} |
| 12 | |
| 13 | HealthCheckAuth |
| 14 | ${healthcheck}= Create list healthcheck zb!XztG34 |
| 15 | [return] ${healthcheck} |
| 16 | |
| 17 | PerformPostRequest |
| 18 | [Arguments] ${hostname} ${url} ${expectedstatus} ${postjson} ${params} ${auth} |
| 19 | Log Creating session https://${hostname}:6969 |
| 20 | ${session}= Create Session policy https://${hostname}:6969 auth=${auth} |
| 21 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 22 | ${resp}= POST On Session policy ${url} data=${postjson} params=${params} headers=${headers} expected_status=${expectedstatus} |
| 23 | Log Received response from policy ${resp.text} |
| 24 | [return] ${resp} |
| 25 | |
| 26 | PerformPutRequest |
| 27 | [Arguments] ${hostname} ${url} ${expectedstatus} ${params} ${auth} |
| 28 | Log Creating session https://${hostname}:6969 |
| 29 | ${session}= Create Session policy https://${hostname}:6969 auth=${auth} |
| 30 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 31 | ${resp}= PUT On Session policy ${url} params=${params} headers=${headers} expected_status=${expectedstatus} |
| 32 | Log Received response from policy ${resp.text} |
| 33 | [return] ${resp} |
| 34 | |
| 35 | PerformGetRequest |
| 36 | [Arguments] ${hostname} ${url} ${expectedstatus} ${params} ${auth} |
| 37 | Log Creating session https://${hostname}:6969 |
| 38 | ${session}= Create Session policy https://${hostname}:6969 auth=${auth} |
| 39 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 40 | ${resp}= GET On Session policy ${url} params=${params} headers=${headers} expected_status=${expectedstatus} |
| 41 | Log Received response from policy ${resp.text} |
| 42 | [return] ${resp} |
| 43 | |
| 44 | PerformDeleteRequest |
| 45 | [Arguments] ${hostname} ${url} ${expectedstatus} ${auth} |
| 46 | Log Creating session https://${hostname}:6969 |
| 47 | ${session}= Create Session policy https://${hostname}:6969 auth=${auth} |
| 48 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json |
| 49 | ${resp}= DELETE On Session policy ${url} headers=${headers} expected_status=${expectedstatus} |
| 50 | Log Received response from policy ${resp.text} |
| 51 | |
a.sreekumar | 60d6a08 | 2021-08-20 17:39:53 +0100 | [diff] [blame] | 52 | CreatePolicy |
| 53 | [Arguments] ${url} ${expectedstatus} ${postjson} ${policyname} ${policyversion} |
| 54 | [Documentation] Create the specific policy |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 55 | ${policyadmin}= PolicyAdminAuth |
| 56 | ${resp}= PerformPostRequest ${POLICY_API_IP} ${url} ${expectedstatus} ${postjson} null ${policyadmin} |
a.sreekumar | 60d6a08 | 2021-08-20 17:39:53 +0100 | [diff] [blame] | 57 | Run Keyword If ${expectedstatus}==200 Dictionary Should Contain Key ${resp.json()['topology_template']['policies'][0]} ${policyname} |
| 58 | Run Keyword If ${expectedstatus}==200 Should Be Equal As Strings ${resp.json()['topology_template']['policies'][0]['${policyname}']['version']} ${policyversion} |
| 59 | |
| 60 | QueryPdpGroups |
| 61 | [Documentation] Verify pdp group query - supports upto 2 groups |
| 62 | [Arguments] ${groupsLength} ${group1Name} ${group1State} ${policiesLengthInGroup1} ${group2Name} ${group2State} ${policiesLengthInGroup2} |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 63 | ${policyadmin}= PolicyAdminAuth |
| 64 | ${resp}= PerformGetRequest ${POLICY_PAP_IP} /policy/pap/v1/pdps 200 null ${policyadmin} |
a.sreekumar | 60d6a08 | 2021-08-20 17:39:53 +0100 | [diff] [blame] | 65 | Length Should Be ${resp.json()['groups']} ${groupsLength} |
| 66 | Should Be Equal As Strings ${resp.json()['groups'][0]['name']} ${group1Name} |
| 67 | Should Be Equal As Strings ${resp.json()['groups'][0]['pdpGroupState']} ${group1State} |
| 68 | Length Should Be ${resp.json()['groups'][0]['pdpSubgroups'][0]['policies']} ${policiesLengthInGroup1} |
| 69 | Run Keyword If ${groupsLength}>1 Should Be Equal As Strings ${resp.json()['groups'][1]['name']} ${group2Name} |
| 70 | Run Keyword If ${groupsLength}>1 Should Be Equal As Strings ${resp.json()['groups'][1]['pdpGroupState']} ${group2State} |
| 71 | Run Keyword If ${groupsLength}>1 Length Should Be ${resp.json()['groups'][1]['pdpSubgroups'][0]['policies']} ${policiesLengthInGroup2} |
| 72 | |
| 73 | QueryPolicyAudit |
| 74 | [Arguments] ${url} ${expectedstatus} ${pdpGroup} ${pdpType} ${policyName} ${expectedAction} |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 75 | ${policyadmin}= PolicyAdminAuth |
| 76 | ${resp}= PerformGetRequest ${POLICY_PAP_IP} ${url} ${expectedstatus} recordCount=1 ${policyadmin} |
a.sreekumar | 60d6a08 | 2021-08-20 17:39:53 +0100 | [diff] [blame] | 77 | Should Be Equal As Strings ${resp.json()[0]['pdpGroup']} ${pdpGroup} |
| 78 | Should Be Equal As Strings ${resp.json()[0]['pdpType']} ${pdpType} |
| 79 | Should Be Equal As Strings ${resp.json()[0]['policy']['name']} ${policyName} |
| 80 | Should Be Equal As Strings ${resp.json()[0]['policy']['version']} 1.0.0 |
| 81 | Should Be Equal As Strings ${resp.json()[0]['action']} ${expectedAction} |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 82 | Should Be Equal As Strings ${resp.json()[0]['user']} policyadmin |
a.sreekumar | 60d6a08 | 2021-08-20 17:39:53 +0100 | [diff] [blame] | 83 | |
| 84 | QueryPolicyStatus |
adheli.tavares | 496b301 | 2021-11-01 10:40:32 +0000 | [diff] [blame] | 85 | [Documentation] Verify policy deployment status |
| 86 | [Arguments] ${policyName} ${pdpGroup} ${pdpType} ${pdpName} ${policyTypeName} |
| 87 | ${policyadmin}= PolicyAdminAuth |
| 88 | ${resp}= PerformGetRequest ${POLICY_PAP_IP} /policy/pap/v1/policies/status 200 null ${policyadmin} |
| 89 | FOR ${responseEntry} IN @{resp.json()} |
| 90 | Exit For Loop IF '${responseEntry['policy']['name']}'=='${policyName}' |
| 91 | END |
| 92 | Should Be Equal As Strings ${resp.status_code} 200 |
| 93 | Should Be Equal As Strings ${responseEntry['pdpGroup']} ${pdpGroup} |
| 94 | Should Be Equal As Strings ${responseEntry['pdpType']} ${pdpType} |
| 95 | Should Be Equal As Strings ${responseEntry['pdpId']} ${pdpName} |
| 96 | Should Be Equal As Strings ${responseEntry['policy']['name']} ${policyName} |
| 97 | Should Be Equal As Strings ${responseEntry['policy']['version']} 1.0.0 |
| 98 | Should Be Equal As Strings ${responseEntry['policyType']['name']} ${policyTypeName} |
| 99 | Should Be Equal As Strings ${responseEntry['policyType']['version']} 1.0.0 |
| 100 | Should Be Equal As Strings ${responseEntry['deploy']} True |
| 101 | Should Be Equal As Strings ${responseEntry['state']} SUCCESS |
a.sreekumar | 60d6a08 | 2021-08-20 17:39:53 +0100 | [diff] [blame] | 102 | |