feat:(策略对象新增修改)1:策略对象支持多个同时新增/修改
2.策略对象修改支持addItemList,updateItemList,deleteItemIds 3.策略对象支持enable,disable,只需要传入objectId,objectType
This commit is contained in:
@@ -2,8 +2,11 @@
|
|||||||
Test Teardown DeletePolicyAndObjectAndProfile ${policyIds} ${objectIds} ${profiles}
|
Test Teardown DeletePolicyAndObjectAndProfile ${policyIds} ${objectIds} ${profiles}
|
||||||
Resource ../../../02-Keyword/tsg_bfapi/PolicyObject.robot
|
Resource ../../../02-Keyword/tsg_bfapi/PolicyObject.robot
|
||||||
Resource ../../../02-Keyword/tsg_bfapi/policy_object/Policy.robot
|
Resource ../../../02-Keyword/tsg_bfapi/policy_object/Policy.robot
|
||||||
|
Resource ../../../02-Keyword/tsg_bfapi/policy_object/Object.robot
|
||||||
Resource ../../../02-Keyword/tsg_bfapi/Common.robot
|
Resource ../../../02-Keyword/tsg_bfapi/Common.robot
|
||||||
|
Library json
|
||||||
*** Variables ***
|
*** Variables ***
|
||||||
|
@{policyIds}
|
||||||
@{profiles}
|
@{profiles}
|
||||||
*** Test Cases ***
|
*** Test Cases ***
|
||||||
Policy-Get-v1-00001
|
Policy-Get-v1-00001
|
||||||
@@ -253,3 +256,117 @@ Policy-Post-v2-00009
|
|||||||
Comment 更新安全策略
|
Comment 更新安全策略
|
||||||
Set To Dictionary ${policy1} policyId=${updatePolicyId}
|
Set To Dictionary ${policy1} policyId=${updatePolicyId}
|
||||||
${rescode} UpdatePolicies 1 ${policy1} v2 enable
|
${rescode} UpdatePolicies 1 ${policy1} v2 enable
|
||||||
|
Policy-Post-v2-00010
|
||||||
|
Comment 创建IP
|
||||||
|
${objectDict} Create Dictionary objectType=ip isValid=${1}
|
||||||
|
... isInitialize=0
|
||||||
|
... addItemList=range|192.168.41.68|192.168.41.68|0/0
|
||||||
|
${rescode} ${objectId1} AddObject2 ${1} ${objectDict}
|
||||||
|
${objectIds} Set Variable ${objectId1}
|
||||||
|
Log To Console Create IP Object1
|
||||||
|
Comment 创建url
|
||||||
|
${objectDict} Create Dictionary objectType=url isValid=${1} addItemList=*baidu.com
|
||||||
|
${rescode} ${objectId3} AddObject2 ${1} ${objectDict}
|
||||||
|
${objectIds} Set Variable ${objectId3},${objectIds}
|
||||||
|
Log To Console Create url Object3
|
||||||
|
|
||||||
|
Comment 创建安全策略
|
||||||
|
${policy} Create Dictionary policyName=WX_AddPolicy-v2-00010 policyType=tsg_security
|
||||||
|
... policyDesc=wx-autotest
|
||||||
|
... action=deny effectiveRange={}
|
||||||
|
... userRegion={"protocol":"HTTP","method":"drop"}
|
||||||
|
... source=${objectId1}|TSG_SECURITY_SOURCE_ADDR
|
||||||
|
... destination=${objectId3}|TSG_FIELD_HTTP_URL
|
||||||
|
... isValid=${0} appIdObjects=2
|
||||||
|
${rescode} ${policyIds} AddPolicies 1 ${policy} v2
|
||||||
|
Log ${rescode}
|
||||||
|
${updatePolicyId} Set Variable ${policyIds}[0][policyIds][0]
|
||||||
|
Comment 更新安全策略
|
||||||
|
${policy} Create Dictionary policyId=${updatePolicyId}
|
||||||
|
${rescode} UpdatePolicies 1 ${policy} v2 enable
|
||||||
|
Policy-Post-v2-00011
|
||||||
|
Comment 创建IP
|
||||||
|
${objectDict} Create Dictionary objectType=ip isValid=${1}
|
||||||
|
... isInitialize=0
|
||||||
|
... addItemList=range|192.168.41.68|192.168.41.68|0/0
|
||||||
|
${rescode} ${objectId1} AddObject2 ${1} ${objectDict}
|
||||||
|
${objectIds} Set Variable ${objectId1}
|
||||||
|
Log To Console Create IP Object1
|
||||||
|
Comment 创建url
|
||||||
|
${objectDict} Create Dictionary objectType=url isValid=${1} addItemList=*baidu.com
|
||||||
|
${rescode} ${objectId3} AddObject2 ${1} ${objectDict}
|
||||||
|
${objectIds} Set Variable ${objectId3},${objectIds}
|
||||||
|
Log To Console Create url Object3
|
||||||
|
|
||||||
|
Comment 创建安全策略
|
||||||
|
${policy} Create Dictionary policyName=WX_AddPolicy-v2-00011 policyType=tsg_security
|
||||||
|
... policyDesc=wx-autotest
|
||||||
|
... action=deny effectiveRange={}
|
||||||
|
... userRegion={"protocol":"HTTP","method":"drop"}
|
||||||
|
... source=${objectId1}|TSG_SECURITY_SOURCE_ADDR
|
||||||
|
... destination=${objectId3}|TSG_FIELD_HTTP_URL
|
||||||
|
... isValid=${1} appIdObjects=2
|
||||||
|
${rescode} ${policyIds} AddPolicies 1 ${policy} v2
|
||||||
|
Log ${rescode}
|
||||||
|
${updatePolicyId} Set Variable ${policyIds}[0][policyIds][0]
|
||||||
|
Comment 更新安全策略
|
||||||
|
${policy} Create Dictionary policyId=${updatePolicyId}
|
||||||
|
${rescode} UpdatePolicies 1 ${policy} v2 disable
|
||||||
|
Policy-Post-v1-00012
|
||||||
|
Comment 创建IP
|
||||||
|
${objectDict} Create Dictionary objectType=ip isValid=${1}
|
||||||
|
... isInitialize=0
|
||||||
|
... addItemList=range|192.168.41.68|192.168.41.68|0/0
|
||||||
|
${rescode} ${objectId1} AddObjects ${1} ${objectDict}
|
||||||
|
${objectIds} Set Variable ${objectId1}
|
||||||
|
Log To Console Create IP Object
|
||||||
|
Comment 更新IP
|
||||||
|
${objectDict} Create Dictionary objectId=${objectId1} objectType=ip
|
||||||
|
${rescode} UpdateObjects ${1} ${objectDict} disable
|
||||||
|
Log To Console Create IP Object
|
||||||
|
Policy-Post-v1-00013
|
||||||
|
Comment 创建IP
|
||||||
|
${objectDict} Create Dictionary objectType=ip isValid=${0}
|
||||||
|
... isInitialize=0
|
||||||
|
... addItemList=range|192.168.41.68|192.168.41.68|0/0
|
||||||
|
${rescode} ${objectId1} AddObjects ${1} ${objectDict}
|
||||||
|
${objectIds} Set Variable ${objectId1}
|
||||||
|
Log To Console Create IP Object
|
||||||
|
${params} Create Dictionary objectId=${objectId1} itemType=ip
|
||||||
|
${rescode} ${itemIds} ${itemList} GetObjectItems ${params}
|
||||||
|
Log To Console ${itemIds}
|
||||||
|
Comment 更新IP
|
||||||
|
${len} Get Length ${itemList}
|
||||||
|
FOR ${index} IN ${len}
|
||||||
|
${index1} Evaluate int(${index})-1
|
||||||
|
Set To Dictionary ${itemList}[${index1}] clientIp1 192.168.41.67
|
||||||
|
Set To Dictionary ${itemList}[${index1}] clientIp2 192.168.41.67
|
||||||
|
Remove From Dictionary ${itemList}[${index1}] isInitialize
|
||||||
|
Set To Dictionary ${itemList}[${index1}] serverIp1 192.168.41.68
|
||||||
|
Set To Dictionary ${itemList}[${index1}] serverIp2 192.168.41.68
|
||||||
|
END
|
||||||
|
${objectDict} Create Dictionary objectId=${objectId1} objectType=ip
|
||||||
|
... updateItemList=${itemList}
|
||||||
|
${rescode} UpdateObjects ${1} ${objectDict} update
|
||||||
|
Log To Console Create IP Object
|
||||||
|
Policy-Post-v1-00014
|
||||||
|
Comment 创建urls
|
||||||
|
${objectDict1} Create Dictionary objectType=url isValid=${1} addItemList=*baidu.com,
|
||||||
|
${objectDict2} Create Dictionary objectType=url isValid=${1} addItemList=*google.com
|
||||||
|
${objectDict} Create List ${objectDict1} ${objectDict2}
|
||||||
|
${rescode} ${objectIds} AddObjects ${1} ${objectDict}
|
||||||
|
Policy-Post-v1-00015
|
||||||
|
Comment 创建urls
|
||||||
|
${objectDict1} Create Dictionary objectType=url isValid=${1} addItemList=*baidu.com,*google.com
|
||||||
|
${rescode} ${objectIds} AddObjects ${1} ${objectDict1}
|
||||||
|
${params} Create Dictionary objectId=${objectIds} itemType=url
|
||||||
|
${rescode} ${itemIds} ${itemList} GetObjectItems ${params}
|
||||||
|
Log To Console ${itemIds}
|
||||||
|
Comment 修改urls
|
||||||
|
${updateList} Create List *baidu.com* *baidu1.com*
|
||||||
|
Set To Dictionary ${itemList}[0] keywordArray ${updateList}
|
||||||
|
${objectDict} Create Dictionary objectId=${objectIds} objectType=url
|
||||||
|
... addItemList=putty.com
|
||||||
|
... updateItemList=${itemList}[0]
|
||||||
|
... deleteItemIds=${itemIds}[1]
|
||||||
|
${rescode} UpdateObjects ${1} ${objectDict} update
|
||||||
@@ -98,3 +98,28 @@ BaseEditRequestForV2
|
|||||||
... ELSE set variable /${apiVersion}/${requestUri}
|
... ELSE set variable /${apiVersion}/${requestUri}
|
||||||
${response} BaseEditRequest ${requestUri} ${data}
|
${response} BaseEditRequest ${requestUri} ${data}
|
||||||
[Return] ${response}
|
[Return] ${response}
|
||||||
|
#拼接字典类型数据为get请求的字符串
|
||||||
|
Dictionary-To-QueryParams
|
||||||
|
[Documentation]
|
||||||
|
... 接收get参数字典,转换为请求字符串
|
||||||
|
[Arguments] ${params}
|
||||||
|
${paramsString} = Set Variable ${EMPTY}
|
||||||
|
FOR ${key} IN @{params}
|
||||||
|
${value} = Get From Dictionary ${params} ${key}
|
||||||
|
${paramStr} = Catenate SEPARATOR=\= ${key} ${value}
|
||||||
|
${len} = Get Length ${paramsString}
|
||||||
|
${paramsString} = Run Keyword If ${len} != 0 Catenate SEPARATOR=& ${paramsString} ${paramStr}
|
||||||
|
... ELSE Set Variable ${paramStr}
|
||||||
|
END
|
||||||
|
Log To Console ${paramsString}
|
||||||
|
[Return] ${paramsString}
|
||||||
|
BaseFormRequest
|
||||||
|
[Arguments] ${requestUri} ${data} ${apiVersion}
|
||||||
|
${headers} set variable {"Authorization":"${token}","Content-Type":"application/x-www-form-urlencoded"}
|
||||||
|
create session api http://${host}:${port}/${apiVersion} ${headers}
|
||||||
|
${response} Run Keyword If "${data}"=="${EMPTY}" Get Request api ${requestUri}
|
||||||
|
... ELSE Get Request api ${requestUri}?${data}
|
||||||
|
log return data =${response}
|
||||||
|
Should Be Equal As Strings ${response.status_code} 200
|
||||||
|
${response} to json ${response.content}
|
||||||
|
[Return] ${response}
|
||||||
72
02-Keyword/tsg_bfapi/policy_object/Object.robot
Normal file
72
02-Keyword/tsg_bfapi/policy_object/Object.robot
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
*** Settings ***
|
||||||
|
Library Collections
|
||||||
|
Library RequestsLibrary
|
||||||
|
Resource ../../../03-Variable/BifangApiVariable.txt
|
||||||
|
Resource ../../../02-Keyword/tsg_bfapi/policy_file_interface/FunctionalKeywords.robot
|
||||||
|
Resource ProcessObjectBody.robot
|
||||||
|
Library Collections
|
||||||
|
Resource ../Common.robot
|
||||||
|
*** Variables ***
|
||||||
|
${objectUrl} /policy/object
|
||||||
|
*** Keywords ***
|
||||||
|
AddObjects
|
||||||
|
[Documentation]
|
||||||
|
... 新增策略对象
|
||||||
|
... objectList,策略对象,可为list类型与dict类型
|
||||||
|
... returnData,是否返回数据,固定为1
|
||||||
|
[Arguments] ${returnData} ${objectList}
|
||||||
|
${returnData}= Run Keyword If '${returnData}' == '${EMPTY}' Set Variable 1
|
||||||
|
... ELSE Set Variable ${returnData}
|
||||||
|
|
||||||
|
#必选参数判定
|
||||||
|
Should Not Be Empty ${objectList}
|
||||||
|
${dictType} = Evaluate type(${objectList})
|
||||||
|
${body} Run Keyword If "${dictType}" == "<class 'list'>" WxObjectListOperation ${returnData} ${objectList} add
|
||||||
|
... ELSE IF "${dictType}" == "<class 'dict'>" WxObjectOperation ${returnData} ${objectList} add
|
||||||
|
... ELSE Set Variable ${EMPTY}
|
||||||
|
|
||||||
|
${response} BasePostRequestForV2 ${objectUrl} ${body} ${version}
|
||||||
|
${objectIds} Run Keyword If "${returnData}" == "1" WxGet-ObjectIds ${response}
|
||||||
|
... ELSE Create List
|
||||||
|
${rescode} Set Variable ${response['code']}
|
||||||
|
Should Be Equal As Strings ${rescode} 200
|
||||||
|
[Return] ${rescode} ${objectIds}
|
||||||
|
UpdateObjects
|
||||||
|
[Documentation]
|
||||||
|
... 更新策略对象
|
||||||
|
... objectList,策略对象,可为list类型与dict类型
|
||||||
|
... returnData,是否返回数据,固定为1
|
||||||
|
... opAction,可为update,enable,disable
|
||||||
|
[Arguments] ${returnData} ${objectList} ${opAction}
|
||||||
|
${returnData}= Run Keyword If '${returnData}' == '${EMPTY}' Set Variable 1
|
||||||
|
... ELSE Set Variable ${returnData}
|
||||||
|
|
||||||
|
#必选参数判定
|
||||||
|
Should Not Be Empty ${objectList}
|
||||||
|
${dictType} = Evaluate type(${objectList})
|
||||||
|
${body} Run Keyword If "${dictType}" == "<class 'list'>" WxObjectListOperation ${returnData} ${objectList} ${opAction}
|
||||||
|
... ELSE IF "${dictType}" == "<class 'dict'>" WxObjectOperation ${returnData} ${objectList} ${opAction}
|
||||||
|
... ELSE Set Variable ${EMPTY}
|
||||||
|
|
||||||
|
${response} BaseEditRequestForV2 ${objectUrl} ${body} ${version}
|
||||||
|
${rescode} Set Variable ${response['code']}
|
||||||
|
Should Be Equal As Strings ${rescode} 200
|
||||||
|
[Return] ${rescode}
|
||||||
|
GetObjectItems
|
||||||
|
[Documentation]
|
||||||
|
... 获取策略对象中的item,策略对象单元
|
||||||
|
... 当updateItemList中有需要传入数据时
|
||||||
|
... 调用此关键字
|
||||||
|
[Arguments] ${params}
|
||||||
|
#必选参数判定
|
||||||
|
Should Not Be Empty ${params}
|
||||||
|
${paramsStr} Dictionary-To-QueryParams ${params}
|
||||||
|
${response} BaseFormRequest /policy/items ${paramsStr} ${version}
|
||||||
|
${rescode} Set Variable ${response['code']}
|
||||||
|
Should Be Equal As Strings ${rescode} 200
|
||||||
|
${data} Set Variable ${response['data']}
|
||||||
|
${itemIds} Create List
|
||||||
|
FOR ${item} IN @{data['list']}
|
||||||
|
Append To List ${itemIds} ${item['itemId']}
|
||||||
|
END
|
||||||
|
[Return] ${rescode} ${itemIds} ${data['list']}
|
||||||
@@ -9,21 +9,6 @@ Resource ../Common.robot
|
|||||||
*** Variables ***
|
*** Variables ***
|
||||||
${url} /policy/compile
|
${url} /policy/compile
|
||||||
*** Keywords ***
|
*** Keywords ***
|
||||||
#拼接字典类型数据为get请求的字符串
|
|
||||||
Dictionary-To-QueryParams
|
|
||||||
[Documentation]
|
|
||||||
... 接收get参数字典,转换为请求字符串
|
|
||||||
[Arguments] ${params}
|
|
||||||
${paramsString} = Set Variable ${EMPTY}
|
|
||||||
FOR ${key} IN @{params}
|
|
||||||
${value} = Get From Dictionary ${params} ${key}
|
|
||||||
${paramStr} = Catenate SEPARATOR=\= ${key} ${value}
|
|
||||||
${len} = Get Length ${paramsString}
|
|
||||||
${paramsString} = Run Keyword If ${len} != 0 Catenate SEPARATOR=& ${paramsString} ${paramStr}
|
|
||||||
... ELSE Set Variable ${paramStr}
|
|
||||||
END
|
|
||||||
Log To Console ${paramsString}
|
|
||||||
[Return] ${paramsString}
|
|
||||||
#get查询策略,传入字典对象,该方法将字典对象自动拼接成get请求查询条件
|
#get查询策略,传入字典对象,该方法将字典对象自动拼接成get请求查询条件
|
||||||
QueryPolicies
|
QueryPolicies
|
||||||
[Documentation]
|
[Documentation]
|
||||||
@@ -74,6 +59,7 @@ AddPolicies
|
|||||||
${policyIds} Run Keyword If "${returnData}" == "1" WxGet-PolicyIds ${response}
|
${policyIds} Run Keyword If "${returnData}" == "1" WxGet-PolicyIds ${response}
|
||||||
... ELSE Create List
|
... ELSE Create List
|
||||||
${rescode} Set Variable ${response['code']}
|
${rescode} Set Variable ${response['code']}
|
||||||
|
Should Be Equal As Strings ${rescode} 200
|
||||||
[Return] ${rescode} ${policyIds}
|
[Return] ${rescode} ${policyIds}
|
||||||
UpdatePolicies
|
UpdatePolicies
|
||||||
[Arguments] ${returnData} ${policyList} ${version} ${opAction}
|
[Arguments] ${returnData} ${policyList} ${version} ${opAction}
|
||||||
@@ -88,4 +74,5 @@ UpdatePolicies
|
|||||||
... ELSE Set Variable ${EMPTY}
|
... ELSE Set Variable ${EMPTY}
|
||||||
${response} BaseEditRequestForV2 ${url} ${body} ${version}
|
${response} BaseEditRequestForV2 ${url} ${body} ${version}
|
||||||
${rescode} Set Variable ${response['code']}
|
${rescode} Set Variable ${response['code']}
|
||||||
|
Should Be Equal As Strings ${rescode} 200
|
||||||
[Return] ${rescode}
|
[Return] ${rescode}
|
||||||
163
02-Keyword/tsg_bfapi/policy_object/ProcessObjectBody.robot
Normal file
163
02-Keyword/tsg_bfapi/policy_object/ProcessObjectBody.robot
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
*** Settings ***
|
||||||
|
Library json
|
||||||
|
Library Collections
|
||||||
|
Resource ../../../03-Variable/BifangApiVariable.txt
|
||||||
|
Resource ../../../03-Variable/PolicyObjectDefault.txt
|
||||||
|
Resource ../../tsg_common/ManageObjectBody.robot
|
||||||
|
*** Keywords ***
|
||||||
|
WxObjectListOperation
|
||||||
|
[Documentation]
|
||||||
|
... 描述:入口,opAction参数可为'add','update','disable','enable'
|
||||||
|
... 参数:returnData: 必传,是否返回请求数据。可选${0}(不返回)/${1}(返回)。
|
||||||
|
... objectList: 必传,字典类型。字典内可选参数信息:
|
||||||
|
... 其它参数默认值见../../03-Variable/PolicyObjectDefault.txt
|
||||||
|
... 多个对象处理
|
||||||
|
|
||||||
|
[Arguments] ${returnData} ${objectList} ${opAction}
|
||||||
|
Log To Console Call WxObjectListOperation
|
||||||
|
${objectListJson} Set Variable [
|
||||||
|
FOR ${object} IN @{objectList}
|
||||||
|
${json} WxObjectOrganize ${object} ${opAction}
|
||||||
|
${objectListJson} Set Variable ${objectListJson}${json},
|
||||||
|
END
|
||||||
|
${objectListJson}= Replace String Using Regexp ${objectListJson} ,$ ]
|
||||||
|
# 转为json结构并返回
|
||||||
|
${dict} Create Dictionary opAction=${opAction} returnData=${returnData} objectList=replace:objectList
|
||||||
|
${bodyJson} json.Dumps ${dict} ensure_ascii=False
|
||||||
|
${json} Replace String ${bodyJson} "replace:objectList" ${objectListJson}
|
||||||
|
Log Object_Request_Body-${json}
|
||||||
|
[Return] ${json}
|
||||||
|
|
||||||
|
WxObjectOperation
|
||||||
|
[Documentation]
|
||||||
|
... 描述:入口,opAction参数可为'add','update','disable','enable'
|
||||||
|
... 参数:returnData: 必传,是否返回请求数据。可选${0}(不返回)/${1}(返回)。
|
||||||
|
... object: 必传,字典类型。字典内可选参数信息:
|
||||||
|
... 其它参数默认值见../../03-Variable/PolicyObjectDefault.txt
|
||||||
|
... 单个策略处理
|
||||||
|
|
||||||
|
[Arguments] ${returnData} ${object} ${opAction}
|
||||||
|
Log To Console Call WxPolicyOperation
|
||||||
|
${json} WxObjectOrganize ${object} ${opAction}
|
||||||
|
# 转为json结构并返回
|
||||||
|
${dict} Create Dictionary opAction=${opAction} returnData=${returnData} objectList=replace:objectList
|
||||||
|
${bodyJson} json.Dumps ${dict} ensure_ascii=False
|
||||||
|
${json} Replace String ${bodyJson} "replace:objectList" ${json}
|
||||||
|
|
||||||
|
Log Object_Request_Body-${json}
|
||||||
|
[Return] ${json}
|
||||||
|
|
||||||
|
WxObjectOrganize
|
||||||
|
[Documentation]
|
||||||
|
... 描述:入口,opAction参数可为'add','update','disable','enable'
|
||||||
|
... object: 必传,字典类型。字典内可选参数信息:
|
||||||
|
... 其它参数默认值见../../03-Variable/PolicyObjectDefault.txt
|
||||||
|
... 单个策略转换为json
|
||||||
|
[Arguments] ${object} ${opAction}
|
||||||
|
Log To Console Call WxObjectOrganize
|
||||||
|
${emptyList} Create List
|
||||||
|
${returnDict} Create Dictionary
|
||||||
|
# 断言必传参数
|
||||||
|
# Should Not Be Empty ${object}[objectType]
|
||||||
|
# Set To Dictionary ${returnDict} objectType=${object}[objectType]
|
||||||
|
#新增时addItemList不能为空
|
||||||
|
Run Keyword If "${opAction}"=="add" Should Not Be Empty ${object}[addItemList]
|
||||||
|
|
||||||
|
Run Keyword If "${opAction}"=="update" Should Not Be Empty ${object}[objectId]
|
||||||
|
Run Keyword If "${opAction}"=="enable" Should Not Be Empty ${object}[objectId]
|
||||||
|
Run Keyword If "${opAction}"=="disable" Should Not Be Empty ${object}[objectId]
|
||||||
|
|
||||||
|
${return} ${objectId} Run Keyword And Ignore Error Get From Dictionary ${object} objectId
|
||||||
|
Run Keyword If "${return}"=="FAIL" or "${objectId}"=="${EMPTY}" Set To Dictionary ${returnDict} objectId=${EMPTY}
|
||||||
|
... ELSE Set To Dictionary ${returnDict} objectId=${objectId}
|
||||||
|
|
||||||
|
${return} ${objectType} Run Keyword And Ignore Error Get From Dictionary ${object} objectType
|
||||||
|
${objectTypeV} Run Keyword If "${return}"!="FAIL" and "${objectType}"!="${EMPTY}" Evaluate '${objectType}'.lower()
|
||||||
|
... ELSE Evaluate '${Default_ObjectType}'.lower()
|
||||||
|
Set To Dictionary ${returnDict} objectType=${objectTypeV}
|
||||||
|
#enable disable直接返回json
|
||||||
|
Run Keyword And Return If "${opAction}"=="enable" or "${opAction}"=="disable" ManageEnableAndDisable ${object} ${returnDict} ${opAction}
|
||||||
|
# 取可选参数,为传入设置默认值
|
||||||
|
Set To Dictionary ${returnDict} objectType=${objectTypeV}
|
||||||
|
${return} ${objectSubType} Run Keyword And Ignore Error Get From Dictionary ${object} objectSubType
|
||||||
|
Run Keyword If "${return}"!="FAIL" and "${objectSubType}"!="${EMPTY}" Set To Dictionary ${returnDict} objectSubType=${objectSubType}
|
||||||
|
... ELSE Set To Dictionary ${returnDict} objectSubType=${Default_ObjectSubType}
|
||||||
|
${return} ${isValid} Run Keyword And Ignore Error Get From Dictionary ${object} isValid
|
||||||
|
Run Keyword If "${return}"=="FAIL" or "${isValid}"=="${EMPTY}" Set To Dictionary ${returnDict} isValid=${Default_IsValid}
|
||||||
|
... ELSE Set To Dictionary ${returnDict} isValid=${isValid}
|
||||||
|
|
||||||
|
${return} ${isInitialize} Run Keyword And Ignore Error Get From Dictionary ${object} isInitialize
|
||||||
|
Run Keyword If "${return}"=="FAIL" or "${isInitialize}"=="${EMPTY}" Set To Dictionary ${returnDict} isInitialize=${Default_IsInitialize}
|
||||||
|
... ELSE Set To Dictionary ${returnDict} isInitialize=${isInitialize}
|
||||||
|
${return} ${isExclusion} Run Keyword And Ignore Error Get From Dictionary ${object} isExclusion
|
||||||
|
Run Keyword If "${return}"=="FAIL" or "${isExclusion}"=="${EMPTY}" Set To Dictionary ${returnDict} isExclusion=${Default_IsExclusion}
|
||||||
|
... ELSE Set To Dictionary ${returnDict} isExclusion=${isExclusion}
|
||||||
|
${return} ${objectName} Run Keyword And Ignore Error Get From Dictionary ${object} objectName
|
||||||
|
Run Keyword If "${return}"=="FAIL" or "${objectName}"=="${EMPTY}" Set To Dictionary ${returnDict} objectName=${Default_ObjectName}
|
||||||
|
... ELSE Set To Dictionary ${returnDict} objectName=${objectName}
|
||||||
|
${return} ${objectDesc} Run Keyword And Ignore Error Get From Dictionary ${object} objectDesc
|
||||||
|
Run Keyword If "${return}"!="FAIL" and "${objectDesc}"!="${EMPTY}" Set To Dictionary ${returnDict} objectDesc=${objectDesc}
|
||||||
|
... ELSE Set To Dictionary ${returnDict} objectDesc=${Default_ObjectDesc}
|
||||||
|
${return} ${subObjectIds} Run Keyword And Ignore Error Get From Dictionary ${object} subObjectIds
|
||||||
|
${subObjectIdsV} Run Keyword If "${return}"!="FAIL" and "${subObjectIds}"!="${EMPTY}" and "${subObjectIds}"!="${None}" Evaluate list(map(int, re.split('[,]', '${subObjectIds}'))) re
|
||||||
|
... ELSE Set Variable ${emptyList}
|
||||||
|
Set To Dictionary ${returnDict} subObjectIds=${subObjectIdsV}
|
||||||
|
|
||||||
|
# 处理AddItemList
|
||||||
|
${return} ${addItemList} Run Keyword And Ignore Error Get From Dictionary ${object} addItemList
|
||||||
|
Run Keyword If "${return}"!="FAIL" and "${addItemList}"!="${EMPTY}" ManageAddItemList ${object} ${returnDict}
|
||||||
|
|
||||||
|
# 处理UpdateItemList
|
||||||
|
${return} ${updateItemList} Run Keyword And Ignore Error Get From Dictionary ${object} updateItemList
|
||||||
|
Run Keyword If "${opAction}"=="update" and "${return}"!="FAIL" and "${updateItemList}"!="${EMPTY}" ManageUpdateItemList ${updateItemList} ${returnDict}
|
||||||
|
# 处理deleteItemIds
|
||||||
|
${return} ${deleteItemIds} Run Keyword And Ignore Error Get From Dictionary ${object} deleteItemIds
|
||||||
|
Run Keyword If "${opAction}"=="update" and "${return}"!="FAIL" and "${deleteItemIds}"!="${EMPTY}" ManageDeleteItemIds ${deleteItemIds} ${returnDict}
|
||||||
|
# 转为json结构并返回
|
||||||
|
${json} json.Dumps ${returnDict} ensure_ascii=False
|
||||||
|
Log Object-${json}
|
||||||
|
[Return] ${json}
|
||||||
|
ManageEnableAndDisable
|
||||||
|
[Documentation]
|
||||||
|
... 启用与禁用时调用
|
||||||
|
[Arguments] ${object} ${returnDict} ${opAction}
|
||||||
|
Run Keyword If "${opAction}"=="enable" Set To Dictionary ${returnDict} isValid=1
|
||||||
|
Run Keyword If "${opAction}"=="disable" Set To Dictionary ${returnDict} isValid=0
|
||||||
|
${json} json.Dumps ${returnDict} ensure_ascii=False
|
||||||
|
Log Object-${json}
|
||||||
|
[Return] ${json}
|
||||||
|
ManageUpdateItemList
|
||||||
|
[Documentation]
|
||||||
|
... 处理updateItemList
|
||||||
|
[Arguments] ${updateItemList} ${returnDict}
|
||||||
|
Set To Dictionary ${returnDict} updateItemList=${updateItemList}
|
||||||
|
ManageDeleteItemIds
|
||||||
|
[Documentation]
|
||||||
|
... 处理deleteItemIds
|
||||||
|
... ${1},${2},${3} -> [1,2,3]
|
||||||
|
[Arguments] ${deleteItemIds} ${returnDict}
|
||||||
|
${list} Evaluate re.split('[,]', '${deleteItemIds}') re
|
||||||
|
${list1} Create List
|
||||||
|
FOR ${var} IN @{list}
|
||||||
|
${var} Run Keyword If '${var}'.isdigit() Evaluate int('${var}')
|
||||||
|
... ELSE Set Variable ${var}
|
||||||
|
Append To List ${list1} ${var}
|
||||||
|
END
|
||||||
|
Set To Dictionary ${returnDict} deleteItemIds=${list1}
|
||||||
|
WxGet-ObjectIds
|
||||||
|
[Documentation]
|
||||||
|
... 获取结果中的对象ID
|
||||||
|
[Arguments] ${value}
|
||||||
|
Log Call WxGet-ObjectIds
|
||||||
|
${objectIds} Create List
|
||||||
|
${objectIdsTemp} Set Variable ${EMPTY}
|
||||||
|
${return} ${data} Run Keyword And Ignore Error Get From Dictionary ${value} data
|
||||||
|
Return From Keyword If "${return}"=="FAIL" ${objectIdsTemp}
|
||||||
|
|
||||||
|
FOR ${object} IN @{value['data']['objectList']}
|
||||||
|
Append To List ${objectIds} ${object['objectId']}
|
||||||
|
END
|
||||||
|
${json} json.Dumps ${objectIds} ensure_ascii=False
|
||||||
|
${json} Remove String ${json} [
|
||||||
|
${json} Remove String ${json} ]
|
||||||
|
[Return] ${json}
|
||||||
Reference in New Issue
Block a user