feat:(策略验证)1.策略验证提交;2:Wx开头的关键字修改;

3:修复删除策略一行关键字名写错
This commit is contained in:
wangxin
2020-06-23 18:15:03 +08:00
parent c1326a0039
commit 2230c98d24
5 changed files with 263 additions and 55 deletions

View File

@@ -51,12 +51,12 @@ AddPolicies
#必选参数判定
Should Not Be Empty ${policyList}
${dictType} = Evaluate type(${policyList})
${body} Run Keyword If "${dictType}" == "<class 'list'>" WxPolicyListOperation ${returnData} ${policyList} add ${version}
... ELSE IF "${dictType}" == "<class 'dict'>" WxPolicyOperation ${returnData} ${policyList} add ${version}
${body} Run Keyword If "${dictType}" == "<class 'list'>" PolicyListDataOperation ${returnData} ${policyList} add ${version}
... ELSE IF "${dictType}" == "<class 'dict'>" PolicyDataOperation ${returnData} ${policyList} add ${version}
... ELSE Set Variable ${EMPTY}
#${body} Set Variable {"opAction":"add","policyList":{"policyName":"wx-test","policyType":"tsg_security","action":"deny","userTags":"","doBlacklist":0,"doLog":1,"policyDesc":"","effectiveRange":{"tag_sets":[[]]},"userRegion":{"protocol":"SSL","method":"drop"},"source":[{"objectId":3101,"protocolField":"TSG_SECURITY_SOURCE_ADDR"}],"destination":[],"filterList":[{"filter":[{"objectId":3404,"protocolField":"TSG_FIELD_SSL_CN"}]}],"appIdObjects":[3],"isValid":0,"scheduleId":[]}}
${response} BasePostRequestForV2 ${policyUrl} ${body} ${version}
${policyIds} Run Keyword If "${returnData}" == "1" WxGet-PolicyIds ${response}
${policyIds} Run Keyword If "${returnData}" == "1" Get-PolicyIds ${response}
... ELSE Create List
${rescode} Set Variable ${response['code']}
Should Be Equal As Strings ${rescode} 200
@@ -72,36 +72,32 @@ UpdatePolicies
#必选参数判定
Should Not Be Empty ${policyList}
${dictType} = Evaluate type(${policyList})
${body} Run Keyword If "${dictType}" == "<class 'list'>" WxPolicyListOperation ${returnData} ${policyList} ${opAction} ${version}
... ELSE IF "${dictType}" == "<class 'dict'>" WxPolicyOperation ${returnData} ${policyList} ${opAction} ${version}
${body} Run Keyword If "${dictType}" == "<class 'list'>" PolicyListDataOperation ${returnData} ${policyList} ${opAction} ${version}
... ELSE IF "${dictType}" == "<class 'dict'>" PolicyDataOperation ${returnData} ${policyList} ${opAction} ${version}
... ELSE Set Variable ${EMPTY}
${response} BaseEditRequestForV2 ${policyUrl} ${body} ${version}
${rescode} Set Variable ${response['code']}
Should Be Equal As Strings ${rescode} 200
[Return] ${rescode}
DeletePolicies
[Arguments] ${params}
${paramsType} Evaluate type(${params})
Run Keyword And Return If "${paramsType}" == "<class 'dict'>" DeletePoliciy ${params}
FOR ${param} IN @{params}
${rescode} WxDeletePolicy ${param}
END
[Return] ${rescode}
WxDeletePolicy
[Documentation]
... 删除策略
... params,传入的删除字典
... 结构为policyIds=${policyIds} (List) policyType=${policyType} (variable)
[Arguments] ${params}
${response} BaseDeleteRequest /${version}${policyUrl} ${params}
${rescode} Set Variable ${response['code']}
Should Be Equal As Strings ${rescode} 200
... params结构可为List或者dict
... dict结构
... dict data{'policyType':'tsg_security','policyIds':[1,2,3]}
... list 结构
... list data:[{'policyType':'tsg_security','policyIds':[1,2,3]},{'policyType':'pxy_manipulation','policyIds':[4,5,6]}]
[Arguments] ${params}
${paramsType} Evaluate type(${params})
Run Keyword And Return If "${paramsType}" == "<class 'dict'>" DeletePolicyWithParamDict ${params}
FOR ${param} IN @{params}
${rescode} DeletePolicyWithParamDict ${param}
END
[Return] ${rescode}
WxDeletePolicy1
DeletePolicy1
[Documentation]
... 与DeletePoliciy类似但是参数分开
... policyIds 策略id list
... policyType 策略类型
... policyIds 策略id list [1,2,3]
... policyType 策略类型 tsg_security等
[Arguments] ${policyIds} ${policyType}
${params} Create Dictionary policyIds=${policyIds} policyType=${policyType}
${response} BaseDeleteRequest /${version}${policyUrl} ${params}
@@ -127,6 +123,9 @@ ImportPolicy
ExportPolicy
[Documentation]
... 策略导出
... policyType tsg_security等
... policyIds 1,2,3
... policyName 字符串
[Arguments] ${policyType} ${policyIds} ${policyName}
Should Not Be Empty ${policyType}
${params} Create Dictionary policyType=${policyType}
@@ -141,4 +140,30 @@ WriteFile
${type} Evaluate type(${content})
${content} Run Keyword If "${type}" == "<class 'dict'>" json.Dumps ${content}
... ELSE Set Variable ${content}
Append To File ${path}/${filePath}/${fileName} ${content}
Append To File ${path}/${filePath}/${fileName} ${content}
VerifyPolicies
[Documentation]
... 策略验证
... 支持多个策略验证与单个策略验证
... 单个策略验证时verifyList 是一个dict
... 多个策略验证时是一个list
... atrributeValue字段可为三种格式
... 1:dict
... 2:json
... 3.字符串ip的value对应格式为clientIp|clientPort|serverIp|serverPort|addrType|protocol,注意addrType,protocol为数字
... signature 的value对应格式为district|string
... string的格式就是string
... 以上三种方式可以混合搭配使用
[Arguments] ${verifyList}
Log To Console Call VerifyPolicies
#必选参数判定
Should Not Be Empty ${verifyList}
${dictType} = Evaluate type(${verifyList})
${body} Run Keyword If "${dictType}" == "<class 'list'>" VerifyPolicyList ${verifyList}
... ELSE IF "${dictType}" == "<class 'dict'>" VerifyPolicyObj ${verifyList}
... ELSE Set Variable ${EMPTY}
${body} Set Variable {"verifyList":${body}}
${response} BasePostRequestForV2 /policy/verify ${body} ${version}
${rescode} Set Variable ${response['code']}
Should Be Equal As Strings ${rescode} 200
[Return] ${rescode} ${response['data']}