summaryrefslogtreecommitdiff
path: root/keyword/objects/object.robot
diff options
context:
space:
mode:
Diffstat (limited to 'keyword/objects/object.robot')
-rw-r--r--keyword/objects/object.robot513
1 files changed, 513 insertions, 0 deletions
diff --git a/keyword/objects/object.robot b/keyword/objects/object.robot
new file mode 100644
index 0000000..2ae994a
--- /dev/null
+++ b/keyword/objects/object.robot
@@ -0,0 +1,513 @@
+*** Settings ***
+Library Collections
+Library RequestsLibrary
+Resource ../../variable/common_variable.txt
+Resource ../common/functional_keywords.robot
+Resource process_object_body.robot
+Library Collections
+Resource ../common/common.robot
+#Library ../../../04-CustomLibrary/Library/fileOperations.py
+Library DatabaseLibrary
+
+*** Variables ***
+${objectUrl} /policy/object
+${categoryUrl} /category/dict
+${applicationDictUrl} /application/update/dict
+${fileUploaduRL} /system/feature/update/
+
+*** Keywords ***
+AddLocalIPObject
+ #创建对象IP
+ log to_AddLocalIPObject
+ Comment 创建IP
+ #object为IP→endpoint时的addItemList单个对象
+ ${addItemList1} Create Dictionary isSession=endpoint ip=${testClentIP} port=0-65535 direction=0 protocol=0 isInitialize=0
+ #可以添加多个
+ ${addItemLists} Create list ${addItemList1}
+ #objectList对象
+ ${objectDict} Create Dictionary objectType=ip objectSubType=endpoint isValid=${1} addItemList=${addItemLists}
+ ${rescode} ${objectId1} AddObjects ${1} ${objectDict}
+ SET GLOBAL VARIABLE ${testClentID} ${objectId1}
+ Comment 创建SubId
+ log to_AddLocalSubidObject
+ #可以添加多个
+ ${addItemList1} Create Dictionary keywordArray=${testSubscriberID} isHexbin=${0}
+ ${addItemLists} Create list ${addItemList1}
+ ${objectDict} Create Dictionary objectType=subscriberid objectSubType=subscriberid objectName=autotest_localSubId_${testSubscriberID} isValid=${1} addItemList=${addItemLists}
+ ${rescode} ${subiid} AddObjects ${1} ${objectDict}
+ #log ${subiid}
+ log LocalSubIP:${subiid}
+ SET GLOBAL VARIABLE ${testClentSubID} ${subiid}
+ Comment 创建mobile_identity-imsi
+ ${addItemList1} Create Dictionary keywordArray=${imsi} isHexbin=${0}
+ ${addItemLists} Create list ${addItemList1}
+ ${objectDict} Create Dictionary objectType=mobile_identity objectSubType=imsi isValid=${1} addItemList=${addItemLists}
+ ${rescode} ${imsi_id} AddObjects ${1} ${objectDict}
+ InsertObjectIdToFile global_imsi_id ${imsi_id}
+ SET GLOBAL VARIABLE ${object_imsi_id} ${imsi_id}
+ Comment 创建mobile_identity-phone_number
+ ${addItemList1} Create Dictionary keywordArray=${phone_number1} isHexbin=${0}
+ ${addItemList2} Create Dictionary keywordArray=${phone_number2} isHexbin=${0}
+ ${addItemList3} Create Dictionary keywordArray=${phone_number3} isHexbin=${0}
+ ${addItemList4} Create Dictionary keywordArray=${phone_number4} isHexbin=${0}
+ ${addItemLists} Create list ${addItemList1} ${addItemList2} ${addItemList3} ${addItemList4}
+ ${objectDict} Create Dictionary objectType=mobile_identity objectSubType=phone_number isValid=${1} addItemList=${addItemLists}
+ ${rescode} ${phoneNum_id} AddObjects ${1} ${objectDict}
+ InsertObjectIdToFile global_phoneNum_id ${imsi_id}
+ SET GLOBAL VARIABLE ${obj_phoneNum_Id} ${phoneNum_id}
+ Comment 创建apn
+ ${addItemList1} Create Dictionary keywordArray=${apn1} isHexbin=${0}
+ ${addItemList2} Create Dictionary keywordArray=${apn2} isHexbin=${0}
+ ${addItemLists} Create list ${addItemList1} ${addItemList2}
+ ${objectDict} Create Dictionary objectType=apn objectSubType=apn isValid=${1} addItemList=${addItemLists}
+ ${rescode} ${apn_id} AddObjects ${1} ${objectDict}
+ InsertObjectIdToFile global_apn_id ${imsi_id}
+ SET GLOBAL VARIABLE ${obj_apn_Id} ${apn_id}
+
+AddObjects
+ [Arguments] ${returnData} ${objectList}
+ [Documentation] 新增策略对象
+ ... objectList,策略对象,可为list类型与dict类型
+ ... addItemList自动过滤itemId
+ ... updateItemList自动过滤isInitialize(update时该字段引发异常)
+ ... ipItem格式为dict,自动过滤空的字段
+ ... stringItem格式为dict,需要注意keywordArray字段应传入逗号分隔的字符串eg: keyword1,keyword2
+ ... http_signature为代表的拓展关键字keywordArray字段也是以逗号分隔的
+ ... returnData,是否返回数据,固定为1
+ ${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'>" ObjectListOperation ${returnData} ${objectList} add
+ ... ELSE IF "${dictType}" == "<class 'dict'>" ObjectOperation ${returnData} ${objectList} add
+ ... ELSE Set Variable ${EMPTY}
+ ${response} BasePostRequestForV2 ${objectUrl} ${body} ${version}
+ ${objectIds} Run Keyword If "${returnData}" == "1" GetObjectIds ${response}
+ ... ELSE Create List
+ ${rescode} Set Variable ${response['code']}
+ Should Be Equal As Strings ${rescode} 200
+ [Return] ${rescode} ${objectIds}
+
+UpdateObjects
+ [Arguments] ${returnData} ${objectList} ${opAction}
+ [Documentation] 更新策略对象
+ ... objectList,策略对象,可为list类型与dict类型
+ ... addItemList自动过滤itemId
+ ... updateItemList自动过滤isInitialize(update时该字段引发异常)
+ ... ipItem格式为dict,自动过滤空的字段
+ ... stringItem格式为dict,需要注意keywordArray字段应传入逗号分隔的字符串eg: keyword1,keyword2
+ ... http_signature为代表的拓展关键字keywordArray字段也是以逗号分隔的
+ ... returnData,是否返回数据,固定为1
+ ... opAction,可为update,enable,disable
+ ${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'>" ObjectListOperation ${returnData} ${objectList} ${opAction}
+ ... ELSE IF "${dictType}" == "<class 'dict'>" ObjectOperation ${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}
+
+UpdateInstall
+ [Arguments] ${updateDict}
+ [Documentation] 更新策略对象
+ ... objectList,策略对象,可为list类型与dict类型
+ ... addItemList自动过滤itemId
+ ... updateItemList自动过滤isInitialize(update时该字段引发异常)
+ ... ipItem格式为dict,自动过滤空的字段
+ ... stringItem格式为dict,需要注意keywordArray字段应传入逗号分隔的字符串eg: keyword1,keyword2
+ ... http_signature为代表的拓展关键字keywordArray字段也是以逗号分隔的
+ ... returnData,是否返回数据,固定为1
+ ... opAction,可为update,enable,disable
+ #必选参数判定
+ Should Not Be Empty ${updateDict}
+ ${bodyJson} json.Dumps ${updateDict} ensure_ascii=False
+ ${response} BaseEditRequestForV2 ${fileUploaduRL} ${body} ${version}
+ ${rescode} Set Variable ${response['code']}
+ Should Be Equal As Strings ${rescode} 200
+ [Return] ${rescode}
+
+GetObjectItems
+ [Arguments] ${params}
+ [Documentation] 获取策略对象中的item,策略对象单元
+ ... 当updateItemList中有需要传入数据时
+ ... 调用此关键字
+ #必选参数判定
+ Should Not Be Empty ${params}
+ ${paramsStr} DictionaryToQueryParams ${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']}
+
+GetObjectItems1
+ [Arguments] ${params}
+ [Documentation] 获取策略对象中的item,策略对象单元
+ ... 当updateItemList中有需要传入数据时
+ ... 调用此关键字
+ #必选参数判定
+ Should Not Be Empty ${params}
+ ${paramsStr} DictionaryToQueryParams ${params}
+ ${response} BaseFormRequest /policy/items ${paramsStr} ${version}
+ ${rescode} Set Variable ${response['code']}
+ Should Be Equal As Strings ${rescode} 200
+ ${data} Set Variable ${response['data']}
+ [Return] ${rescode} ${data}
+
+DeleteObjectByIds
+ [Arguments] ${objectIds}
+ [Documentation] 删除策略对象
+ ... params,传入的删除字典
+ ... 结构为[1,2,3]
+ ${type} Evaluate isinstance(${objectIds},list)
+ Should Be True ${type}
+ ${dict} Create Dictionary objectIds=${objectIds}
+ ${json} json.Dumps ${dict} ensure_ascii=False
+ ${response} BaseDeleteRequest /${version}${objectUrl} ${json}
+ ${rescode} Set Variable ${response['code']}
+ Should Be Equal As Strings ${rescode} 200
+ [Return] ${rescode}
+
+ImportObject
+ [Arguments] ${filePath} ${fileName} ${objectType} ${objectSubType} ${objectName}
+ [Documentation] 策略对象导入
+ ... filePath文件路径
+ ... fileName文件名称
+ ... objectType对象类型
+ ... objectSubType对象子类型
+ ... objectName对象名称
+ ... jira CHON-12导入限制需求支持
+ Directory Should Exist ${path}
+ File Should Exist ${path}/${filePath}/${fileName}
+ File Should Not Be Empty ${path}/${filePath}/${fileName}
+ ${size} Get File Size ${path}/${filePath}/${fileName}
+ Should Not Be Empty ${objectType}
+ #获取Item 的总数
+ ${total} GetItemNum ${objectType} ${objectSubType}
+ #获取导入文件中的总行数
+ #${lines} CountLines ${path}/${filePath}/${fileName}
+ ${lines} CountLines ${path}/${filePath}/${fileName}
+ #总数超过一定数据量测试不通过
+ ${total1} Evaluate ${total}+${lines}
+ #链接数据库查询上限
+ Connect To Database Using Custom Params pymysql ${mysqlHost}
+ ${objectLimit} query SELECT cfg_value FROM t_sys_cfg WHERE cfg_name='${objectType}_upper_limit'
+ ${objectLimit} Set Variable ${objectLimit[0][0]}
+ ${remaining} Evaluate ${objectLimit}-${total}
+ log ${objectType}剩余可导入量为:${remaining}
+ ${testType} Evaluate type($objectLimit)
+ Disconnect From Database
+ #jira CHON-12导入限制需求支持
+ Run Keyword If "${objectType}"=="url" and ${total1}>${objectLimit} log 当前已经存在item个数${total},待导入个数${lines},总数超过${objectLimit}条!
+ ... ELSE IF ${total1}>${objectLimit} log 当前已经存在item个数${total},待导入个数${lines},总数超过${objectLimit}条!
+ ${objectSubType} Run Keyword If "${objectType}"=="ip" and "${objectSubType}"=="${EMPTY}" Set Variable endpoint
+ ... ELSE Set Variable ${objectSubType}
+ ${subfix} Fetch From Right ${fileName} .
+ ${binFile} Run Keyword If "${subfix}"=="txt" Evaluate (r'${fileName}',open(r"${path}/${filePath}/${fileName}",'rb'),'text/plain')
+ ... ELSE IF "${subfix}"=="csv" Evaluate (r'${fileName}',open(r"${path}/${filePath}/${fileName}",'rb'),'application/vnd.ms-excel')
+ ... ELSE ${EMPTY}
+ ${data} Create Dictionary objectType=${objectType}
+ Run Keyword If "${objectSubType}"!="${EMPTY}" Set To Dictionary ${data} objectSubType=${objectSubType}
+ Run Keyword If "${objectName}"!="${EMPTY}" Set To Dictionary ${data} objectName=${objectName}
+ ${file} Create Dictionary file=${binFile}
+ ${response} BaseMultipartPostRequest ${objectUrl}/batch ${data} ${file} ${version}
+ ${rescode} Set Variable ${response['code']}
+ Should Be Equal As Strings ${rescode} 200
+ [Return] ${rescode} ${objectType} ${response}
+
+ImportApplication
+ [Arguments] ${filePath} ${fileName} ${feature} ${code}
+ [Documentation] 策略对象导入
+ ... filePath文件路径
+ ... fileName文件名称
+ ... feature是特征
+ Directory Should Exist ${path}
+ File Should Exist ${path}/${filePath}/${fileName}
+ File Should Not Be Empty ${path}/${filePath}/${fileName}
+ ${size} Get File Size ${path}/${filePath}/${fileName}
+ ${binFile} Run Keyword If "${feature}"=="${EMPTY}" Evaluate (r'${fileName}',open(r"${path}/${filePath}/${fileName}",'rb'),'application/xml')
+ ... ELSE IF "${feature}"=="app_library" or "${feature}"=="app_signature" Evaluate (r'${fileName}',open(r"${path}/${filePath}/${fileName}",'rb'),'application/octet-stream')
+ ... ELSE ${EMPTY}
+ ${file} Create Dictionary file=${binFile}
+ # ${response} BaseMultipartPostRequest ${objectUrl}/batch ${EMPTY} ${file} ${version}
+ ${response} Run Keyword If "${feature}"=="${EMPTY}" BaseMultipartPostRequest ${applicationDictUrl} ${EMPTY} ${file} ${version}
+ ... ELSE IF "${feature}"=="app_library" or "${feature}"=="app_signature" BaseMultipartPostRequest ${fileUploaduRL} ${EMPTY} ${file} ${version}
+ ${rescode} Set Variable ${response['code']}
+ Should Be Equal As Strings ${rescode} ${code}
+
+
+ExportObject
+ [Arguments] ${objectType} ${objectSubType} ${objectIds} ${objectName}
+ [Documentation] 策略对象导出
+ ... objectType ip,url等
+ ... objectSubType 子类型
+ ... objectIds 1,2,3
+ ... objectName 字符串
+ Should Not Be Empty ${objectType}
+ ${params} Create Dictionary objectType=${objectType}
+ Run Keyword If "${objectSubType}"!="${EMPTY}" Set To Dictionary ${params} objectSubType=${objectSubType}
+ Run Keyword If "${objectIds}"!="${EMPTY}" Set To Dictionary ${params} objectIds=${objectIds}
+ Run Keyword If "${objectName}"!="${EMPTY}" Set To Dictionary ${params} objectName=${objectName}
+ ${response} BaseGetRequestReturnBinary ${objectUrl}/batch ${params} ${version}
+ [Return] ${response}
+
+GetItemNum
+ [Arguments] ${objectType} ${objectSubType}
+ [Documentation] 获取策略对象单元总数
+ ${getTotal} Create Dictionary pageNo=${1} pageSize=${1}
+ Run Keyword If "${objectType}"=="ip" and "${objectSubType}"=="endpoint" Set To Dictionary ${getTotal} itemType=IP
+ ... ELSE IF "${objectType}"=="ip" and "${objectSubType}"=="geo_location" Set To Dictionary ${getTotal} itemType=geo_location
+ ... ELSE IF "${objectType}"=="ip" and "${objectSubType}"=="as_number" Set To Dictionary ${getTotal} itemType=as_number
+ ... ELSE IF "${objectType}"=="url" Set To Dictionary ${getTotal} itemType=URL
+ ... ELSE Set To Dictionary ${getTotal} itemType=${objectType}
+ ${rescode} ${data} GetObjectItems1 ${getTotal}
+ ${total} Set Variable ${data['total']}
+ Run Keyword If "${objectType}"=="fqdn_category" Set To Dictionary ${getTotal} isInitialize=1
+ ${rescode} ${data} Run Keyword If "${objectType}"=="fqdn_category" GetObjectItems1 ${getTotal}
+ ... ELSE Set Variable ${rescode} ${data}
+ ${total} Run Keyword If "${objectType}"=="fqdn_category" Evaluate ${total} - ${data['total']}
+ ... ELSE Set Variable ${total}
+ [Return] ${total}
+
+CountLines1
+ [Arguments] ${file}
+ [Documentation] 获取文件总行数
+ ${count} Set Variable ${0}
+ ${openFile} Evaluate enumerate(open(r"${file}",'r'))
+ FOR ${line} IN @{openFile}
+ ${val} Run Keyword If "${line[0]}"=="0" Set Variable ${line[1]}
+ ... ELSE Set Variable ${EMPTY}
+ ${val2} Run Keyword If "${line[1]}"=="\n" Set Variable ${line[0]}
+ ... ELSE Set Variable ${EMPTY}
+ log ${line}
+ log "${line[1]}"
+ ${match} Get Regexp Matches ${val} ^-->
+ #${match2} Get Regexp Matches ${val} ^(\t)*$\n
+ ${len} Get Length ${match}
+ #${len2} Get Length ${match2}
+ ${count} Run Keyword If "${line[0]}"=="0" and ${len}>0 Set Variable ${count}
+ ... ELSE Evaluate ${count}+1
+ END
+ [Return] ${count}
+
+PolicProtocolFields
+ [Arguments] ${policyType} ${protocol} ${objectType}
+ [Documentation] 策略对象生效协议字段查询
+ ... policyType策略类型
+ ... protocol协议
+ ... objectType对象类型
+ ${dict} Create Dictionary
+ Run Keyword If "${policyType}"!="${EMPTY}" Set To Dictionary ${dict} policyType=${policyType}
+ Run Keyword If "${protocol}"!="${EMPTY}" Set To Dictionary ${dict} protocol=${protocol}
+ Run Keyword If "${objectType}"!="${EMPTY}" Set To Dictionary ${dict} objectType=${objectType}
+ ${parmStr} DictionaryToQueryParams ${dict}
+ ${response} BaseFormRequest ${objectUrl}/protocolFields ${parmStr} ${version}
+ ${rescode} Set Variable ${response['code']}
+ Should Be Equal As Strings ${rescode} 200
+ [Return] ${response['data']}
+
+ObjectReference
+ [Arguments] ${objectId}
+ [Documentation] 策略对象相关性查询
+ ${response} BaseFormRequest ${objectUrl}/reference objectId=${objectId} ${version}
+ ${rescode} Set Variable ${response['code']}
+ Should Be Equal As Strings ${rescode} 200
+ [Return] ${response['data']}
+
+AppIdTreeSearch
+ [Arguments] ${referenceObjectId}
+ [Documentation] App ID对象树查询
+ ${response} BaseFormRequest ${objectUrl}/appId/tree referenceObjectId=${referenceObjectId} ${version}
+ ${rescode} Set Variable ${response['code']}
+ Should Be Equal As Strings ${rescode} 200
+ [Return] ${response['data']}
+
+AddCategories
+ [Arguments] ${returnData} ${categoryList} ${opAction} ${testCode}=null
+ [Documentation] 新增Category
+ ... returnData,是否返回数据,固定为1
+ Comment 此处思路给category单独的另一套关键字,原因:地址与json串名称与Object部分不同了
+ ${returnData}= Run Keyword If '${returnData}' == '${EMPTY}' Set Variable 1
+ ... ELSE Set Variable ${returnData}
+ #必选参数判定
+ Should Not Be Empty ${categoryList}
+ ${dictType} = Evaluate type(${categoryList})
+ ${body} Run Keyword If "${dictType}" == "<class 'list'>" CategoryListOperation ${returnData} ${categoryList} ${opAction}
+ ... ELSE IF "${dictType}" == "<class 'dict'>" CategoryOperation ${returnData} ${categoryList} ${opAction}
+ ... ELSE Set Variable ${EMPTY}
+
+ log ${body}
+ # ${response} BasePostRequestForV2 ${categoryUrl} ${body} ${version}
+ ${response} Run Keyword If "${opAction}"=="add" BasePostRequestForV2 ${categoryUrl} ${body} ${version}
+ ... ELSE IF "${opAction}"=="update" BaseEditRequestForV2 ${categoryUrl} ${body} ${version}
+ ${CategoryObjIds} Run Keyword If "${returnData}" == "1" and ${testCode} == 200 and "${opAction}"=="add" GetCategoryObjIds ${response}
+ ... ELSE Set Variable ${EMPTY}
+ ${CategoryIds} Run Keyword If "${returnData}" == "1" and ${testCode} == 200 and "${opAction}"=="add" GetCategoryIds ${response}
+ ... ELSE Set Variable ${EMPTY}
+ ${rescode} Set Variable ${response['code']}
+ Should Be Equal As Strings ${rescode} ${testCode}
+ [Return] ${rescode} ${CategoryObjIds} ${CategoryIds}
+
+QueryUpadateRecord
+ [Arguments] ${body} ${code}
+ ${response} BaseGetRequestOK /${version}/system/feature/update body=${body}
+ log ${response}
+ ${rescode} Set Variable ${response['code']}
+ Shoule Be Equal As Strings ${rescode} ${code}
+ [Return] ${rescode}
+
+DeleteCategoryByIds
+ [Arguments] ${categoryids}
+ #删除对象
+ log todeleteobjAndCategory
+ ${response} BaseDeleteRequest /${version}/category/dict {"categoryIds":[${categoryids}]}
+ ${response_code} Get From Dictionary ${response} code
+ Should Be Equal As Strings ${response_code} 200
+ ${response} Convert to String ${response}
+ log ${response}
+DelLocalIPObject
+ log to_DelLocalIPObject
+
+ ${emptyList} Create List
+ ${objectId1} Set Variable [${testClentID},${testClentSubID}]
+ ${objectId1} json.loads ${objectId1}
+ # ${objectId1} Create List [${testClentID},${testClentSubID},${object_imsi_id},${obj_phoneNum_Id},${obj_apn_Id}]
+ DeleteObjectByIds ${objectId1}
+ SET GLOBAL VARIABLE ${testClentID} ${EMPTY}
+ SET GLOBAL VARIABLE ${testClentSubID} ${EMPTY}
+###############################################################################
+#数据分离,测试数据来自对应的yaml文件
+ObjectsByTemplate
+ [Documentation] 根据测试数据文件,使用对应公共模板,创建对象
+ ... 入参:${dataFilePath}数据文件,全路径文件名 ${keyword}测试用例名称
+ ... data数据文件格式参照:other/data/object/demo_data.yaml
+ ... 返回数据:对象idlist${objectIds},格式:[107582, 107583]
+ ... 返回数据:策略id+类型list${policyIds},格式:[{'objectId': 107582, 'protocolField': 'TSG_SECURITY_SOURCE_ADDR'},{'objectId': 107583, 'protocolField': 'TSG_SECURITY_SOURCE_ADDR'}]
+ [Arguments] ${dataFilePath} ${keyword}
+ ${yamlData}= Get File ${dataFilePath}
+ ${loadedData}= yaml.Safe Load ${yamlData}
+ ${list} Get From Dictionary ${loadedData} ${keyword}_data
+ ${objectIds} Create List
+ Comment 循环创建策略
+ FOR ${key} IN @{list}
+ LOG passssssssss
+ ${objectId} ${objectList} Run Keyword And Continue On Failure CreateObjectList ${key} ${keyword}
+ #返回的对象和策略信息添加到对象和策略列表
+ Run Keyword If "${objectId}" !="None" AppendListToList ${objectIds} ${objectId}
+ END
+ [Return] ${objectIds}
+OrangeFilter
+ [Documentation] filer对象处理,把一个filter的list处理为一个filter
+ #[Arguments] ${filterList} ${objectList}
+ [Arguments] ${objectList}
+ ${list} Create List ${objectList}
+ ${filter} Create Dictionary filter=${list}
+ #${filterList} Append To List ${filter}
+ [Return] ${filter}
+
+CreateObjectList
+ [Documentation] 处理对象
+ [Arguments] ${objectData} ${keyword}=${EMPTY}
+ Comment 针对位置进行处理
+ ${return} ${protocolField} Run Keyword And Ignore Error Get From Dictionary ${objectData} protocolField
+ #${objList} Get From Dictionary ${objectData} objList
+
+ ${objectIds} ${objectList} CreateObjects ${objectData}
+ ${objectList} Run Keyword If "${return}"=="FAIL" Set Variable ${objectList}
+ ... ELSE IF "${protocolField}" == "TSG_SECURITY_SOURCE_ADDR" or "${protocolField}" == "None" or "${protocolField}" == "TSG_SECURITY_SOURCE_LOCATION" or "${protocolField}" == "TSG_SECURITY_SOURCE_ASN" or "${protocolField}" == "TSG_FILED_GTP_IMSI" or "${protocolField}" == "TSG_FILED_GTP_PHONE_NUMBER" or "${protocolField}" == "TSG_FILED_GTP_APN" Set Variable ${objectList}
+ ##############destination
+ ... ELSE IF "${protocolField}" == "TSG_SECURITY_DESTINATION_ADDR" or "${protocolField}" == "TSG_SECURITY_DESTINATION_LOCATION" or "${protocolField}" == "TSG_SECURITY_DESTINATION_ASN" Set Variable ${objectList}
+ #filter
+ ... ELSE OrangeFilter ${objectList}
+ [Return] ${objectIds} ${objectList}
+CreateObjects
+ [Documentation] 处理对象
+ [Arguments] ${objectData}
+ Comment 针对位置进行处理
+ #${YAML}= Get File ${path}/data/mode.yaml
+ #${LOADED}= yaml.Safe Load ${YAML}
+ #${ipMode} Get From Dictionary ${LOADED} ip_batch_mode
+ ${return} ${protocolField} Run Keyword And Ignore Error Get From Dictionary ${objectData} protocolField
+ ${objList} Get From Dictionary ${objectData} objectList
+
+ Comment ${objJson}对象模板取自全局变量
+ ${objJson} Set Variable ${objModeJson}
+ ${objectJson} Set Variable ${objListMode}
+ #JSON处理
+ ${return} ${objectType} Run Keyword And Ignore Error Get From Dictionary ${objectData} objectType
+ ${objectJson} = Run Keyword If "${return}"!="FAIL" and "${objectType}" != "None" Replace String ${objectJson} "objectType": "ip" "objectType":"${objectType}"
+ ... ELSE Set Variable ${objectJson}
+ ${return} ${objectSubType} Run Keyword And Ignore Error Get From Dictionary ${objectData} objectSubType
+ #${objectSubType} Run Keyword If "${return}"!="FAIL" Set Variable ${objectSubType} ELSE Set Variable ${EMPTY}
+ ${objectJson} = Run Keyword If "${return}"!="FAIL" and "${objectSubType}" != "None" Replace String ${objectJson} "objectSubType": "endpoint" "objectSubType":"${objectSubType}"
+ ... ELSE Set Variable ${objectJson}
+ ${return} ${objectId} Run Keyword And Ignore Error Get From Dictionary ${objectData} objectId
+ ${objectJson} = Run Keyword If "${return}"!="FAIL" and "${objectId}" != "None" Replace String ${objectJson} "objectId": null "objectId":${objectId}
+ ... ELSE Set Variable ${objectJson}
+ ${objectJson} = Run Keyword If "${return}"!="FAIL" and "${objectId}" != "None" Replace String ${objectJson} "opAction": "add" "option": "update"
+ ... ELSE Set Variable ${objectJson}
+ #${objectId} Run Keyword If "${return}"!="FAIL" Set Variable ${objectId} ELSE Set Variable ${EMPTY}
+ #JSON处理
+ ${objectJsonList} Create List
+ ${objListType} = Evaluate type(${objList})
+ FOR ${obj} IN @{objList}
+ ${return} ${addItemList} Run Keyword And Ignore Error Get From Dictionary ${obj} addItemList
+ #${objectJson} Convert To String ${objectJson}
+ #${addItemList} Convert To String ${addItemList}
+ #${objectJson} josn.loads ${objectJson}
+ ${addItemList} json.Dumps ${addItemList}
+ #${objectJson} = Replace String ${objectJson} "addItemList": "addItemList":${itemList}
+ ${addItemList} = Run Keyword If "${return}"!="FAIL" and "${objectSubType}" == "ip_learning" Replace String ${addItemList} [{" "
+ ... ELSE Set Variable ${addItemList}
+ ${addItemList} = Run Keyword If "${return}"!="FAIL" and "${objectSubType}" == "ip_learning" Replace String ${addItemList} "}] "
+ ... ELSE Set Variable ${addItemList}
+ ${objectJson} = Run Keyword If "${return}"!="FAIL" and "${objectSubType}" == "ip_learning" Replace String ${objectJson} "addItemList": [null] "addItemList": [], ${addItemList}
+ ... ELSE IF "${return}"!="FAIL" Replace String ${objectJson} "addItemList": [null] "addItemList": ${addItemList}
+ ... ELSE Set Variable ${objectJson}
+ ${objectJson} = Replace String ${objectJson} [null] []
+ #提交接口返回id拼接
+
+ #Create File ${path}/test.txt ${objectJson}
+ #Append To File ${path}/test.txt ${objectJson}
+ ${objDictionary} json.loads ${objectJson}
+ AppendListToList ${objectJsonList} ${objDictionary}
+ END
+ ${objectData} Create Dictionary opAction=add returnData=1 objectList=${objectJsonList}
+ ${rescode} ${objectIds} CreateObject ${objectData}
+ Should Be Equal As Strings ${rescode} 200
+
+ ${protocolField} Run Keyword If "${protocolField}" != "None" Set Variable ${protocolField}
+ ${objectsList} Create List
+ FOR ${obj} IN @{objectIds}
+ ${objectList} Create Dictionary objectId=${objectIds}[0] protocolField=${protocolField}
+ Append To List ${objectsList} ${objectList}
+ END
+ [Return] ${objectIds} ${objectList}
+CreateObject
+ [Tags]
+ [Arguments] ${ipList}
+ Comment 参数${ipList}对象dict
+ Comment 创建IP
+ ${returnData} Get From Dictionary ${ipList} returnData
+ ${bodyJson} json.Dumps ${ipList}
+ #${bodyJson} = Replace String ${bodyJson} [null] []
+ ${response} BasePostRequestForV2 ${objectUrl} ${bodyJson} ${version}
+ ${objectIds} Run Keyword If "${returnData}" == "1" getObjectListIds ${response}
+ ... ELSE Create List
+ ${rescode} Set Variable ${response['code']}
+ Should Be Equal As Strings ${rescode} 200
+
+ ${objectIds} Run Keyword IF "${createObjectIds}" != "${EMPTY}" AppendListToList ${objectIds} ${createObjectIds}
+ ... ELSE Set Variable ${objectIds}
+ SET GLOBAL VARIABLE ${createObjectIds} ${objectIds}
+ [Return] ${rescode} ${objectIds} \ No newline at end of file