From f7a44c4d9c7f3994d7707464355a5cc12989d087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E6=98=8E=E6=98=8E?= Date: Thu, 13 Aug 2020 18:38:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8D=95=E5=8C=85=E7=AD=96=E7=95=A5=E6=96=B0?= =?UTF-8?q?=E5=A2=9E/=E4=BF=AE=E6=94=B9=E6=9C=8D=E5=8A=A1=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=20=E6=96=B0=E5=A2=9E=E5=85=B3=E9=94=AE=E5=AD=97?= =?UTF-8?q?=E7=BC=96=E5=86=99=E4=BB=A5=E5=8F=8A=20ip=E6=B1=A0=E9=87=8D?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tsg_bfapi/setting/PacketCapture.robot | 51 ++++++++++ 02-Keyword/tsg_bfapi/PolicyObject.robot | 8 +- 02-Keyword/tsg_common/ManageObjectBody.robot | 94 +++++++++++++++---- 3 files changed, 132 insertions(+), 21 deletions(-) create mode 100644 01-TestCase/tsg_bfapi/setting/PacketCapture.robot diff --git a/01-TestCase/tsg_bfapi/setting/PacketCapture.robot b/01-TestCase/tsg_bfapi/setting/PacketCapture.robot new file mode 100644 index 0000000..adbe618 --- /dev/null +++ b/01-TestCase/tsg_bfapi/setting/PacketCapture.robot @@ -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} ( ; \ No newline at end of file diff --git a/02-Keyword/tsg_bfapi/PolicyObject.robot b/02-Keyword/tsg_bfapi/PolicyObject.robot index 6fe21c0..20487b0 100644 --- a/02-Keyword/tsg_bfapi/PolicyObject.robot +++ b/02-Keyword/tsg_bfapi/PolicyObject.robot @@ -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 diff --git a/02-Keyword/tsg_common/ManageObjectBody.robot b/02-Keyword/tsg_common/ManageObjectBody.robot index 3baff6a..ac07a93 100644 --- a/02-Keyword/tsg_common/ManageObjectBody.robot +++ b/02-Keyword/tsg_common/ManageObjectBody.robot @@ -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} \ No newline at end of file