捕包策略新增/修改服务接口 新增关键字编写以及 ip池重构
This commit is contained in:
51
01-TestCase/tsg_bfapi/setting/PacketCapture.robot
Normal file
51
01-TestCase/tsg_bfapi/setting/PacketCapture.robot
Normal file
@@ -0,0 +1,51 @@
|
||||
*** Settings ***
|
||||
Test Teardown DeletePolicyAndObject ${policyIds} ${objectids}
|
||||
Force Tags tsg_adc proxy_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 ../../../02-Keyword/tsg_bfapi/ApiRequest.robot
|
||||
Resource ../../../03-Variable/AllFlowCaseVariable.txt
|
||||
Library String
|
||||
Library Custometest
|
||||
|
||||
*** Variables ***
|
||||
${policyIds} ${EMPTY}
|
||||
${objectids} ${EMPTY}
|
||||
|
||||
*** Test Cases ***
|
||||
test
|
||||
${isp} Create List transtel tnsplus ktel-mask ktel-bng ktel-mxpe
|
||||
${value} Set Variable transtel
|
||||
${aaaaa} Index ${isp} ${value}
|
||||
# index ${isp} ${value}
|
||||
log ${aaaaa}
|
||||
create_PacketCapture_Select_Location
|
||||
#添加一个vpn
|
||||
${PacketCapture} Create Dictionary policyId= policyName=zmmtest addrType=4 protocol=6 clientIp=192.168.40.5 clientPort=120 serverIp=0.0.0.0 serverPort=0 maxPacket=1000 captureDuration=1
|
||||
${location} Create List Almaty Nursurtan
|
||||
# ${location} Create List
|
||||
# ${isp} Create List transtel tnsplus ktel-mask ktel-bng ktel-mxpe
|
||||
${isp} Create List
|
||||
log ${PacketCapture}
|
||||
${PacketCaptureresponse} Add&Edit_PacketCapture ${PacketCapture} ${location} ${isp}
|
||||
|
||||
|
||||
|
||||
create_PacketCapture_Select_ISP
|
||||
#添加一个vpn
|
||||
${wan_vpn_dict} Create Dictionary username=zmmtest2 password=abcdef iconColor=#dddddd
|
||||
${wan_vpn_dict_2} Create Dictionary username=zmmtest3 password=abcdef iconColor=#dddddd
|
||||
${wan_vpn_list} Create List ${wan_vpn_dict} ${wan_vpn_dict_2}
|
||||
${a} AddWanVpn ${wan_vpn_list}
|
||||
log ${a}
|
||||
delete_wan_vpn_1
|
||||
# 删除一个vpn
|
||||
${deletelist} Create List 31
|
||||
${a} DeleteWanVpn ${deletelist}
|
||||
delete_wan_vpn_2
|
||||
# 删除一个vpn
|
||||
${deletelist} Create List 35 33
|
||||
${a} DeleteWanVpn ${deletelist}
|
||||
${result} Replace String ${test01} ( ;
|
||||
@@ -136,15 +136,15 @@ DeleteWanIpPood
|
||||
log ${response}
|
||||
|
||||
Add&Edit_PacketCapture
|
||||
[Arguments] ${PacketCapture_data}
|
||||
${body} PacketCapture ${PacketCapture_data}
|
||||
[Arguments] ${PacketCapture_data} ${location} ${isp}
|
||||
${body} PacketCapture ${PacketCapture_data} ${location} ${isp}
|
||||
log ${body}
|
||||
# ${body1} Set Variable {"refuseCode":true,"opAction":"add","returnData":0,"list":[{"ipList":[{"flag":"add","ip":"192.168.50.60","status":1597124967143,"isError":false,"testIp":"192.168.50.60","testIpRelativeLocation":"internal","testResult":[{"serverIp":"192.168.32.92","serverRelativeLocation":"external","serverGeoLocation":"UA","reachable":"pass"},{"serverIp":"192.168.32.91","serverRelativeLocation":"internal","serverGeoLocation":"Hongkang","reachable":"pass"}],"linkInfo":{"todo1":"fake-result","todo2":"test-API-only","todo3":"not-get-from-galaxy"},"relative_location":"internal","reachableCollect":"success"}],"profileName":"12313123123"}]}
|
||||
${response} run keyword if '${PacketCapture_data}[profileId]'=="" BasePostRequest /${version}/troubleshooting/packetcapture/policy ${body}
|
||||
${response} run keyword if '${PacketCapture_data}[policyId]'=="" BasePostRequest /${version}/troubleshooting/packetcapture/policy ${body}
|
||||
... ELSE BaseEditRequestOK /${version}/troubleshooting/packetcapture/policy ${body}
|
||||
log ${response}
|
||||
${response_code} Set Variable ${response['code']}
|
||||
${response_id} Set Variable ${response['data']['list'][0]['profileId']}
|
||||
${response_id} Set Variable ${response['data']['packetCaptureList'][0]['policyId']}
|
||||
# log 11111111111111111111222222222222222
|
||||
# log ${response_id}
|
||||
Should Be Equal As Strings ${response_code} 200
|
||||
|
||||
@@ -275,43 +275,103 @@ WanNatIpPood
|
||||
${opAction} run keyword if '${must_parameter}[profileId]'=="" Set Variable add
|
||||
... ELSE Set Variable update
|
||||
#编写最外面的格式
|
||||
${wan_nat_ip_pood_data} Create Dictionary opAction=${opAction} returnData=1 list=${wan_nat_ip_list}
|
||||
${returnData} evaluate int(1)
|
||||
${wan_nat_ip_pood_data} Create Dictionary opAction=${opAction} returnData=${returnData} list=${wan_nat_ip_list}
|
||||
# 返回请求json
|
||||
log ${wan_nat_ip_pood_data}
|
||||
${json} json.Dumps ${wan_nat_ip_pood_data} ensure_ascii=False
|
||||
log ${json}
|
||||
[Return] ${json}
|
||||
|
||||
|
||||
# index
|
||||
# [Arguments] ${list} ${value}
|
||||
# ${index} evaluate int(0)
|
||||
# ${1} evaluate int(1)
|
||||
# FOR ${a} IN @{list}
|
||||
# #${a} Set Variable ${a}
|
||||
# run Keyword if "${a}"=="${value}" log ${index}
|
||||
# ... ELSE ${index} evaluate ${index}+${1}
|
||||
# log ${a}
|
||||
# END
|
||||
|
||||
abcd
|
||||
[Arguments] ${effectiveRange_list} ${location}
|
||||
${ab} create list
|
||||
FOR ${a} IN @{location}
|
||||
${i} Index ${effectiveRange_list} ${a}
|
||||
Append To List ${ab} ${i}
|
||||
END
|
||||
[Return] ${ab}
|
||||
|
||||
isp_json
|
||||
[Arguments] ${isp_json}
|
||||
${1} Create List ${isp_json}
|
||||
[Return] ${1}
|
||||
|
||||
location_json
|
||||
[Arguments] ${location_json}
|
||||
${2} Create List ${location_json}
|
||||
[Return] ${2}
|
||||
|
||||
loccation_And_isp_json
|
||||
[Arguments] ${location_json} ${isp_json}
|
||||
${3} Create List ${location_json} ${isp_json}
|
||||
[Return] ${3}
|
||||
|
||||
|
||||
|
||||
PacketCapture
|
||||
[Arguments] ${PacketCapturedata}
|
||||
[Arguments] ${PacketCapturedata} ${location} ${isp}
|
||||
# 构建effectiveRange_tsg_sets
|
||||
${effectiveRange_list_manu} Create List location location2 Almaty Nursurtan isp transtel tnsplus ktel-mask ktel-bng ktel-mxpe
|
||||
${location_length} = Get Length ${location}
|
||||
${isp_length} = Get Length ${isp}
|
||||
|
||||
${location_ids} run keyword if ${location_length}==0 abcd ${effectiveRange_list_manu} ${location}
|
||||
... ELSE abcd ${effectiveRange_list_manu} ${location}
|
||||
log ${location_ids}
|
||||
${loction_json} Create Dictionary tag=location value=${location} ids=${location_ids}
|
||||
|
||||
${isp_ids} run keyword if ${isp_length}==0 abcd ${effectiveRange_list_manu} ${isp}
|
||||
... ELSE abcd ${effectiveRange_list_manu} ${isp}
|
||||
log ${isp}
|
||||
${isp_json} Create Dictionary tag=isp value=${isp} ids=${isp_ids}
|
||||
|
||||
${tag_sets_2} Create List ${loction_json} ${isp_json}
|
||||
${tag_sets} Create List ${tag_sets_2}
|
||||
${effectiveRange} Create Dictionary tag_sets=${tag_sets}
|
||||
# 编写iplist json格式
|
||||
log ${PacketCapturedata}
|
||||
# 替换指定键值对的值为 int
|
||||
# 构建PolicyList
|
||||
${addrType} evaluate int(${PacketCapturedata}[addrType])
|
||||
${protocol} evaluate int(${PacketCapturedata}[protocol])
|
||||
${captureDuration} evaluate int(${PacketCapturedata}[captureDuration])
|
||||
Set To Dictionary ${PacketCapturedata}#
|
||||
${second} Set Variable ${3600}
|
||||
${captureDuration1} evaluate int(${PacketCapturedata}[captureDuration])
|
||||
${captureDuration} evaluate ${captureDuration1}*${second}
|
||||
log ${captureDuration}
|
||||
${policyListDict} Create Dictionary
|
||||
... policyId=${PacketCapturedata}[policyId]
|
||||
... policyName=${PacketCapturedata}[policyName]
|
||||
... addrType=${PacketCapturedata}[addrType]
|
||||
... protocol=${PacketCapturedata}[protocol]
|
||||
... addrType=${addrType}
|
||||
... protocol=${protocol}
|
||||
... clientIp=${PacketCapturedata}[clientIp]
|
||||
... clientPort=${PacketCapturedata}[clientPort]
|
||||
... serverIp=${PacketCapturedata}[serverIp]
|
||||
... serverPort=${PacketCapturedata}[serverPort]
|
||||
... maxPacket=${PacketCapturedata}[maxPacket]
|
||||
... captureDuration=${PacketCapturedata}[captureDuration]
|
||||
log 111111111111111111111111111111111111111111111111111111111
|
||||
log ${PacketCapturedata}
|
||||
${wan_nat_ip_iplist} Create Dictionary profileId=${must_parameter}[profileId] profileName=${must_parameter}[profileName] ipList=${wan_nat_ip_iplist} isValid=1
|
||||
#编写二层list内地格式
|
||||
${wan_nat_ip_list} Create List ${wan_nat_ip_iplist}
|
||||
... captureDuration=${captureDuration}
|
||||
... effectiveRange=${effectiveRange}
|
||||
log ${policyListDict}
|
||||
${policyList} Create List ${policyListDict}
|
||||
# 判断sjon是用于修改还是新增
|
||||
${opAction} run keyword if '${must_parameter}[profileId]'=="" Set Variable add
|
||||
${opAction} run keyword if '${PacketCapturedata}[policyId]'=="" Set Variable add
|
||||
... ELSE Set Variable update
|
||||
#编写最外面的格式
|
||||
${wan_nat_ip_pood_data} Create Dictionary opAction=${opAction} returnData=1 policyList=${wan_nat_ip_list}
|
||||
${returnData} evaluate int(1)
|
||||
${PacketCapture} Create Dictionary opAction=${opAction} returnData=${returnData} policyList=${policyList}
|
||||
# 返回请求json
|
||||
log ${wan_nat_ip_pood_data}
|
||||
${json} json.Dumps ${wan_nat_ip_pood_data} ensure_ascii=False
|
||||
log ${PacketCapture}
|
||||
${json} json.Dumps ${PacketCapture} ensure_ascii=False
|
||||
log 111111111111${json}
|
||||
[Return] ${json}
|
||||
Reference in New Issue
Block a user