2020-04-24 18:44:07 +08:00
|
|
|
|
*** Settings ***
|
|
|
|
|
|
Test Teardown DeletePolicyAndObject ${policyIds} ${objectids}
|
|
|
|
|
|
Force Tags zjj Security_Policy Active_Defence_Policy
|
|
|
|
|
|
Library OperatingSystem
|
|
|
|
|
|
Resource ../../02-Keyword/tsg_adc/SystemCommand.robot
|
|
|
|
|
|
Resource ../../02-Keyword/tsg_bfapi/PolicyObject.robot
|
|
|
|
|
|
Resource ../../02-Keyword/tsg_bfapi/LogVariable.robot
|
|
|
|
|
|
Resource ../../03-Variable/PolicyObjectDefault.txt
|
|
|
|
|
|
Resource ../../02-Keyword/tsg_common/StmpHandle.robot
|
|
|
|
|
|
Resource ../../03-Variable/BifangApiVariable.txt
|
|
|
|
|
|
Resource ../../02-Keyword/tsg_bfapi/Common.robot
|
|
|
|
|
|
Library Custometest
|
|
|
|
|
|
Library json
|
|
|
|
|
|
|
|
|
|
|
|
*** Variables ***
|
|
|
|
|
|
${policyIds} ${EMPTY}
|
|
|
|
|
|
${objectids} ${EMPTY}
|
|
|
|
|
|
${url} /policy/profile/responsepages
|
|
|
|
|
|
${profiledId} ${EMPTY}
|
2020-06-11 09:26:43 +08:00
|
|
|
|
${target_ip} 10.3.22.139
|
2020-04-24 18:44:07 +08:00
|
|
|
|
# 无DHCP,需要手动设置IP,可用地址段: 10.3.22.[129-254], 掩码: 255.255.255.0, DNS服务器: 10.3.22.11。
|
|
|
|
|
|
*** Test Cases ***
|
|
|
|
|
|
ZDFY_ActiveDefencePolicy-Flood-00001
|
|
|
|
|
|
[Tags] flood
|
|
|
|
|
|
|
|
|
|
|
|
${caseName} set variable ZDFY_ActiveDefencePolicy-Flood-00001
|
|
|
|
|
|
Comment claimed_src_ip_profile_id
|
2020-04-28 17:03:28 +08:00
|
|
|
|
${response} BasePostRequest /policy/profile/claimedsrcip body={"opAction":"add","returnData":1,"claimedSrcIpList":[{"profileName":"autotest","addrType":4,"ipList":["10.3.22.0/25"],"isValid":1,"profileDesc":"autotest"}]}
|
2020-04-24 18:44:07 +08:00
|
|
|
|
${claimed_src_ip_profile_id} Set Variable ${response['data']['list'][0]['profileId']}
|
|
|
|
|
|
|
|
|
|
|
|
Comment 创建带主动策略Flood
|
|
|
|
|
|
${policyDict} Create Dictionary
|
|
|
|
|
|
... policyName=${caseName}
|
|
|
|
|
|
... policyType=active_defence
|
|
|
|
|
|
... policyDesc=${caseName}
|
|
|
|
|
|
... action=activeDefence
|
|
|
|
|
|
... effectiveRange=${Default_EffectiveRange}
|
|
|
|
|
|
... userRegion={"method":"flood","l4_protocol":"TCP","target_ip":"${target_ip}","target_port":1234,"rate_pps":1,"claimed_src_ip_profile_id":${claimed_src_ip_profile_id}}
|
|
|
|
|
|
... referenceObject=
|
|
|
|
|
|
... isValid=1
|
|
|
|
|
|
... appObjectIdArray=${2}
|
|
|
|
|
|
... userTags=${Default_UserTags}
|
|
|
|
|
|
... doLog=${Default_DoLog}
|
|
|
|
|
|
${rescode} ${policyId} AddPolicy2 ${1} ${policyDict}
|
|
|
|
|
|
${s} Convert to String ${policyId}
|
|
|
|
|
|
${policyIds} Create List {"policyType":"active_defence","policyIds":[${policyId}]}
|
2020-04-28 17:03:28 +08:00
|
|
|
|
ZDFY_ActiveDefencePolicy-Flood-00002
|
2020-06-11 09:26:43 +08:00
|
|
|
|
[Tags] flood
|
2020-04-28 17:03:28 +08:00
|
|
|
|
|
|
|
|
|
|
${caseName} set variable ZDFY_ActiveDefencePolicy-Flood-00002
|
|
|
|
|
|
Comment claimed_src_ip_profile_id
|
|
|
|
|
|
${response} BasePostRequest /policy/profile/claimedsrcip body={"opAction":"add","returnData":1,"claimedSrcIpList":[{"profileName":"autotest","addrType":4,"ipList":["10.3.22.0/25"],"isValid":1,"profileDesc":"autotest"}]}
|
|
|
|
|
|
${claimed_src_ip_profile_id} Set Variable ${response['data']['list'][0]['profileId']}
|
|
|
|
|
|
|
2020-06-11 09:26:43 +08:00
|
|
|
|
Comment 创建带主动策略Flood
|
|
|
|
|
|
${policyDict} Create Dictionary
|
|
|
|
|
|
... policyName=${caseName}
|
|
|
|
|
|
... policyType=active_defence
|
|
|
|
|
|
... policyDesc=${caseName}
|
|
|
|
|
|
... action=activeDefence
|
|
|
|
|
|
... effectiveRange=${Default_EffectiveRange}
|
|
|
|
|
|
... userRegion={"method":"flood","l4_protocol":"UDP","target_ip":"${target_ip}","target_port":1234,"rate_pps":1,"claimed_src_ip_profile_id":${claimed_src_ip_profile_id}}
|
|
|
|
|
|
... referenceObject=
|
|
|
|
|
|
... isValid=1
|
|
|
|
|
|
... appObjectIdArray=${2}
|
|
|
|
|
|
... userTags=${Default_UserTags}
|
|
|
|
|
|
... doLog=${Default_DoLog}
|
|
|
|
|
|
${rescode} ${policyId} AddPolicy2 ${1} ${policyDict}
|
|
|
|
|
|
${s} Convert to String ${policyId}
|
|
|
|
|
|
${policyIds} Create List {"policyType":"active_defence","policyIds":[${policyId}]}
|
|
|
|
|
|
ZDFY_ActiveDefencePolicy-Flood-00003
|
|
|
|
|
|
[Tags] flood TwoPolicyOneprofile
|
|
|
|
|
|
|
|
|
|
|
|
${caseName} set variable ZDFY_ActiveDefencePolicy-Flood-00003
|
|
|
|
|
|
Comment claimed_src_ip_profile_id
|
|
|
|
|
|
${response} BasePostRequest /policy/profile/claimedsrcip body={"opAction":"add","returnData":1,"claimedSrcIpList":[{"profileName":"autotest","addrType":4,"ipList":["10.3.22.0/25"],"isValid":1,"profileDesc":"autotest"}]}
|
|
|
|
|
|
${claimed_src_ip_profile_id} Set Variable ${response['data']['list'][0]['profileId']}
|
|
|
|
|
|
|
2020-04-28 17:03:28 +08:00
|
|
|
|
Comment 创建带主动策略Flood
|
|
|
|
|
|
${policyDict} Create Dictionary
|
|
|
|
|
|
... policyName=${caseName}
|
|
|
|
|
|
... policyType=active_defence
|
|
|
|
|
|
... policyDesc=${caseName}
|
|
|
|
|
|
... action=activeDefence
|
|
|
|
|
|
... effectiveRange=${Default_EffectiveRange}
|
|
|
|
|
|
... userRegion={"method":"flood","l4_protocol":"TCP","target_ip":"${target_ip}","target_port":1234,"rate_pps":1,"claimed_src_ip_profile_id":${claimed_src_ip_profile_id}}
|
|
|
|
|
|
... referenceObject=
|
|
|
|
|
|
... isValid=1
|
|
|
|
|
|
... appObjectIdArray=${2}
|
|
|
|
|
|
... userTags=${Default_UserTags}
|
|
|
|
|
|
... doLog=${Default_DoLog}
|
|
|
|
|
|
${rescode} ${policyId} AddPolicy2 ${1} ${policyDict}
|
|
|
|
|
|
Comment 创建带主动策略Flood
|
|
|
|
|
|
${policyDict2} Create Dictionary
|
|
|
|
|
|
... policyName=${caseName}
|
|
|
|
|
|
... policyType=active_defence
|
2020-05-07 18:01:59 +08:00
|
|
|
|
... policyDesc=${caseName}
|
|
|
|
|
|
... action=activeDefence
|
|
|
|
|
|
... effectiveRange=${Default_EffectiveRange}
|
|
|
|
|
|
... userRegion={"method":"flood","l4_protocol":"UDP","target_ip":"${target_ip}","target_port":5678,"rate_pps":1,"claimed_src_ip_profile_id":${claimed_src_ip_profile_id}}
|
|
|
|
|
|
... referenceObject=
|
|
|
|
|
|
... isValid=1
|
|
|
|
|
|
... appObjectIdArray=${2}
|
|
|
|
|
|
... userTags=${Default_UserTags}
|
|
|
|
|
|
... doLog=${Default_DoLog}
|
|
|
|
|
|
${rescode} ${policyId2} AddPolicy2 ${1} ${policyDict2}
|
|
|
|
|
|
${policyIds} Create List {"policyType":"active_defence","policyIds":[${policyId},${policyId2}]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Comment 创建带主动策略Flood
|
|
|
|
|
|
${policyDict2Edit} Create Dictionary
|
|
|
|
|
|
... policyId=${policyId}
|
|
|
|
|
|
... policyName=${caseName}
|
|
|
|
|
|
... policyType=active_defence
|
|
|
|
|
|
... policyDesc=${caseName}
|
|
|
|
|
|
... action=activeDefence
|
|
|
|
|
|
... effectiveRange=${Default_EffectiveRange}
|
|
|
|
|
|
... userRegion={"method":"flood","l4_protocol":"UDP","target_ip":"${target_ip}","target_port":5678,"rate_pps":1,"claimed_src_ip_profile_id":${claimed_src_ip_profile_id}}
|
|
|
|
|
|
... referenceObject=
|
|
|
|
|
|
... isValid=1
|
|
|
|
|
|
... appObjectIdArray=${2}
|
|
|
|
|
|
... userTags=${Default_UserTags}
|
|
|
|
|
|
... doLog=${Default_DoLog}
|
|
|
|
|
|
Sleep ${policyVerificationSleepSeconds}s
|
2020-06-11 09:26:43 +08:00
|
|
|
|
${rescode} ${policyId} ${response} EditPolicy ${policyDict2Edit} disable
|
2020-05-07 18:01:59 +08:00
|
|
|
|
${policyDictEdit} Create Dictionary
|
|
|
|
|
|
... policyId=${policyId2}
|
|
|
|
|
|
... policyName=${caseName}
|
|
|
|
|
|
... policyType=active_defence
|
2020-04-28 17:03:28 +08:00
|
|
|
|
... policyDesc=${caseName}
|
|
|
|
|
|
... action=activeDefence
|
|
|
|
|
|
... effectiveRange=${Default_EffectiveRange}
|
|
|
|
|
|
... userRegion={"method":"flood","l4_protocol":"TCP","target_ip":"${target_ip}","target_port":1234,"rate_pps":1,"claimed_src_ip_profile_id":${claimed_src_ip_profile_id}}
|
|
|
|
|
|
... referenceObject=
|
|
|
|
|
|
... isValid=1
|
|
|
|
|
|
... appObjectIdArray=${2}
|
|
|
|
|
|
... userTags=${Default_UserTags}
|
|
|
|
|
|
... doLog=${Default_DoLog}
|
2020-05-07 18:01:59 +08:00
|
|
|
|
Sleep ${policyVerificationSleepSeconds}s
|
2020-06-11 09:26:43 +08:00
|
|
|
|
${rescode} ${policyId} ${response} EditPolicy ${policyDictEdit} disable
|
|
|
|
|
|
${rescode} ${policyId} ${response} EditPolicy ${policyDict2Edit} enable
|
2020-04-28 17:03:28 +08:00
|
|
|
|
|
|
|
|
|
|
|
2020-04-24 18:44:07 +08:00
|
|
|
|
ZDFY_ActiveDefencePolicy-Reflection-00001
|
|
|
|
|
|
[Tags] reflection
|
|
|
|
|
|
${caseName} set variable ZDFY_ActiveDefencePolicy-Reflection-00001
|
|
|
|
|
|
Comment claimed_src_ip_profile_id
|
2020-04-28 17:03:28 +08:00
|
|
|
|
${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"}]}
|
2020-04-24 18:44:07 +08:00
|
|
|
|
${reflector_profile_id} Set Variable ${response['data']['list'][0]['profileId']}
|
2020-04-28 17:03:28 +08:00
|
|
|
|
${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":""}]}
|
2020-04-24 18:44:07 +08:00
|
|
|
|
${payload_profile_id} Set Variable ${response['data']['list'][0]['profileId']}
|
|
|
|
|
|
Comment 创建策略reflection
|
|
|
|
|
|
${policyDict} Create Dictionary
|
|
|
|
|
|
... policyName=${caseName}
|
|
|
|
|
|
... policyType=active_defence
|
|
|
|
|
|
... policyDesc=${caseName}
|
|
|
|
|
|
... action=activeDefence
|
|
|
|
|
|
... effectiveRange=${Default_EffectiveRange}
|
|
|
|
|
|
... 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}}
|
|
|
|
|
|
... referenceObject=
|
|
|
|
|
|
... isValid=1
|
|
|
|
|
|
... appObjectIdArray=${2}
|
|
|
|
|
|
... userTags=${Default_UserTags}
|
|
|
|
|
|
... doLog=${Default_DoLog}
|
|
|
|
|
|
${rescode} ${policyId} AddPolicy2 ${1} ${policyDict}
|
|
|
|
|
|
${s} Convert to String ${policyId}
|
|
|
|
|
|
${policyIds} Create List {"policyType":"active_defence","policyIds":[${policyId}]}
|
|
|
|
|
|
ZDFY_ActiveDefencePolicy-CC-00001
|
|
|
|
|
|
[Tags] CC
|
|
|
|
|
|
${caseName} set variable ZDFY_ActiveDefencePolicy-CC-00001
|
|
|
|
|
|
Comment claimed_src_ip_profile_id
|
2020-05-07 18:01:59 +08:00
|
|
|
|
${response} BasePostRequest /policy/profile/claimedsrcip body={"opAction":"add","returnData":1,"claimedSrcIpList":[{"profileName":"autotest","addrType":4,"ipList":["10.1.1.0/24"],"isValid":1,"profileDesc":""}]}
|
2020-04-24 18:44:07 +08:00
|
|
|
|
${claimed_src_ip_profile_id} Set Variable ${response['data']['list'][0]['profileId']}
|
|
|
|
|
|
Comment 创建带主动策略CC
|
|
|
|
|
|
${policyDict} Create Dictionary
|
|
|
|
|
|
... policyName=${caseName}
|
|
|
|
|
|
... policyType=active_defence
|
|
|
|
|
|
... policyDesc=${caseName}
|
|
|
|
|
|
... action=activeDefence
|
|
|
|
|
|
... effectiveRange=${Default_EffectiveRange}
|
|
|
|
|
|
... userRegion={"method":"cc","l7_protocol":"HTTP","target_url":"http://test.com","rate_cps":1,"claimed_src_ip_profile_id":${claimed_src_ip_profile_id}}
|
|
|
|
|
|
... referenceObject=
|
|
|
|
|
|
... isValid=1
|
|
|
|
|
|
... appObjectIdArray=${2}
|
|
|
|
|
|
... userTags=${Default_UserTags}
|
|
|
|
|
|
... doLog=${Default_DoLog}
|
|
|
|
|
|
${rescode} ${policyId} AddPolicy2 ${1} ${policyDict}
|
|
|
|
|
|
${s} Convert to String ${policyId}
|
|
|
|
|
|
${policyIds} Create List {"policyType":"active_defence","policyIds":[${policyId}]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ZDFY_ActiveDefencePolicy-CC-00002
|
|
|
|
|
|
[Tags] CC
|
|
|
|
|
|
${caseName} set variable ZDFY_ActiveDefencePolicy-CC-00002
|
|
|
|
|
|
Comment claimed_src_ip_profile_id
|
2020-05-07 18:01:59 +08:00
|
|
|
|
${response} BasePostRequest /policy/profile/claimedsrcip body={"opAction":"add","returnData":1,"claimedSrcIpList":[{"profileName":"autotest","addrType":4,"ipList":["10.1.1.0/24"],"isValid":1,"profileDesc":"autotest"}]}
|
2020-04-24 18:44:07 +08:00
|
|
|
|
${claimed_src_ip_profile_id} Set Variable ${response['data']['list'][0]['profileId']}
|
|
|
|
|
|
Comment 创建带主动策略CC
|
|
|
|
|
|
${policyDict} Create Dictionary
|
|
|
|
|
|
... policyName=${caseName}
|
|
|
|
|
|
... policyType=active_defence
|
|
|
|
|
|
... policyDesc=${caseName}
|
|
|
|
|
|
... action=activeDefence
|
|
|
|
|
|
... effectiveRange=${Default_EffectiveRange}
|
2020-05-07 18:01:59 +08:00
|
|
|
|
... userRegion={"method":"cc","l7_protocol":"HTTPS","target_url":"https://test.com","rate_cps":60000,"claimed_src_ip_profile_id":${claimed_src_ip_profile_id}}
|
2020-04-24 18:44:07 +08:00
|
|
|
|
... referenceObject=
|
|
|
|
|
|
... isValid=1
|
|
|
|
|
|
... appObjectIdArray=${2}
|
|
|
|
|
|
... userTags=${Default_UserTags}
|
|
|
|
|
|
... doLog=${Default_DoLog}
|
|
|
|
|
|
${rescode} ${policyId} AddPolicy2 ${1} ${policyDict}
|
|
|
|
|
|
${s} Convert to String ${policyId}
|
2020-05-07 18:01:59 +08:00
|
|
|
|
${policyIds} Create List {"policyType":"active_defence","policyIds":[${policyId}]}
|
|
|
|
|
|
|
|
|
|
|
|
ZDFY_ActiveDefencePolicy-Delete
|
|
|
|
|
|
[Tags] DeleteActiveDefencePolicy
|
|
|
|
|
|
#${policyIds} Create List {"policyType":"active_defence","policyIds":[492,493,495]}
|
|
|
|
|
|
DeletePolicyAndObject ${policyIds} ${objectids}
|
|
|
|
|
|
ZDFY_ActiveDefencePolicy-Query
|
|
|
|
|
|
[Tags] QueryActiveDefencePolicy
|
|
|
|
|
|
${rescode} ${response} QueryPolicy policyType=active_defence
|
|
|
|
|
|
log ${response}
|
|
|
|
|
|
#${policyIds} Create List {"policyType":"active_defence","policyIds":[43,44]}
|