blob: 95831b0d51a0f150bfbaa265ed4dc2ff70e03616 [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
liamfallon8d3f1292022-10-18 14:04:06 +010014 ${healthcheck}= Create list policyadmin zb!XztG34
adheli.tavares496b3012021-11-01 10:40:32 +000015 [return] ${healthcheck}
16
17PerformPostRequest
18 [Arguments] ${hostname} ${url} ${expectedstatus} ${postjson} ${params} ${auth}
liamfallonfaac45b2022-09-01 12:05:47 +010019 Log Creating session http://${hostname}:6969
20 ${session}= Create Session policy http://${hostname}:6969 auth=${auth}
adheli.tavares496b3012021-11-01 10:40:32 +000021 ${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}
liamfallonfaac45b2022-09-01 12:05:47 +010028 Log Creating session http://${hostname}:6969
29 ${session}= Create Session policy http://${hostname}:6969 auth=${auth}
adheli.tavares496b3012021-11-01 10:40:32 +000030 ${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}
liamfallonfaac45b2022-09-01 12:05:47 +010037 Log Creating session http://${hostname}:6969
38 ${session}= Create Session policy http://${hostname}:6969 auth=${auth}
adheli.tavares496b3012021-11-01 10:40:32 +000039 ${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}
liamfallonfaac45b2022-09-01 12:05:47 +010046 Log Creating session http://${hostname}:6969
47 ${session}= Create Session policy http://${hostname}:6969 auth=${auth}
adheli.tavares496b3012021-11-01 10:40:32 +000048 ${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
rameshiyer27a8be1f72022-03-16 10:36:33 +000060CreateNodeTemplate
61 [Arguments] ${url} ${expectedstatus} ${postjson} ${nodeTemplateListLength}
62 [Documentation] Create the node templates
63 ${policyadmin}= PolicyAdminAuth
64 ${resp}= PerformPostRequest ${POLICY_API_IP} ${url} ${expectedstatus} ${postjson} \ ${policyadmin}
65 Run Keyword If ${expectedstatus}==200 Length Should Be ${resp.json()['topology_template']['node_templates']} ${nodeTemplateListLength}
66
67
a.sreekumar60d6a082021-08-20 17:39:53 +010068QueryPdpGroups
69 [Documentation] Verify pdp group query - supports upto 2 groups
70 [Arguments] ${groupsLength} ${group1Name} ${group1State} ${policiesLengthInGroup1} ${group2Name} ${group2State} ${policiesLengthInGroup2}
adheli.tavares496b3012021-11-01 10:40:32 +000071 ${policyadmin}= PolicyAdminAuth
72 ${resp}= PerformGetRequest ${POLICY_PAP_IP} /policy/pap/v1/pdps 200 null ${policyadmin}
a.sreekumar60d6a082021-08-20 17:39:53 +010073 Length Should Be ${resp.json()['groups']} ${groupsLength}
74 Should Be Equal As Strings ${resp.json()['groups'][0]['name']} ${group1Name}
75 Should Be Equal As Strings ${resp.json()['groups'][0]['pdpGroupState']} ${group1State}
76 Length Should Be ${resp.json()['groups'][0]['pdpSubgroups'][0]['policies']} ${policiesLengthInGroup1}
77 Run Keyword If ${groupsLength}>1 Should Be Equal As Strings ${resp.json()['groups'][1]['name']} ${group2Name}
78 Run Keyword If ${groupsLength}>1 Should Be Equal As Strings ${resp.json()['groups'][1]['pdpGroupState']} ${group2State}
79 Run Keyword If ${groupsLength}>1 Length Should Be ${resp.json()['groups'][1]['pdpSubgroups'][0]['policies']} ${policiesLengthInGroup2}
80
81QueryPolicyAudit
82 [Arguments] ${url} ${expectedstatus} ${pdpGroup} ${pdpType} ${policyName} ${expectedAction}
adheli.tavares496b3012021-11-01 10:40:32 +000083 ${policyadmin}= PolicyAdminAuth
rameshiyer27a8be1f72022-03-16 10:36:33 +000084 ${resp}= PerformGetRequest ${POLICY_PAP_IP} ${url} ${expectedstatus} recordCount=2 ${policyadmin}
85 Log Received response from queryPolicyAudit ${resp.text}
86 FOR ${responseEntry} IN @{resp.json()}
87 Exit For Loop IF '${responseEntry['policy']['name']}'=='${policyName}'
88 END
89 Should Be Equal As Strings ${responseEntry['pdpGroup']} ${pdpGroup}
90 Should Be Equal As Strings ${responseEntry['pdpType']} ${pdpType}
91 Should Be Equal As Strings ${responseEntry['policy']['name']} ${policyName}
92 Should Be Equal As Strings ${responseEntry['policy']['version']} 1.0.0
93 Should Be Equal As Strings ${responseEntry['action']} ${expectedAction}
94 Should Be Equal As Strings ${responseEntry['user']} policyadmin
a.sreekumar60d6a082021-08-20 17:39:53 +010095
96QueryPolicyStatus
adheli.tavares496b3012021-11-01 10:40:32 +000097 [Documentation] Verify policy deployment status
98 [Arguments] ${policyName} ${pdpGroup} ${pdpType} ${pdpName} ${policyTypeName}
99 ${policyadmin}= PolicyAdminAuth
100 ${resp}= PerformGetRequest ${POLICY_PAP_IP} /policy/pap/v1/policies/status 200 null ${policyadmin}
101 FOR ${responseEntry} IN @{resp.json()}
102 Exit For Loop IF '${responseEntry['policy']['name']}'=='${policyName}'
103 END
104 Should Be Equal As Strings ${resp.status_code} 200
105 Should Be Equal As Strings ${responseEntry['pdpGroup']} ${pdpGroup}
106 Should Be Equal As Strings ${responseEntry['pdpType']} ${pdpType}
107 Should Be Equal As Strings ${responseEntry['pdpId']} ${pdpName}
108 Should Be Equal As Strings ${responseEntry['policy']['name']} ${policyName}
109 Should Be Equal As Strings ${responseEntry['policy']['version']} 1.0.0
110 Should Be Equal As Strings ${responseEntry['policyType']['name']} ${policyTypeName}
111 Should Be Equal As Strings ${responseEntry['policyType']['version']} 1.0.0
112 Should Be Equal As Strings ${responseEntry['deploy']} True
113 Should Be Equal As Strings ${responseEntry['state']} SUCCESS
a.sreekumar60d6a082021-08-20 17:39:53 +0100114
a.sreekumar67f7bd92022-02-14 13:51:34 +0000115GetMetrics
liamfallonc49f64d2023-01-19 15:30:30 +0000116 [Arguments] ${hostname} ${auth} ${context_path}
liamfallonfaac45b2022-09-01 12:05:47 +0100117 Log Creating session http://${hostname}:6969
118 ${session}= Create Session policy http://${hostname}:6969 auth=${auth}
liamfallonc49f64d2023-01-19 15:30:30 +0000119 ${resp}= GET On Session policy ${context_path}metrics expected_status=200
a.sreekumar67f7bd92022-02-14 13:51:34 +0000120 Log Received response from policy ${resp.text}
121 [return] ${resp}