fix:(v2版本策略)1:AddPolicies参数说明

2:v2版本主动防御支持
3:添加主动防御测试用例
This commit is contained in:
wangxin
2020-06-16 16:52:32 +08:00
parent b6cd16e91c
commit 8a41c0112b
3 changed files with 42 additions and 0 deletions

View File

@@ -2,6 +2,7 @@
Test Teardown DeletePolicyAndObject ${policyIds} ${objectIds}
Resource ../../../02-Keyword/tsg_bfapi/PolicyObject.robot
Resource ../../../02-Keyword/tsg_bfapi/policy_object/Policy.robot
Resource ../../../02-Keyword/tsg_bfapi/Common.robot
*** Test Cases ***
Policy-Get-v1-00001
${policy} Create Dictionary policyType=tsg_security action=deny
@@ -122,4 +123,25 @@ Policy-Post-v2-00005
... destination=${objectId2}|TSG_FIELD_HTTP_URL
... isValid=${1} appIdObjects=2
${rescode} ${policyIds} AddPolicies 1 ${policy} v2
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}

View File

@@ -42,6 +42,21 @@ AddPolicies
... returnData是否返回数据这里需要设置为1
... policyList策略列表支持dict与list两种形式
... 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取而代之的是sourcedestinationfilterList
... 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}
Log To Console Call AddPolicies
${returnData}= Run Keyword If '${returnData}' == '${EMPTY}' Set Variable 1

View File

@@ -134,6 +134,11 @@ WxPolicyOrganize
${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} 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.Dumps ${policy} ensure_ascii=False
${json} Replace String ${json} "method:rst" ${userRegion}