From e9893ac45d38de5c68d373d6dd752e979c7bf601 Mon Sep 17 00:00:00 2001 From: wangxin Date: Tue, 16 Jun 2020 18:13:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:(test=20case)=E4=B8=BB=E5=8A=A8=E9=98=B2?= =?UTF-8?q?=E5=BE=A1=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B=E5=88=A0=E9=99=A4?= =?UTF-8?q?profileId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../policy_object/PolicyObjectTests.robot | 13 ++++++--- 02-Keyword/tsg_bfapi/PolicyObject.robot | 27 ++++++++++++++++--- .../policy_object/ProcessPolicyBody.robot | 9 +++++++ 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/01-TestCase/tsg_bfapi/policy_object/PolicyObjectTests.robot b/01-TestCase/tsg_bfapi/policy_object/PolicyObjectTests.robot index c36b437..6ec67c8 100644 --- a/01-TestCase/tsg_bfapi/policy_object/PolicyObjectTests.robot +++ b/01-TestCase/tsg_bfapi/policy_object/PolicyObjectTests.robot @@ -1,8 +1,10 @@ *** Settings *** -Test Teardown DeletePolicyAndObject ${policyIds} ${objectIds} +Test Teardown DeletePolicyAndObjectAndProfile ${policyIds} ${objectIds} ${profiles} Resource ../../../02-Keyword/tsg_bfapi/PolicyObject.robot Resource ../../../02-Keyword/tsg_bfapi/policy_object/Policy.robot Resource ../../../02-Keyword/tsg_bfapi/Common.robot +*** Variables *** +@{profiles} *** Test Cases *** Policy-Get-v1-00001 ${policy} Create Dictionary policyType=tsg_security action=deny @@ -129,9 +131,9 @@ Policy-Post-v2-00006 ${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"}]} + ${response} BasePostRequest /v1/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 /v1/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 @@ -143,5 +145,8 @@ Policy-Post-v2-00006 ... 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} + ${profile} Create Dictionary typeUrl=reflector profileIds=${reflector_profile_id} + ${profile1} Create Dictionary typeUrl=reflector/payload profileIds=${payload_profile_id} + Append To List ${profiles} ${profile} ${profile1} + ${objectIds} Set Variable ${EMPTY} Log ${rescode} ${policyIds} ${objectIds} \ No newline at end of file diff --git a/02-Keyword/tsg_bfapi/PolicyObject.robot b/02-Keyword/tsg_bfapi/PolicyObject.robot index 422dbad..7317ace 100644 --- a/02-Keyword/tsg_bfapi/PolicyObject.robot +++ b/02-Keyword/tsg_bfapi/PolicyObject.robot @@ -177,7 +177,24 @@ DeleteObject ${response} Convert to String ${response} log ${response} #Should Be Equal As Strings ${response} {'code': 200, 'msg': 'Success', 'success': True} - + +DeleteProfile + [Arguments] ${typeUrl} ${profileIds} + #删除对象 + log DeleteProfile + ${response} BaseDeleteRequest /${version}/policy/profile/${typeUrl} {"profileIds":[${profileIds}]} + ${response_code} Get From Dictionary ${response} code + #log aaaaaaaaaa:${response_code} + Should Be Equal As Strings ${response_code} 200 + #Integer ${response_code} 200 + ${response} Convert to String ${response} + log ${response} + #Should Be Equal As Strings ${response} {'code': 200, 'msg': 'Success', 'success': True} +DeleteProfiles + [Arguments] ${profiles} + FOR ${profile} IN @{profiles} + Run Keyword If "${profile}"!="" and ${profile}!="${EMPTY}" DeleteProfile ${profile}[typeUrl] ${profile}[profileIds] + END DeletePolicyAndObject [Arguments] ${policyids} ${objectids} #删除和对象 @@ -193,8 +210,12 @@ DeletePolicyAndObject #删除对象 log todeleteobj_DeletePolicyAndObject Run Keyword If "${objectids}"=="${EMPTY}" log no obj to del - ... ELSE DeleteObject ${objectids} - + ... ELSE DeleteObject ${objectids} + +DeletePolicyAndObjectAndProfile + [Arguments] ${policyids} ${objectids} ${profiles} + DeletePolicyAndObject ${policyids} ${objectids} + DeleteProfiles ${profiles} DeleteAfterCase [Arguments] ${policyids} ${objectids} Run Keyword If '${testPart}'=='all' or '${testPart}'=='3' DeletePolicyAndObject ${policyids} ${objectids} diff --git a/02-Keyword/tsg_bfapi/policy_object/ProcessPolicyBody.robot b/02-Keyword/tsg_bfapi/policy_object/ProcessPolicyBody.robot index 261094f..2f68d94 100644 --- a/02-Keyword/tsg_bfapi/policy_object/ProcessPolicyBody.robot +++ b/02-Keyword/tsg_bfapi/policy_object/ProcessPolicyBody.robot @@ -85,6 +85,15 @@ WxPolicyOrganize [Arguments] ${policy} ${opAction} ${policyObjectVersion} Log To Console Call WxPolicyOrganize ${emptyList} Create List + #v1版本接口与v2版本接口不同的字段 + Run Keyword If "${policyObjectVersion}"=="v1" Dictionary Should Not Contain Key ${policy} source + Run Keyword If "${policyObjectVersion}"=="v1" Dictionary Should Not Contain Key ${policy} destination + Run Keyword If "${policyObjectVersion}"=="v1" Dictionary Should Not Contain Key ${policy} filterList + Run Keyword If "${policyObjectVersion}"=="v1" Dictionary Should Not Contain Key ${policy} appIdObjects + + Run Keyword If "${policyObjectVersion}"=="v2" Dictionary Should Not Contain Key ${policy} referenceObject + Run Keyword If "${policyObjectVersion}"=="v2" Dictionary Should Not Contain Key ${policy} appObjectIdArray + # 取可选参数,为传入设置默认值 ${return} ${policyName} Run Keyword And Ignore Error Get From Dictionary ${policy} policyName Run Keyword If "${return}"=="FAIL" or "${policyName}"=="${EMPTY}" Set To Dictionary ${policy} policyName=${Default_PolicyName}