blob: 830d0f6338f926f1fa6b443687f5e181de252692 [file] [log] [blame]
a.sreekumar60d6a082021-08-20 17:39:53 +01001*** Settings ***
2Library Collections
3Library RequestsLibrary
4Library OperatingSystem
5Library json
6
a.sreekumar60d6a082021-08-20 17:39:53 +01007*** Keywords ***
8
adheli.tavares496b3012021-11-01 10:40:32 +00009PolicyAdminAuth
10 ${policyadmin}= Create list policyadmin zb!XztG34
11 [return] ${policyadmin}
12
13HealthCheckAuth
14 ${healthcheck}= Create list healthcheck zb!XztG34
15 [return] ${healthcheck}
16
17PerformPostRequest
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
26PerformPutRequest
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
35PerformGetRequest
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
44PerformDeleteRequest
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.sreekumar60d6a082021-08-20 17:39:53 +010052CreatePolicy
53 [Arguments] ${url} ${expectedstatus} ${postjson} ${policyname} ${policyversion}
54 [Documentation] Create the specific policy
adheli.tavares496b3012021-11-01 10:40:32 +000055 ${policyadmin}= PolicyAdminAuth
56 ${resp}= PerformPostRequest ${POLICY_API_IP} ${url} ${expectedstatus} ${postjson} null ${policyadmin}
a.sreekumar60d6a082021-08-20 17:39:53 +010057 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
60QueryPdpGroups
61 [Documentation] Verify pdp group query - supports upto 2 groups
62 [Arguments] ${groupsLength} ${group1Name} ${group1State} ${policiesLengthInGroup1} ${group2Name} ${group2State} ${policiesLengthInGroup2}
adheli.tavares496b3012021-11-01 10:40:32 +000063 ${policyadmin}= PolicyAdminAuth
64 ${resp}= PerformGetRequest ${POLICY_PAP_IP} /policy/pap/v1/pdps 200 null ${policyadmin}
a.sreekumar60d6a082021-08-20 17:39:53 +010065 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
73QueryPolicyAudit
74 [Arguments] ${url} ${expectedstatus} ${pdpGroup} ${pdpType} ${policyName} ${expectedAction}
adheli.tavares496b3012021-11-01 10:40:32 +000075 ${policyadmin}= PolicyAdminAuth
76 ${resp}= PerformGetRequest ${POLICY_PAP_IP} ${url} ${expectedstatus} recordCount=1 ${policyadmin}
a.sreekumar60d6a082021-08-20 17:39:53 +010077 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.tavares496b3012021-11-01 10:40:32 +000082 Should Be Equal As Strings ${resp.json()[0]['user']} policyadmin
a.sreekumar60d6a082021-08-20 17:39:53 +010083
84QueryPolicyStatus
adheli.tavares496b3012021-11-01 10:40:32 +000085 [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.sreekumar60d6a082021-08-20 17:39:53 +0100102