diff options
Diffstat (limited to 'keyword/common/log_variable.robot')
| -rw-r--r-- | keyword/common/log_variable.robot | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/keyword/common/log_variable.robot b/keyword/common/log_variable.robot new file mode 100644 index 0000000..dc12fb2 --- /dev/null +++ b/keyword/common/log_variable.robot @@ -0,0 +1,146 @@ +*** Settings ***
+Resource ../../variable/common_variable.txt
+Resource logschema.robot
+Library REST http://${host}:${port}
+Library RequestsLibrary
+Library OperatingSystem
+Library Collections
+Library string
+Library customlibrary/Custometest/log_contrast.py
+
+
+*** Keywords ***
+GetLogSchemaByType
+ [Documentation] 根据日志类型获取对应schema
+ ... ${logType}日志类型:
+ ... security_event_log:安全策略
+ ... proxy_event_log:代理策略
+ ... connection_record_log: 协议采集日志
+ ... radius_record_log radius:采集日志
+ ... active_defence_event_log:主动防御日志
+ ... voip_record_log:voip协议日志
+ ... transaction_record_log:事务日志
+ ... live_session_record_log:活跃会话日志
+ ... gtpc_record_log:gtp协议日志
+ ...
+ [Arguments] ${logType}
+ Set Headers {"Content-Type":"application/x-www-form-urlencoded","Authorization":"${token}"}
+ &{LogSchemaResponse}= GET /${version}/log/schema?logType=${logType}
+ log ${logType}
+ #Output Schema response body
+ Object response body
+ #Integer $.code 200
+ log ${LogSchemaResponse.body['data']}
+ #${field} Evaluate json.dumps(eval(str(${LogSchemaResponse.body['data']['fields']}))) json
+ [Return] ${LogSchemaResponse.body['data']}
+
+GetLogContentByKeyword
+ [Documentation] 根据关键字重schema获取对应内容
+ ... ${logSchema}schema内容
+ ... security_event_log:安全策略
+ ... proxy_event_log:代理策略
+ ... connection_record_log: 协议采集日志
+ ... radius_record_log radius:采集日志
+ ... active_defence_event_log:主动防御日志
+ ... voip_record_log:voip协议日志
+ ... transaction_record_log:事务日志
+ ... live_session_record_log:活跃会话日志
+ ... gtpc_record_log:gtp协议日志
+ ...
+ [Arguments] ${logSchema} ${keyword}
+ ${keyword} Run Keyword If "${keyword}"=="field" Set Veriable ${LogSchemaResponse.body['data']['fields']}
+ ... ELSE IF "${keyword}"=="field" Set Veriable ${LogSchemaResponse.body['data']['fields']}
+ ... ELSE Set Veriable ${LogSchemaResponse.body['data']['fields']}
+ ${content} Evaluate json.dumps(eval(str(${keyword}))) json
+ #${field} Evaluate json.dumps(eval(str(${LogSchemaResponse.body['data']['fields']}))) json
+ [Return] ${content}
+
+OrganizeLogCondition
+ [Documentation] 根据条件list组织条件
+ [Arguments] ${logname} ${startTime} ${endTime} ${field} ${filter}=
+ #${logname} ${startTime} ${endTime} ${client_ip} ${policy_id}
+ ${pageSize} Set Variable 30
+ ${pageNo} Set Variable 1
+ ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","fields":${field},"start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}", "filter":"${filter}"}
+ log this time query condition:${logCondition}
+ [Return] ${filds}
+
+LogVeriable
+ [Arguments] ${logType} ${startTime} ${endTime} ${filter}
+ ${logSchema} GetLogSchemaByType ${logType}
+ ${filds} GetLogContentByKeyword ${logSchema} field
+ ${logCondition} OrganizeLogCondition ${logname} ${startTime} ${endTime} ${filds} ${filter}
+ #common_client_ips":"${client_ip}" and "common_policy_ids":"${policy_id}
+ ${logs} GetLogList ${logType} ${logCondition}
+ ${returnvalue} log_contrast ${logs} ${client_ip} ${policy_id} ${parmkey} ${parmvalue}
+ ${trueorfalse} Run Keyword If "${returnvalue}"=="true" set variable true
+ ... ELSE set variable false
+ Run Keyword If "${returnvalue}"=="true" Exit for loop
+ [Return] ${trueorfalse}
+
+GetLogList
+ [Arguments] ${logType} ${logCondition}
+ log ${logCondition}
+ ${LogListResponse} PostRemoteData /${version}/log/list ${logCondition}
+ Should Be Equal As Strings ${LogListResponse.status_code} 200
+ ${returnData} To Json ${LogListResponse.content}
+ ${responseCode} Get From Dictionary ${returnData} code
+ Log ${responseCode}
+ Should Be Equal ${responseCode} ${200} security_event_log \ \ test query list failed
+ log this time request security_event_log \ table logRecord \ : ${LogListResponse.content}
+ ${a} Set Variable this time request security_event_log \ table logRecord \ : ${LogListResponse.content}
+ log ${a}
+ ${log} Set Variable ${LogListResponse.json()}[data][list]
+ FOR ${logs} IN ${log}
+ log ${logs}
+ END
+ [Return] ${logs}
+
+GetLogList1
+ [Arguments] ${logType} ${startTime} ${endTime} ${client_ip} ${policy_id} ${parmkey} ${parmvalue}
+ ${logCondition} GetLogCondition ${logType} ${startTime} ${endTime} ${client_ip} ${policy_id}
+ log ${logCondition}
+ ${LogListResponse} PostRemoteData /${version}/log/list ${logCondition}
+ Should Be Equal As Strings ${LogListResponse.status_code} 200
+ ${returnData} To Json ${LogListResponse.content}
+ ${responseCode} Get From Dictionary ${returnData} code
+ Log ${responseCode}
+ Should Be Equal ${responseCode} ${200} security_event_log \ \ test query list failed
+ log this time request security_event_log \ table logRecord \ : ${LogListResponse.content}
+ ${a} Set Variable this time request security_event_log \ table logRecord \ : ${LogListResponse.content}
+ log ${a}
+ ${log} Set Variable ${LogListResponse.json()}[data][list]
+ FOR ${logs} IN ${log}
+ log ${logs}
+ END
+ log %%%%%%%%%%%%%%%%%%%%%%%%${logs}
+ Should Contain ${logs}"" ${client_ip}
+ Should Contain ${logs}"" ${policy_id}
+ Should Contain ${logs}"" ${parmkey}
+ Should Contain ${logs}"${parmkey}" ${parmvalue}
+
+GetLogListSize
+ [Documentation]
+ ... 描述:ProxyPinning
+ ...
+ [Arguments] ${logType} ${startTime} ${endTime} ${client_ip} ${policy_id} ${parmkey} ${parmvalue}
+ ${logCondition} GetALLLogCondition ${logType} ${startTime} ${endTime} ${client_ip} ${policy_id} 10000 1
+ log ${logCondition}
+ ${LogListResponse} PostRemoteData /${version}/log/list ${logCondition}
+ Should Be Equal As Strings ${LogListResponse.status_code} 200
+ ${returnData} To Json ${LogListResponse.content}
+ ${data} Get From Dictionary ${returnData} data
+ ${len} Get Length ${data}[list]
+ [Return] ${len}
+
+
+GetLogCount
+ [Arguments] ${logType} ${startTime} ${endTime} ${client_ip} ${policy_id} ${parmkey} ${parmvalue}
+ ${logCondition} GetALLLogCondition ${logType} ${startTime} ${endTime} ${client_ip} ${policy_id} 10000 1
+ ${LogListResponse} PostRemoteData /${version}/log/count ${logCondition}
+ Should Be Equal As Strings ${LogListResponse.status_code} 200
+ ${returnData} To Json ${LogListResponse.content}
+ ${len} Set Variable ${LogListResponse.json()}[data][total]
+ #${len} Get From Dictionary ${returnData} total
+ [Return] ${len}
+
\ No newline at end of file |
