diff --git a/01-TestCase/tsg_bfapi/policy_object/PolicyObjectTests.robot b/01-TestCase/tsg_bfapi/policy_object/PolicyObjectTests.robot index f5824c4..c36b437 100644 --- a/01-TestCase/tsg_bfapi/policy_object/PolicyObjectTests.robot +++ b/01-TestCase/tsg_bfapi/policy_object/PolicyObjectTests.robot @@ -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} \ No newline at end of file diff --git a/02-Keyword/tsg_bfapi/policy_object/Policy.robot b/02-Keyword/tsg_bfapi/policy_object/Policy.robot index 7eac1ab..3a9225b 100644 --- a/02-Keyword/tsg_bfapi/policy_object/Policy.robot +++ b/02-Keyword/tsg_bfapi/policy_object/Policy.robot @@ -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,取而代之的是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} Log To Console Call AddPolicies ${returnData}= Run Keyword If '${returnData}' == '${EMPTY}' Set Variable 1 diff --git a/02-Keyword/tsg_bfapi/policy_object/ProcessPolicyBody.robot b/02-Keyword/tsg_bfapi/policy_object/ProcessPolicyBody.robot index 0d1f422..261094f 100644 --- a/02-Keyword/tsg_bfapi/policy_object/ProcessPolicyBody.robot +++ b/02-Keyword/tsg_bfapi/policy_object/ProcessPolicyBody.robot @@ -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}