fix:(v2版本策略)1:AddPolicies参数说明
2:v2版本主动防御支持 3:添加主动防御测试用例
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
Test Teardown DeletePolicyAndObject ${policyIds} ${objectIds}
|
Test Teardown DeletePolicyAndObject ${policyIds} ${objectIds}
|
||||||
Resource ../../../02-Keyword/tsg_bfapi/PolicyObject.robot
|
Resource ../../../02-Keyword/tsg_bfapi/PolicyObject.robot
|
||||||
Resource ../../../02-Keyword/tsg_bfapi/policy_object/Policy.robot
|
Resource ../../../02-Keyword/tsg_bfapi/policy_object/Policy.robot
|
||||||
|
Resource ../../../02-Keyword/tsg_bfapi/Common.robot
|
||||||
*** Test Cases ***
|
*** Test Cases ***
|
||||||
Policy-Get-v1-00001
|
Policy-Get-v1-00001
|
||||||
${policy} Create Dictionary policyType=tsg_security action=deny
|
${policy} Create Dictionary policyType=tsg_security action=deny
|
||||||
@@ -123,3 +124,24 @@ Policy-Post-v2-00005
|
|||||||
... isValid=${1} appIdObjects=2
|
... isValid=${1} appIdObjects=2
|
||||||
${rescode} ${policyIds} AddPolicies 1 ${policy} v2
|
${rescode} ${policyIds} AddPolicies 1 ${policy} v2
|
||||||
Log ${rescode} ${policyIds} ${objectIds}
|
Log ${rescode} ${policyIds} ${objectIds}
|
||||||
|
Policy-Post-v2-00006
|
||||||
|
[Tags] reflection
|
||||||
|
${caseName} set variable WX_ActiveDefencePolicy-Reflection-V2-00006
|
||||||
|
${target_ip} set variable 10.3.22.139
|
||||||
|
Comment claimed_src_ip_profile_id
|
||||||
|
${response} BasePostRequest /policy/profile/reflector body={"opAction":"add","returnData":1,"reflectorList":[{"profileName":"autotest","addrType":4,"ipList":["10.3.22.11"],"reflectorType":"dns","isValid":1,"profileDesc":"autotest"}]}
|
||||||
|
${reflector_profile_id} Set Variable ${response['data']['list'][0]['profileId']}
|
||||||
|
${response} BasePostRequest /policy/profile/reflector/payload body={"opAction":"add","returnData":1,"reflectorList":[{"profileName":"autotest","reflectorType":"dns","payload":"zasBAAABAAAAAAAABHRlc3QDY29tAAD/AAE=","isValid":1,"profileDesc":""}]}
|
||||||
|
#${response} BasePostRequest /policy/profile/reflector/payload body={"opAction":"add","returnData":1,"reflectorList":[{"profileName":"autotest","reflectorPayload":"dns","payload":"zasBAAABAAAAAAAABHRlc3QDY29tAAD/AAE=","isValid":1,"profileDesc":""}]}
|
||||||
|
${payload_profile_id} Set Variable ${response['data']['list'][0]['profileId']}
|
||||||
|
Comment 创建策略reflection
|
||||||
|
${policyDict} Create Dictionary
|
||||||
|
... policyName=${caseName}
|
||||||
|
... policyType=active_defence
|
||||||
|
... policyDesc=${caseName}
|
||||||
|
... action=activeDefence
|
||||||
|
... userRegion={"method":"reflection","reflector_type":"DNS","target_ip":"${target_ip}","target_port":1234,"rate_pps":1,"payload_profile_id":${payload_profile_id},"reflector_profile_id":${reflector_profile_id}}
|
||||||
|
... isValid=1
|
||||||
|
${rescode} ${policyIds} AddPolicies 1 ${policyDict} v2
|
||||||
|
${objectIds} Set Variable ${EMPTY}
|
||||||
|
Log ${rescode} ${policyIds} ${objectIds}
|
||||||
@@ -42,6 +42,21 @@ AddPolicies
|
|||||||
... returnData:是否返回数据,这里需要设置为1
|
... returnData:是否返回数据,这里需要设置为1
|
||||||
... policyList:策略列表,支持dict与list两种形式
|
... policyList:策略列表,支持dict与list两种形式
|
||||||
... version:接口版本号
|
... version:接口版本号
|
||||||
|
... 支持v1版本接口与v2版本接口
|
||||||
|
... v1版本特殊参数说明:
|
||||||
|
... referenceObject=${265}|TSG_FIELD_HTTP_HOST,${266}|TSG_FIELD_SSL_SNI&TSG_FIELD_SSL_SAN
|
||||||
|
... 为字符串类型,每条引用的策略对象信息以','分隔
|
||||||
|
... [objectId]|[protocolFileds],... ,多个protocolFileds用'&'连接
|
||||||
|
... appObjectIdArray==${2},${3}
|
||||||
|
... 为字符串类型,以','分隔
|
||||||
|
... v2版本特殊参数说明:
|
||||||
|
... v2版本中无referenceObject,取而代之的是source,destination,filterList
|
||||||
|
... source= ${265}|TSG_FIELD_HTTP_HOST,${266}|TSG_FIELD_SSL_SNI&TSG_FIELD_SSL_SAN
|
||||||
|
... destination= ${265}|TSG_FIELD_HTTP_HOST,${266}|TSG_FIELD_SSL_SNI&TSG_FIELD_SSL_SAN
|
||||||
|
... filterList= ${265}|${257}:TSG_FIELD_HTTP_HOST,${266}|${299}:TSG_FIELD_SSL_SNI&TSG_FIELD_SSL_SAN
|
||||||
|
... filterList由多个数字用‘|’分隔,加上:对上对应的protocolFiled,
|
||||||
|
... 一个filter中的protocolFiled是确定的,一个protocolFiled对应多个objectId
|
||||||
|
... appIdObjects==${2},${3}
|
||||||
[Arguments] ${returnData} ${policyList} ${version}
|
[Arguments] ${returnData} ${policyList} ${version}
|
||||||
Log To Console Call AddPolicies
|
Log To Console Call AddPolicies
|
||||||
${returnData}= Run Keyword If '${returnData}' == '${EMPTY}' Set Variable 1
|
${returnData}= Run Keyword If '${returnData}' == '${EMPTY}' Set Variable 1
|
||||||
|
|||||||
@@ -134,6 +134,11 @@ WxPolicyOrganize
|
|||||||
${return} ${policyType} Run Keyword And Ignore Error Set Variable ${policy}[policyType]
|
${return} ${policyType} Run Keyword And Ignore Error Set Variable ${policy}[policyType]
|
||||||
Run Keyword If "${policyObjectVersion}"=="v1" and "${policyType}"=="active_defence" Set To Dictionary ${policy} referenceObject=${active_defence_emptyList}
|
Run Keyword If "${policyObjectVersion}"=="v1" and "${policyType}"=="active_defence" Set To Dictionary ${policy} referenceObject=${active_defence_emptyList}
|
||||||
Run Keyword If "${policyObjectVersion}"=="v1" and "${policyType}"=="active_defence" Set To Dictionary ${policy} appObjectIdArray=${active_defence_emptyList}
|
Run Keyword If "${policyObjectVersion}"=="v1" and "${policyType}"=="active_defence" Set To Dictionary ${policy} appObjectIdArray=${active_defence_emptyList}
|
||||||
|
#v版本主动防御
|
||||||
|
Run Keyword If "${policyObjectVersion}"=="v2" and "${policyType}"=="active_defence" Set To Dictionary ${policy} source=${active_defence_emptyList}
|
||||||
|
Run Keyword If "${policyObjectVersion}"=="v2" and "${policyType}"=="active_defence" Set To Dictionary ${policy} destination=${active_defence_emptyList}
|
||||||
|
Run Keyword If "${policyObjectVersion}"=="v2" and "${policyType}"=="active_defence" Set To Dictionary ${policy} filterList=${active_defence_emptyList}
|
||||||
|
Run Keyword If "${policyObjectVersion}"=="v2" and "${policyType}"=="active_defence" Set To Dictionary ${policy} appIdObjects=${active_defence_emptyList}
|
||||||
# 转为json结构并返回
|
# 转为json结构并返回
|
||||||
${json} json.Dumps ${policy} ensure_ascii=False
|
${json} json.Dumps ${policy} ensure_ascii=False
|
||||||
${json} Replace String ${json} "method:rst" ${userRegion}
|
${json} Replace String ${json} "method:rst" ${userRegion}
|
||||||
|
|||||||
Reference in New Issue
Block a user