feat:(策略删除逻辑)加入策略删除逻辑
This commit is contained in:
@@ -369,4 +369,60 @@ Policy-Post-v1-00015
|
||||
... addItemList=putty.com
|
||||
... updateItemList=${itemList}[0]
|
||||
... deleteItemIds=${itemIds}[1]
|
||||
${rescode} UpdateObjects ${1} ${objectDict} update
|
||||
${rescode} UpdateObjects ${1} ${objectDict} update
|
||||
Policy-Delete-v1-00016
|
||||
Comment 创建IP
|
||||
${objectDict} Create Dictionary objectType=ip isValid=${1}
|
||||
... isInitialize=0
|
||||
... addItemList=range|192.168.41.68|192.168.41.68|0/0
|
||||
${rescode} ${objectId1} AddObject2 ${1} ${objectDict}
|
||||
${objectIds} Set Variable ${objectId1}
|
||||
Log To Console Create IP Object1
|
||||
Comment 创建url
|
||||
${objectDict} Create Dictionary objectType=url isValid=${1} addItemList=*baidu.com
|
||||
${rescode} ${objectId3} AddObject2 ${1} ${objectDict}
|
||||
${objectIds} Set Variable ${objectId3},${objectIds}
|
||||
Log To Console Create url Object3
|
||||
|
||||
Comment 创建安全策略
|
||||
${policy} Create Dictionary policyName=WX_AddPolicy-v2-00011 policyType=tsg_security
|
||||
... policyDesc=wx-autotest
|
||||
... action=deny effectiveRange={}
|
||||
... userRegion={"protocol":"HTTP","method":"drop"}
|
||||
... source=${objectId1}|TSG_SECURITY_SOURCE_ADDR
|
||||
... destination=${objectId3}|TSG_FIELD_HTTP_URL
|
||||
... isValid=${1} appIdObjects=2
|
||||
${rescode} ${policyIds} AddPolicies 1 ${policy} v2
|
||||
Log ${rescode}
|
||||
Comment 删除安全策略
|
||||
${rescode} WxDeletePolicy1 ${policyIds[0]['policyIds']} tsg_security
|
||||
${policyIds} Create List
|
||||
Log ${rescode}
|
||||
Policy-Delete-v1-00017
|
||||
Comment 创建IP
|
||||
${objectDict} Create Dictionary objectType=ip isValid=${1}
|
||||
... isInitialize=0
|
||||
... addItemList=range|192.168.41.68|192.168.41.68|0/0
|
||||
${rescode} ${objectId1} AddObject2 ${1} ${objectDict}
|
||||
${objectIds} Set Variable ${objectId1}
|
||||
Log To Console Create IP Object1
|
||||
Comment 创建url
|
||||
${objectDict} Create Dictionary objectType=url isValid=${1} addItemList=*baidu.com
|
||||
${rescode} ${objectId3} AddObject2 ${1} ${objectDict}
|
||||
${objectIds} Set Variable ${objectId3},${objectIds}
|
||||
Log To Console Create url Object3
|
||||
|
||||
Comment 创建安全策略
|
||||
${policy} Create Dictionary policyName=WX_AddPolicy-v2-00011 policyType=tsg_security
|
||||
... policyDesc=wx-autotest
|
||||
... action=deny effectiveRange={}
|
||||
... userRegion={"protocol":"HTTP","method":"drop"}
|
||||
... source=${objectId1}|TSG_SECURITY_SOURCE_ADDR
|
||||
... destination=${objectId3}|TSG_FIELD_HTTP_URL
|
||||
... isValid=${1} appIdObjects=2
|
||||
${rescode} ${policyIds} AddPolicies 1 ${policy} v2
|
||||
Log ${rescode}
|
||||
Comment 删除安全策略
|
||||
${rescode} DeletePolicies ${policyIds}
|
||||
${policyIds} Create List
|
||||
Log ${rescode}
|
||||
@@ -7,7 +7,7 @@ Resource ProcessPolicyBody.robot
|
||||
Library Collections
|
||||
Resource ../Common.robot
|
||||
*** Variables ***
|
||||
${url} /policy/compile
|
||||
${policyUrl} /policy/compile
|
||||
*** Keywords ***
|
||||
#get查询策略,传入字典对象,该方法将字典对象自动拼接成get请求查询条件
|
||||
QueryPolicies
|
||||
@@ -17,7 +17,7 @@ QueryPolicies
|
||||
Log To Console Call QueryPolicies
|
||||
Dictionary Should Contain Key ${params} policyType
|
||||
${paramsStr} Dictionary-To-QueryParams ${params}
|
||||
${response} BaseGetRequestForV2 ${url} ${paramsStr} ${version}
|
||||
${response} BaseGetRequestForV2 ${policyUrl} ${paramsStr} ${version}
|
||||
${rescode} Set Variable ${response['code']}
|
||||
[Return] ${rescode} ${response}
|
||||
|
||||
@@ -55,13 +55,16 @@ AddPolicies
|
||||
... ELSE IF "${dictType}" == "<class 'dict'>" WxPolicyOperation ${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 ${url} ${body} ${version}
|
||||
${response} BasePostRequestForV2 ${policyUrl} ${body} ${version}
|
||||
${policyIds} Run Keyword If "${returnData}" == "1" WxGet-PolicyIds ${response}
|
||||
... ELSE Create List
|
||||
${rescode} Set Variable ${response['code']}
|
||||
Should Be Equal As Strings ${rescode} 200
|
||||
[Return] ${rescode} ${policyIds}
|
||||
UpdatePolicies
|
||||
[Documentation]
|
||||
... 与新增类似,update多一个参数opAction
|
||||
... opAction可为update,enable,disable
|
||||
[Arguments] ${returnData} ${policyList} ${version} ${opAction}
|
||||
Log To Console Call UpdatePolicies
|
||||
${returnData}= Run Keyword If '${returnData}' == '${EMPTY}' Set Variable 1
|
||||
@@ -72,7 +75,36 @@ UpdatePolicies
|
||||
${body} Run Keyword If "${dictType}" == "<class 'list'>" WxPolicyListOperation ${returnData} ${policyList} ${opAction} ${version}
|
||||
... ELSE IF "${dictType}" == "<class 'dict'>" WxPolicyOperation ${returnData} ${policyList} ${opAction} ${version}
|
||||
... ELSE Set Variable ${EMPTY}
|
||||
${response} BaseEditRequestForV2 ${url} ${body} ${version}
|
||||
${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
|
||||
[Return] ${rescode}
|
||||
WxDeletePolicy1
|
||||
[Documentation]
|
||||
... 与DeletePoliciy类似,但是参数分开
|
||||
... policyIds 策略id list
|
||||
... policyType 策略类型
|
||||
[Arguments] ${policyIds} ${policyType}
|
||||
${params} Create Dictionary policyIds=${policyIds} policyType=${policyType}
|
||||
${response} BaseDeleteRequest /${version}${policyUrl} ${params}
|
||||
${rescode} Set Variable ${response['code']}
|
||||
Should Be Equal As Strings ${rescode} 200
|
||||
[Return] ${rescode}
|
||||
Reference in New Issue
Block a user