feat:(策略对象)1:策略对象删除;2:策略对象导入;3:策略对象导出
This commit is contained in:
@@ -556,4 +556,29 @@ Policy-log-v1-00028
|
||||
... conditions=common_server_port|int|in|${80}^${8080}
|
||||
... orderBy=common_server_ip|true
|
||||
... common_log_ids=162273027957354498
|
||||
${resData} QueryLogs ${params} batch
|
||||
${resData} QueryLogs ${params} batch
|
||||
Policy-Delete-v1-00029
|
||||
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}
|
||||
${objectIds} Evaluate list(map(int, re.split('[,]', '${objectIds}'))) re
|
||||
${rescode} DeleteObjects ${objectIds}
|
||||
${objectIds} Set Variable ${EMPTY}
|
||||
Policy-Import-v1-00030
|
||||
Comment 导入txt
|
||||
${objectIds} Set Variable ${EMPTY}
|
||||
${rescode} ImportObject uploadFiles url.txt url ${EMPTY} ${EMPTY}
|
||||
Policy-Import-v1-00031
|
||||
Comment 导入csv
|
||||
${objectIds} Set Variable ${EMPTY}
|
||||
${rescode} ImportObject uploadFiles url.csv url ${EMPTY} ${EMPTY}
|
||||
Policy-Import-v1-00032
|
||||
Comment 导入csv
|
||||
${objectIds} Set Variable ${EMPTY}
|
||||
${rescode} ImportObject uploadFiles IP.csv ip endpoint ${EMPTY}
|
||||
Policy-Export-v1-00032
|
||||
Comment 导 出json
|
||||
${objectIds} Set Variable ${EMPTY}
|
||||
${response} ExportObject ip endpoint ${EMPTY} ${EMPTY}
|
||||
@@ -181,4 +181,18 @@ BasePostRequestReturnBinary
|
||||
${response} Post Request api ${requestUri} data=${data}
|
||||
log return data =${response}
|
||||
Should Be Equal As Strings ${response.status_code} 200
|
||||
[Return] ${response.content}
|
||||
BaseGetRequestReturnBinary
|
||||
[Documentation]
|
||||
... 下载文件专用
|
||||
... 返回二进制数据
|
||||
[Arguments] ${requestUri} ${data} ${apiVersion}
|
||||
Log Call BasePostRequestReturnBinary
|
||||
${headers} set variable {"Authorization":"${token}","Content-Type":"application/json"}
|
||||
${dataString} Dictionary-To-QueryParams ${data}
|
||||
create session api http://${host}:${port}/${apiVersion} ${headers}
|
||||
Log ${data}
|
||||
${response} Get Request api ${requestUri}?${dataString}
|
||||
log return data =${response}
|
||||
Should Be Equal As Strings ${response.status_code} 200
|
||||
[Return] ${response.content}
|
||||
@@ -69,4 +69,61 @@ GetObjectItems
|
||||
FOR ${item} IN @{data['list']}
|
||||
Append To List ${itemIds} ${item['itemId']}
|
||||
END
|
||||
[Return] ${rescode} ${itemIds} ${data['list']}
|
||||
[Return] ${rescode} ${itemIds} ${data['list']}
|
||||
DeleteObjects
|
||||
[Documentation]
|
||||
... 删除策略对象
|
||||
... params,传入的删除字典
|
||||
... 结构为[1,2,3]
|
||||
[Arguments] ${objectIds}
|
||||
${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
|
||||
[Documentation]
|
||||
... 策略对象导入
|
||||
... filePath文件路径
|
||||
... fileName文件名称
|
||||
... objectType对象类型
|
||||
... objectSubType对象子类型
|
||||
... objectName对象名称
|
||||
[Arguments] ${filePath} ${fileName} ${objectType} ${objectSubType} ${objectName}
|
||||
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}
|
||||
${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}
|
||||
ExportObject
|
||||
[Documentation]
|
||||
... 策略对象导出
|
||||
... objectType ip,url等
|
||||
... objectSubType 子类型
|
||||
... objectIds 1,2,3
|
||||
... objectName 字符串
|
||||
[Arguments] ${objectType} ${objectSubType} ${objectIds} ${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}
|
||||
1
05-Other/uploadFiles/IP.csv
Normal file
1
05-Other/uploadFiles/IP.csv
Normal file
@@ -0,0 +1 @@
|
||||
192.168.41.67/32#8080
|
||||
|
1
05-Other/uploadFiles/url.csv
Normal file
1
05-Other/uploadFiles/url.csv
Normal file
@@ -0,0 +1 @@
|
||||
*.kuaishou.com
|
||||
|
1
05-Other/uploadFiles/url.txt
Normal file
1
05-Other/uploadFiles/url.txt
Normal file
@@ -0,0 +1 @@
|
||||
*.google.com
|
||||
Reference in New Issue
Block a user