summaryrefslogtreecommitdiffstats
path: root/csit/common-library.robot
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2021-11-01 10:40:32 +0000
committeradheli.tavares <adheli.tavares@est.tech>2021-11-05 19:18:24 +0000
commit496b301c101f2a21e8408048dc0fd57c59a12d92 (patch)
treecc4761ab8dbe6c29caefd08391a2e06341fe29dd /csit/common-library.robot
parent6db3db236b6987af30a6fdb12ae6f9ea017c3856 (diff)
Rename username for API and PAP operations.
Use an account other than healthcheck in API and PAP for provisioning of policies. Issue-ID: POLICY-2744 Change-Id: Id2cbba8e5e5095996622572fbf42383bb854fb43 Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'csit/common-library.robot')
-rw-r--r--csit/common-library.robot116
1 files changed, 62 insertions, 54 deletions
diff --git a/csit/common-library.robot b/csit/common-library.robot
index 639d32a8..830d0f63 100644
--- a/csit/common-library.robot
+++ b/csit/common-library.robot
@@ -4,59 +4,18 @@ Library RequestsLibrary
Library OperatingSystem
Library json
-
*** Keywords ***
-CreatePolicy
- [Arguments] ${url} ${expectedstatus} ${postjson} ${policyname} ${policyversion}
- [Documentation] Create the specific policy
- ${resp}= PerformPostRequest ${POLICY_API_IP} ${url} ${expectedstatus} ${postjson} null
- 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}
+PolicyAdminAuth
+ ${policyadmin}= Create list policyadmin zb!XztG34
+ [return] ${policyadmin}
-QueryPdpGroups
- [Documentation] Verify pdp group query - supports upto 2 groups
- [Arguments] ${groupsLength} ${group1Name} ${group1State} ${policiesLengthInGroup1} ${group2Name} ${group2State} ${policiesLengthInGroup2}
- ${resp}= PerformGetRequest ${POLICY_PAP_IP} /policy/pap/v1/pdps 200 null
- Length Should Be ${resp.json()['groups']} ${groupsLength}
- Should Be Equal As Strings ${resp.json()['groups'][0]['name']} ${group1Name}
- Should Be Equal As Strings ${resp.json()['groups'][0]['pdpGroupState']} ${group1State}
- Length Should Be ${resp.json()['groups'][0]['pdpSubgroups'][0]['policies']} ${policiesLengthInGroup1}
- Run Keyword If ${groupsLength}>1 Should Be Equal As Strings ${resp.json()['groups'][1]['name']} ${group2Name}
- Run Keyword If ${groupsLength}>1 Should Be Equal As Strings ${resp.json()['groups'][1]['pdpGroupState']} ${group2State}
- Run Keyword If ${groupsLength}>1 Length Should Be ${resp.json()['groups'][1]['pdpSubgroups'][0]['policies']} ${policiesLengthInGroup2}
-
-QueryPolicyAudit
- [Arguments] ${url} ${expectedstatus} ${pdpGroup} ${pdpType} ${policyName} ${expectedAction}
- ${resp}= PerformGetRequest ${POLICY_PAP_IP} ${url} ${expectedstatus} recordCount=1
- Should Be Equal As Strings ${resp.json()[0]['pdpGroup']} ${pdpGroup}
- Should Be Equal As Strings ${resp.json()[0]['pdpType']} ${pdpType}
- Should Be Equal As Strings ${resp.json()[0]['policy']['name']} ${policyName}
- Should Be Equal As Strings ${resp.json()[0]['policy']['version']} 1.0.0
- Should Be Equal As Strings ${resp.json()[0]['action']} ${expectedAction}
- Should Be Equal As Strings ${resp.json()[0]['user']} healthcheck
-
-QueryPolicyStatus
- [Documentation] Verify policy deployment status
- [Arguments] ${policyName} ${pdpGroup} ${pdpType} ${pdpName} ${policyTypeName}
- ${resp}= PerformGetRequest ${POLICY_PAP_IP} /policy/pap/v1/policies/status 200 null
- FOR ${responseEntry} IN @{resp.json()}
- Exit For Loop IF '${responseEntry['policy']['name']}'=='${policyName}'
- END
- Should Be Equal As Strings ${resp.status_code} 200
- Should Be Equal As Strings ${responseEntry['pdpGroup']} ${pdpGroup}
- Should Be Equal As Strings ${responseEntry['pdpType']} ${pdpType}
- Should Be Equal As Strings ${responseEntry['pdpId']} ${pdpName}
- Should Be Equal As Strings ${responseEntry['policy']['name']} ${policyName}
- Should Be Equal As Strings ${responseEntry['policy']['version']} 1.0.0
- Should Be Equal As Strings ${responseEntry['policyType']['name']} ${policyTypeName}
- Should Be Equal As Strings ${responseEntry['policyType']['version']} 1.0.0
- Should Be Equal As Strings ${responseEntry['deploy']} True
- Should Be Equal As Strings ${responseEntry['state']} SUCCESS
+HealthCheckAuth
+ ${healthcheck}= Create list healthcheck zb!XztG34
+ [return] ${healthcheck}
PerformPostRequest
- [Arguments] ${hostname} ${url} ${expectedstatus} ${postjson} ${params}
- ${auth}= Create List healthcheck zb!XztG34
+ [Arguments] ${hostname} ${url} ${expectedstatus} ${postjson} ${params} ${auth}
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
@@ -65,8 +24,7 @@ PerformPostRequest
[return] ${resp}
PerformPutRequest
- [Arguments] ${hostname} ${url} ${expectedstatus} ${params}
- ${auth}= Create List healthcheck zb!XztG34
+ [Arguments] ${hostname} ${url} ${expectedstatus} ${params} ${auth}
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
@@ -75,8 +33,7 @@ PerformPutRequest
[return] ${resp}
PerformGetRequest
- [Arguments] ${hostname} ${url} ${expectedstatus} ${params}
- ${auth}= Create List healthcheck zb!XztG34
+ [Arguments] ${hostname} ${url} ${expectedstatus} ${params} ${auth}
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
@@ -85,10 +42,61 @@ PerformGetRequest
[return] ${resp}
PerformDeleteRequest
- [Arguments] ${hostname} ${url} ${expectedstatus}
- ${auth}= Create List healthcheck zb!XztG34
+ [Arguments] ${hostname} ${url} ${expectedstatus} ${auth}
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}= DELETE On Session policy ${url} headers=${headers} expected_status=${expectedstatus}
Log Received response from policy ${resp.text}
+
+CreatePolicy
+ [Arguments] ${url} ${expectedstatus} ${postjson} ${policyname} ${policyversion}
+ [Documentation] Create the specific policy
+ ${policyadmin}= PolicyAdminAuth
+ ${resp}= PerformPostRequest ${POLICY_API_IP} ${url} ${expectedstatus} ${postjson} null ${policyadmin}
+ 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}
+
+QueryPdpGroups
+ [Documentation] Verify pdp group query - supports upto 2 groups
+ [Arguments] ${groupsLength} ${group1Name} ${group1State} ${policiesLengthInGroup1} ${group2Name} ${group2State} ${policiesLengthInGroup2}
+ ${policyadmin}= PolicyAdminAuth
+ ${resp}= PerformGetRequest ${POLICY_PAP_IP} /policy/pap/v1/pdps 200 null ${policyadmin}
+ Length Should Be ${resp.json()['groups']} ${groupsLength}
+ Should Be Equal As Strings ${resp.json()['groups'][0]['name']} ${group1Name}
+ Should Be Equal As Strings ${resp.json()['groups'][0]['pdpGroupState']} ${group1State}
+ Length Should Be ${resp.json()['groups'][0]['pdpSubgroups'][0]['policies']} ${policiesLengthInGroup1}
+ Run Keyword If ${groupsLength}>1 Should Be Equal As Strings ${resp.json()['groups'][1]['name']} ${group2Name}
+ Run Keyword If ${groupsLength}>1 Should Be Equal As Strings ${resp.json()['groups'][1]['pdpGroupState']} ${group2State}
+ Run Keyword If ${groupsLength}>1 Length Should Be ${resp.json()['groups'][1]['pdpSubgroups'][0]['policies']} ${policiesLengthInGroup2}
+
+QueryPolicyAudit
+ [Arguments] ${url} ${expectedstatus} ${pdpGroup} ${pdpType} ${policyName} ${expectedAction}
+ ${policyadmin}= PolicyAdminAuth
+ ${resp}= PerformGetRequest ${POLICY_PAP_IP} ${url} ${expectedstatus} recordCount=1 ${policyadmin}
+ Should Be Equal As Strings ${resp.json()[0]['pdpGroup']} ${pdpGroup}
+ Should Be Equal As Strings ${resp.json()[0]['pdpType']} ${pdpType}
+ Should Be Equal As Strings ${resp.json()[0]['policy']['name']} ${policyName}
+ Should Be Equal As Strings ${resp.json()[0]['policy']['version']} 1.0.0
+ Should Be Equal As Strings ${resp.json()[0]['action']} ${expectedAction}
+ Should Be Equal As Strings ${resp.json()[0]['user']} policyadmin
+
+QueryPolicyStatus
+ [Documentation] Verify policy deployment status
+ [Arguments] ${policyName} ${pdpGroup} ${pdpType} ${pdpName} ${policyTypeName}
+ ${policyadmin}= PolicyAdminAuth
+ ${resp}= PerformGetRequest ${POLICY_PAP_IP} /policy/pap/v1/policies/status 200 null ${policyadmin}
+ FOR ${responseEntry} IN @{resp.json()}
+ Exit For Loop IF '${responseEntry['policy']['name']}'=='${policyName}'
+ END
+ Should Be Equal As Strings ${resp.status_code} 200
+ Should Be Equal As Strings ${responseEntry['pdpGroup']} ${pdpGroup}
+ Should Be Equal As Strings ${responseEntry['pdpType']} ${pdpType}
+ Should Be Equal As Strings ${responseEntry['pdpId']} ${pdpName}
+ Should Be Equal As Strings ${responseEntry['policy']['name']} ${policyName}
+ Should Be Equal As Strings ${responseEntry['policy']['version']} 1.0.0
+ Should Be Equal As Strings ${responseEntry['policyType']['name']} ${policyTypeName}
+ Should Be Equal As Strings ${responseEntry['policyType']['version']} 1.0.0
+ Should Be Equal As Strings ${responseEntry['deploy']} True
+ Should Be Equal As Strings ${responseEntry['state']} SUCCESS
+