feat:(策略对象新增修改)1:策略对象支持多个同时新增/修改

2.策略对象修改支持addItemList,updateItemList,deleteItemIds
3.策略对象支持enable,disable,只需要传入objectId,objectType
This commit is contained in:
wangxin
2020-06-18 16:29:17 +08:00
parent e8bab7c328
commit 19ed4e3d4a
5 changed files with 380 additions and 16 deletions

View File

@@ -2,8 +2,11 @@
Test Teardown DeletePolicyAndObjectAndProfile ${policyIds} ${objectIds} ${profiles}
Resource ../../../02-Keyword/tsg_bfapi/PolicyObject.robot
Resource ../../../02-Keyword/tsg_bfapi/policy_object/Policy.robot
Resource ../../../02-Keyword/tsg_bfapi/policy_object/Object.robot
Resource ../../../02-Keyword/tsg_bfapi/Common.robot
Library json
*** Variables ***
@{policyIds}
@{profiles}
*** Test Cases ***
Policy-Get-v1-00001
@@ -252,4 +255,118 @@ Policy-Post-v2-00009
${updatePolicyId} Set Variable ${policyIds}[0][policyIds][0]
Comment 更新安全策略
Set To Dictionary ${policy1} policyId=${updatePolicyId}
${rescode} UpdatePolicies 1 ${policy1} v2 enable
${rescode} UpdatePolicies 1 ${policy1} v2 enable
Policy-Post-v2-00010
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-00010 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=${0} appIdObjects=2
${rescode} ${policyIds} AddPolicies 1 ${policy} v2
Log ${rescode}
${updatePolicyId} Set Variable ${policyIds}[0][policyIds][0]
Comment 更新安全策略
${policy} Create Dictionary policyId=${updatePolicyId}
${rescode} UpdatePolicies 1 ${policy} v2 enable
Policy-Post-v2-00011
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}
${updatePolicyId} Set Variable ${policyIds}[0][policyIds][0]
Comment 更新安全策略
${policy} Create Dictionary policyId=${updatePolicyId}
${rescode} UpdatePolicies 1 ${policy} v2 disable
Policy-Post-v1-00012
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} AddObjects ${1} ${objectDict}
${objectIds} Set Variable ${objectId1}
Log To Console Create IP Object
Comment 更新IP
${objectDict} Create Dictionary objectId=${objectId1} objectType=ip
${rescode} UpdateObjects ${1} ${objectDict} disable
Log To Console Create IP Object
Policy-Post-v1-00013
Comment 创建IP
${objectDict} Create Dictionary objectType=ip isValid=${0}
... isInitialize=0
... addItemList=range|192.168.41.68|192.168.41.68|0/0
${rescode} ${objectId1} AddObjects ${1} ${objectDict}
${objectIds} Set Variable ${objectId1}
Log To Console Create IP Object
${params} Create Dictionary objectId=${objectId1} itemType=ip
${rescode} ${itemIds} ${itemList} GetObjectItems ${params}
Log To Console ${itemIds}
Comment 更新IP
${len} Get Length ${itemList}
FOR ${index} IN ${len}
${index1} Evaluate int(${index})-1
Set To Dictionary ${itemList}[${index1}] clientIp1 192.168.41.67
Set To Dictionary ${itemList}[${index1}] clientIp2 192.168.41.67
Remove From Dictionary ${itemList}[${index1}] isInitialize
Set To Dictionary ${itemList}[${index1}] serverIp1 192.168.41.68
Set To Dictionary ${itemList}[${index1}] serverIp2 192.168.41.68
END
${objectDict} Create Dictionary objectId=${objectId1} objectType=ip
... updateItemList=${itemList}
${rescode} UpdateObjects ${1} ${objectDict} update
Log To Console Create IP Object
Policy-Post-v1-00014
Comment 创建urls
${objectDict1} Create Dictionary objectType=url isValid=${1} addItemList=*baidu.com,
${objectDict2} Create Dictionary objectType=url isValid=${1} addItemList=*google.com
${objectDict} Create List ${objectDict1} ${objectDict2}
${rescode} ${objectIds} AddObjects ${1} ${objectDict}
Policy-Post-v1-00015
Comment 创建urls
${objectDict1} Create Dictionary objectType=url isValid=${1} addItemList=*baidu.com,*google.com
${rescode} ${objectIds} AddObjects ${1} ${objectDict1}
${params} Create Dictionary objectId=${objectIds} itemType=url
${rescode} ${itemIds} ${itemList} GetObjectItems ${params}
Log To Console ${itemIds}
Comment 修改urls
${updateList} Create List *baidu.com* *baidu1.com*
Set To Dictionary ${itemList}[0] keywordArray ${updateList}
${objectDict} Create Dictionary objectId=${objectIds} objectType=url
... addItemList=putty.com
... updateItemList=${itemList}[0]
... deleteItemIds=${itemIds}[1]
${rescode} UpdateObjects ${1} ${objectDict} update