diff --git a/01-TestCase/tsg_bfapi/active_defence_event_log/Log_batch.robot b/01-TestCase/tsg_bfapi/active_defence_event_log/Log_batch.robot index 1a24842..6787b99 100644 --- a/01-TestCase/tsg_bfapi/active_defence_event_log/Log_batch.robot +++ b/01-TestCase/tsg_bfapi/active_defence_event_log/Log_batch.robot @@ -2,333 +2,333 @@ Force Tags api api-log api-log-active_defence_event_log api-log-active_defence_event_log-batch Library downloadexcel.py Resource ../../../02-Keyword/tsg_bfapi/Log_keyword.robot -Library DateTime +Resource ../../../02-Keyword/tsg_bfapi/CommonUtil.robot *** Variables *** @{logType} security_event_log proxy_event_log connection_record_log radius_record_log -${path} ${path} +${apipath} http://${host}:${port}/${version} *** Test Cases *** ExportLog-001 ${conditions} Set Variable {"field":"common_log_id","type":"long","symbol":"=","value":["59526984506148866"] } ${logname} Set Variable active_defence_event_log - ${starttime} Get Time - ${endtime}= Add Time To Date ${starttime} -1 days + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${logCondition} GetLogCondition ${logname} ${starttime} ${endtime} 30 1 ... ${conditions} log ${logCondition} ${header} Create Dictionary Content-Type=application/json Authorization=${token} - ${success} downloadexcel ${header} ${logCondition} ${path}/log/batch + ${success} downloadexcel ${header} ${logCondition} ${apipath}/log/batch log ${success} Should Be Equal ${success} ${200} active_defence_event_log\ test query export failed ExportLog-002 ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "symbol":"=", "value":["2020-04-27 12:48:33"] } ${logname} Set Variable active_defence_event_log - ${starttime} Get Time - ${endtime}= Add Time To Date ${starttime} -1 days + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${logCondition} GetLogCondition ${logname} ${starttime} ${endtime} 30 1 ... ${conditions} log ${logCondition} ${header} Create Dictionary Content-Type=application/json Authorization=${token} - ${success} downloadexcel ${header} ${logCondition} ${path}/log/batch + ${success} downloadexcel ${header} ${logCondition} ${apipath}/log/batch log ${success} Should Be Equal ${success} ${200} active_defence_event_log\ test query export failed ExportLog-003 ${conditions} Set Variable { "field":"common_policy_id", "type":"int", "symbol":"=", "value":["774"] } ${logname} Set Variable active_defence_event_log - ${starttime} Get Time - ${endtime}= Add Time To Date ${starttime} -1 days + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${logCondition} GetLogCondition ${logname} ${starttime} ${endtime} 30 1 ... ${conditions} log ${logCondition} ${header} Create Dictionary Content-Type=application/json Authorization=${token} - ${success} downloadexcel ${header} ${logCondition} ${path}/log/batch + ${success} downloadexcel ${header} ${logCondition} ${apipath}/log/batch log ${success} Should Be Equal ${success} ${200} active_defence_event_log\ test query export failed ExportLog-004 ${conditions} Set Variable { "field":"common_policy_id", "type":"int", "symbol":"=", "value":["774"] } ${logname} Set Variable active_defence_event_log - ${starttime} Get Time - ${endtime}= Add Time To Date ${starttime} -1 days + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${logCondition} GetLogCondition ${logname} ${starttime} ${endtime} 30 1 ... ${conditions} log ${logCondition} ${header} Create Dictionary Content-Type=application/json Authorization=${token} - ${success} downloadexcel ${header} ${logCondition} ${path}/log/batch + ${success} downloadexcel ${header} ${logCondition} ${apipath}/log/batch log ${success} Should Be Equal ${success} ${200} active_defence_event_log\ test query export failed ExportLog-005 ${conditions} Set Variable { "field":"ad_cc_target_url", "type":"string", "symbol":"sub", "value":["www.jianshu.com"] } ${logname} Set Variable active_defence_event_log - ${starttime} Get Time - ${endtime}= Add Time To Date ${starttime} -1 days + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${logCondition} GetLogCondition ${logname} ${starttime} ${endtime} 30 1 ... ${conditions} log ${logCondition} ${header} Create Dictionary Content-Type=application/json Authorization=${token} - ${success} downloadexcel ${header} ${logCondition} ${path}/log/batch + ${success} downloadexcel ${header} ${logCondition} ${apipath}/log/batch log ${success} Should Be Equal ${success} ${200} active_defence_event_log\ test query export failed ExportLog-006 ${conditions} Set Variable { "field":"ad_target_ip", "type":"string", "symbol":"sub", "value":["22"] } ${logname} Set Variable active_defence_event_log - ${starttime} Get Time - ${endtime}= Add Time To Date ${starttime} -1 days + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${logCondition} GetLogCondition ${logname} ${starttime} ${endtime} 30 1 ... ${conditions} log ${logCondition} ${header} Create Dictionary Content-Type=application/json Authorization=${token} - ${success} downloadexcel ${header} ${logCondition} ${path}/log/batch + ${success} downloadexcel ${header} ${logCondition} ${apipath}/log/batch log ${success} Should Be Equal ${success} ${200} active_defence_event_log\ test query export failed ExportLog-007 ${conditions} Set Variable { "field":"ad_target_ip", "type":"string", "symbol":"exactly", "value":["10.3.22.222"] },{"field":"common_log_id","type":"long","symbol":"=","value":["59526984506148866"] },{ "field":"common_recv_time", "type":"timestamp", "symbol":"=", "value":["2020-04-27 13:27:02"] },{ "field":"common_policy_id", "type":"int", "symbol":"=", "value":["95"] } ${logname} Set Variable active_defence_event_log - ${starttime} Get Time - ${endtime}= Add Time To Date ${starttime} -1 days + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${logCondition} GetLogCondition ${logname} ${starttime} ${endtime} 30 1 ... [${conditions}] log ${logCondition} ${header} Create Dictionary Content-Type=application/json Authorization=${token} - ${success} downloadexcel ${header} ${logCondition} ${path}/log/batch + ${success} downloadexcel ${header} ${logCondition} ${apipath}/log/batch log ${success} Should Be Equal ${success} ${200} active_defence_event_log\ test query export failed ExportLog-008 ${conditions} Set Variable { "field":"ad_target_ip", "type":"string", "symbol":"prefix", "value":["10"] } ${logname} Set Variable active_defence_event_log - ${starttime} Get Time - ${endtime}= Add Time To Date ${starttime} -1 days + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${logCondition} GetLogCondition ${logname} ${starttime} ${endtime} 30 1 ... ${conditions} log ${logCondition} ${header} Create Dictionary Content-Type=application/json Authorization=${token} - ${success} downloadexcel ${header} ${logCondition} ${path}/log/batch + ${success} downloadexcel ${header} ${logCondition} ${apipath}/log/batch log ${success} Should Be Equal ${success} ${200} active_defence_event_log\ test query export failed ExportLog-009 ${conditions} Set Variable { "field":"ad_target_ip", "type":"string", "symbol":"suffix", "value":["222"] } ${logname} Set Variable active_defence_event_log - ${starttime} Get Time - ${endtime}= Add Time To Date ${starttime} -1 days + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${logCondition} GetLogCondition ${logname} ${starttime} ${endtime} 30 1 ... ${conditions} log ${logCondition} ${header} Create Dictionary Content-Type=application/json Authorization=${token} - ${success} downloadexcel ${header} ${logCondition} ${path}/log/batch + ${success} downloadexcel ${header} ${logCondition} ${apipath}/log/batch log ${success} Should Be Equal ${success} ${200} active_defence_event_log\ test query export failed ExportLog-010 ${conditions} Set Variable { "field":"ad_target_ip", "type":"string", "symbol":"exactly", "value":["10.3.22.222"] } ${logname} Set Variable active_defence_event_log - ${starttime} Get Time - ${endtime}= Add Time To Date ${starttime} -1 days + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${logCondition} GetLogCondition ${logname} ${starttime} ${endtime} 30 1 ... ${conditions} log ${logCondition} ${header} Create Dictionary Content-Type=application/json Authorization=${token} - ${success} downloadexcel ${header} ${logCondition} ${path}/log/batch + ${success} downloadexcel ${header} ${logCondition} ${apipath}/log/batch log ${success} Should Be Equal ${success} ${200} active_defence_event_log\ test query export failed ExportLog-011 ${conditions} Set Variable { "field":"ad_target_ip", "type":"string", "value":["10"] } ${logname} Set Variable active_defence_event_log - ${starttime} Get Time - ${endtime}= Add Time To Date ${starttime} -1 days + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${logCondition} GetLogCondition ${logname} ${starttime} ${endtime} 30 1 ... ${conditions} log ${logCondition} ${header} Create Dictionary Content-Type=application/json Authorization=${token} - ${success} downloadexcel ${header} ${logCondition} ${path}/log/batch + ${success} downloadexcel ${header} ${logCondition} ${apipath}/log/batch log ${success} Should Be Equal ${success} ${200} active_defence_event_log\ test query export failed ExportLog-012 ${conditions} Set Variable { "field":"common_policy_id", "type":"int", "value":["774"] } ${logname} Set Variable active_defence_event_log - ${starttime} Get Time - ${endtime}= Add Time To Date ${starttime} -1 days + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${logCondition} GetLogCondition ${logname} ${starttime} ${endtime} 30 1 ... ${conditions} log ${logCondition} ${header} Create Dictionary Content-Type=application/json Authorization=${token} - ${success} downloadexcel ${header} ${logCondition} ${path}/log/batch + ${success} downloadexcel ${header} ${logCondition} ${apipath}/log/batch log ${success} Should Be Equal ${success} ${200} active_defence_event_log\ test query export failed ExportLog-013 ${conditions} Set Variable { "field":"common_policy_id", "type":"int", "symbol":"!=", "value":["774"] } ${logname} Set Variable active_defence_event_log - ${starttime} Get Time - ${endtime}= Add Time To Date ${starttime} -1 days + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${logCondition} GetLogCondition ${logname} ${starttime} ${endtime} 30 1 ... ${conditions} log ${logCondition} ${header} Create Dictionary Content-Type=application/json Authorization=${token} - ${success} downloadexcel ${header} ${logCondition} ${path}/log/batch + ${success} downloadexcel ${header} ${logCondition} ${apipath}/log/batch log ${success} Should Be Equal ${success} ${200} active_defence_event_log\ test query export failed ExportLog-014 ${conditions} Set Variable { "field":"common_policy_id", "type":"int", "symbol":">", "value":["774"] } ${logname} Set Variable active_defence_event_log - ${starttime} Get Time - ${endtime}= Add Time To Date ${starttime} -1 days + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${logCondition} GetLogCondition ${logname} ${starttime} ${endtime} 30 1 ... ${conditions} log ${logCondition} ${header} Create Dictionary Content-Type=application/json Authorization=${token} - ${success} downloadexcel ${header} ${logCondition} ${path}/log/batch + ${success} downloadexcel ${header} ${logCondition} ${apipath}/log/batch log ${success} Should Be Equal ${success} ${200} active_defence_event_log\ test query export failed ExportLog-015 ${conditions} Set Variable { "field":"common_policy_id", "type":"int", "symbol":"<", "value":["774"] } ${logname} Set Variable active_defence_event_log - ${starttime} Get Time - ${endtime}= Add Time To Date ${starttime} -1 days + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${logCondition} GetLogCondition ${logname} ${starttime} ${endtime} 30 1 ... ${conditions} log ${logCondition} ${header} Create Dictionary Content-Type=application/json Authorization=${token} - ${success} downloadexcel ${header} ${logCondition} ${path}/log/batch + ${success} downloadexcel ${header} ${logCondition} ${apipath}/log/batch log ${success} Should Be Equal ${success} ${200} active_defence_event_log\ test query export failed ExportLog-016 ${conditions} Set Variable { "field":"common_policy_id", "type":"int", "symbol":"<=", "value":["774"] } ${logname} Set Variable active_defence_event_log - ${starttime} Get Time - ${endtime}= Add Time To Date ${starttime} -1 days + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${logCondition} GetLogCondition ${logname} ${starttime} ${endtime} 30 1 ... ${conditions} log ${logCondition} ${header} Create Dictionary Content-Type=application/json Authorization=${token} - ${success} downloadexcel ${header} ${logCondition} ${path}/log/batch + ${success} downloadexcel ${header} ${logCondition} ${apipath}/log/batch log ${success} Should Be Equal ${success} ${200} active_defence_event_log\ test query export failed ExportLog-017 ${conditions} Set Variable { "field":"common_policy_id", "type":"int", "symbol":">=", "value":["774"] } ${logname} Set Variable active_defence_event_log - ${starttime} Get Time - ${endtime}= Add Time To Date ${starttime} -1 days + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${logCondition} GetLogCondition ${logname} ${starttime} ${endtime} 30 1 ... ${conditions} log ${logCondition} ${header} Create Dictionary Content-Type=application/json Authorization=${token} - ${success} downloadexcel ${header} ${logCondition} ${path}/log/batch + ${success} downloadexcel ${header} ${logCondition} ${apipath}/log/batch log ${success} Should Be Equal ${success} ${200} active_defence_event_log\ test query export failed ExportLog-018 ${conditions} Set Variable { "field":"common_policy_id", "type":"int", "symbol":"in", "value":["774","95"] } ${logname} Set Variable active_defence_event_log - ${starttime} Get Time - ${endtime}= Add Time To Date ${starttime} -1 days + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${logCondition} GetLogCondition ${logname} ${starttime} ${endtime} 30 1 ... ${conditions} log ${logCondition} ${header} Create Dictionary Content-Type=application/json Authorization=${token} - ${success} downloadexcel ${header} ${logCondition} ${path}/log/batch + ${success} downloadexcel ${header} ${logCondition} ${apipath}/log/batch log ${success} Should Be Equal ${success} ${200} active_defence_event_log\ test query export failed ExportLog-019 - ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "value":["2020-04-27 12:48:33"] } - ${logname} Set Variable active_defence_event_log - ${starttime} Get Time - ${endtime}= Add Time To Date ${starttime} -1 days + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "value":["${starttime}"] } + ${logname} Set Variable active_defence_event_log + ${logCondition} GetLogCondition ${logname} ${starttime} ${endtime} 30 1 ... ${conditions} log ${logCondition} ${header} Create Dictionary Content-Type=application/json Authorization=${token} - ${success} downloadexcel ${header} ${logCondition} ${path}/log/batch + ${success} downloadexcel ${header} ${logCondition} ${apipath}/log/batch log ${success} Should Be Equal ${success} ${200} active_defence_event_log\ test query export failed ExportLog-020 - ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "symbol":">", "value":["2020-04-27 12:48:33"] } - ${logname} Set Variable active_defence_event_log - ${starttime} Get Time - ${endtime}= Add Time To Date ${starttime} -1 days + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "symbol":">", "value":["${starttime}"] } + ${logname} Set Variable active_defence_event_log + ${logCondition} GetLogCondition ${logname} ${starttime} ${endtime} 30 1 ... ${conditions} log ${logCondition} ${header} Create Dictionary Content-Type=application/json Authorization=${token} - ${success} downloadexcel ${header} ${logCondition} ${path}/log/batch + ${success} downloadexcel ${header} ${logCondition} ${apipath}/log/batch log ${success} Should Be Equal ${success} ${200} active_defence_event_log\ test query export failed ExportLog-021 - ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "symbol":"<", "value":["2020-04-27 12:48:33"] } - ${logname} Set Variable active_defence_event_log - ${starttime} Get Time - ${endtime}= Add Time To Date ${starttime} -1 days + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "symbol":"<", "value":["${endtime}"] } + ${logname} Set Variable active_defence_event_log + ${logCondition} GetLogCondition ${logname} ${starttime} ${endtime} 30 1 ... ${conditions} log ${logCondition} ${header} Create Dictionary Content-Type=application/json Authorization=${token} - ${success} downloadexcel ${header} ${logCondition} ${path}/log/batch + ${success} downloadexcel ${header} ${logCondition} ${apipath}/log/batch log ${success} Should Be Equal ${success} ${200} active_defence_event_log\ test query export failed ExportLog-022 - ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "symbol":"<=", "value":["2020-04-27 12:48:33"] } - ${logname} Set Variable active_defence_event_log - ${starttime} Get Time - ${endtime}= Add Time To Date ${starttime} -1 days + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "symbol":"<=", "value":["${endtime}"] } + ${logname} Set Variable active_defence_event_log + ${logCondition} GetLogCondition ${logname} ${starttime} ${endtime} 30 1 ... ${conditions} log ${logCondition} ${header} Create Dictionary Content-Type=application/json Authorization=${token} - ${success} downloadexcel ${header} ${logCondition} ${path}/log/batch + ${success} downloadexcel ${header} ${logCondition} ${apipath}/log/batch log ${success} Should Be Equal ${success} ${200} active_defence_event_log\ test query export failed ExportLog-023 - ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "symbol":">=", "value":["2020-04-27 12:48:33"] } - ${logname} Set Variable active_defence_event_log - ${starttime} Get Time - ${endtime}= Add Time To Date ${starttime} -1 days + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "symbol":">=", "value":["${starttime}"] } + ${logname} Set Variable active_defence_event_log + ${logCondition} GetLogCondition ${logname} ${starttime} ${endtime} 30 1 ... ${conditions} log ${logCondition} ${header} Create Dictionary Content-Type=application/json Authorization=${token} - ${success} downloadexcel ${header} ${logCondition} ${path}/log/batch + ${success} downloadexcel ${header} ${logCondition} ${apipath}/log/batch log ${success} Should Be Equal ${success} ${200} active_defence_event_log\ test query export failed ExportLog-024 - ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "symbol":"between", "value":["2020-04-27 12:48:33","${endtime}"] } - ${logname} Set Variable active_defence_event_log - ${starttime} Get Time - ${endtime}= Add Time To Date ${starttime} -1 days + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "symbol":"between", "value":["${starttime}","${endtime}"] } + ${logname} Set Variable active_defence_event_log + ${logCondition} GetLogCondition ${logname} ${starttime} ${endtime} 30 1 ... ${conditions} log ${logCondition} ${header} Create Dictionary Content-Type=application/json Authorization=${token} - ${success} downloadexcel ${header} ${logCondition} ${path}/log/batch + ${success} downloadexcel ${header} ${logCondition} ${apipath}/log/batch log ${success} Should Be Equal ${success} ${200} active_defence_event_log\ test query export failed ExportLog-025 - ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "value":["2020-04-27 12:48:33","${endtime}"] } - ${logname} Set Variable active_defence_event_log - ${starttime} Get Time - ${endtime}= Add Time To Date ${starttime} -1 days + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "value":["${starttime}","${endtime}"] } + ${logname} Set Variable active_defence_event_log + ${logCondition} GetLogCondition ${logname} ${starttime} ${endtime} 30 1 ... ${conditions} log ${logCondition} ${header} Create Dictionary Content-Type=application/json Authorization=${token} - ${success} downloadexcel ${header} ${logCondition} ${path}/log/batch + ${success} downloadexcel ${header} ${logCondition} ${apipath}/log/batch log ${success} Should Be Equal ${success} ${200} active_defence_event_log\ test query export failed diff --git a/01-TestCase/tsg_bfapi/active_defence_event_log/Log_search.robot b/01-TestCase/tsg_bfapi/active_defence_event_log/Log_search.robot index 992ecff..f57b819 100644 --- a/01-TestCase/tsg_bfapi/active_defence_event_log/Log_search.robot +++ b/01-TestCase/tsg_bfapi/active_defence_event_log/Log_search.robot @@ -9,6 +9,7 @@ Resource ../../../02-Keyword/tsg_bfapi/Log_search.robot Library string Library REST http://${host}:${port} Resource ../../../02-Keyword/tsg_bfapi/Log_keyword.robot +Resource ../../../02-Keyword/tsg_bfapi/CommonUtil.robot *** Test Cases *** log-schema-001 @@ -19,7 +20,9 @@ log-search-002 #${filds} schema ${responsedata} Get-Request /${version}/log/schema?logType=active_defence_event_log ${filds} Set Variable ${responsedata['data']['fields']} - ${response} log_search 2020-04-26 12:27:03 2020-04-27 13:27:03 active_defence_event_log ${filds} [] + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + #date_format=%Y-%m-%d %H:%M:%S + ${response} log_search ${starttime} ${endtime} active_defence_event_log ${filds} [] log ${response} Should Be Equal As Strings ${response.code} 200 @@ -27,8 +30,9 @@ log-search-003 #${filds} schema ${responsedata} Get-Request /${version}/log/schema?logType=active_defence_event_log ${filds} Set Variable ${responsedata['data']['fields']} + ${starttime} ${endtime} GetLast24HoursStartAndEndTime ${conditions} Set Variable {"field":"common_log_id","type":"long","symbol":"=","value":["59526984506148866"] } - ${response} log_search 2020-04-26 12:27:03 2020-04-27 13:27:03 active_defence_event_log ${filds} [${conditions}] + ${response} log_search ${starttime} ${endtime} active_defence_event_log ${filds} [${conditions}] log ${response} Should Be Equal As Strings ${response.code} 200 ${responsedata} Get From Dictionary ${response} data @@ -41,8 +45,9 @@ log-search-004 #${filds} schema ${responsedata} Get-Request /${version}/log/schema?logType=active_defence_event_log ${filds} Set Variable ${responsedata['data']['fields']} - ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "symbol":"=", "value":["2020-04-27 12:48:33"] } - ${response} log_search 2020-04-26 12:27:03 2020-04-27 13:27:03 active_defence_event_log ${filds} [${conditions}] + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "symbol":"=", "value":["${starttime}"] } + ${response} log_search ${starttime} ${endtime} active_defence_event_log ${filds} [${conditions}] log ${response} Should Be Equal As Strings ${response.code} 200 ${responsedata} Get From Dictionary ${response} data @@ -55,8 +60,9 @@ log-search-005 #${filds} schema ${responsedata} Get-Request /${version}/log/schema?logType=active_defence_event_log ${filds} Set Variable ${responsedata['data']['fields']} + ${starttime} ${endtime} GetLast24HoursStartAndEndTime ${conditions} Set Variable { "field":"common_policy_id", "type":"int", "symbol":"=", "value":["774"] } - ${response} log_search 2020-04-26 12:27:03 2020-04-27 13:27:03 active_defence_event_log ${filds} ${conditions} + ${response} log_search ${starttime} ${endtime} active_defence_event_log ${filds} ${conditions} log ${response} Should Be Equal As Strings ${response.code} 200 ${responsedata} Get From Dictionary ${response} data @@ -69,8 +75,9 @@ log-search-006 #${filds} schema ${responsedata} Get-Request /${version}/log/schema?logType=active_defence_event_log ${filds} Set Variable ${responsedata['data']['fields']} + ${starttime} ${endtime} GetLast24HoursStartAndEndTime ${conditions} Set Variable { "field":"ad_cc_target_url", "type":"string", "symbol":"sub", "value":["www.jianshu.com"] } - ${response} log_search 2020-04-26 12:27:03 2020-04-27 13:27:03 active_defence_event_log ${filds} ${conditions} + ${response} log_search ${starttime} ${endtime} active_defence_event_log ${filds} ${conditions} log ${response} Should Be Equal As Strings ${response.code} 200 ${responsedata} Get From Dictionary ${response} data @@ -83,8 +90,9 @@ log-search-007 #${filds} schema ${responsedata} Get-Request /${version}/log/schema?logType=active_defence_event_log ${filds} Set Variable ${responsedata['data']['fields']} + ${starttime} ${endtime} GetLast24HoursStartAndEndTime ${conditions} Set Variable { "field":"ad_target_ip", "type":"string", "symbol":"sub", "value":["22"] } - ${response} log_search 2020-04-26 12:27:03 2020-04-27 13:27:03 active_defence_event_log ${filds} ${conditions} + ${response} log_search ${starttime} ${endtime} active_defence_event_log ${filds} ${conditions} log ${response} Should Be Equal As Strings ${response.code} 200 ${responsedata} Get From Dictionary ${response} data @@ -97,8 +105,9 @@ log-search-008 #${filds} schema ${responsedata} Get-Request /${version}/log/schema?logType=active_defence_event_log ${filds} Set Variable ${responsedata['data']['fields']} + ${starttime} ${endtime} GetLast24HoursStartAndEndTime ${conditions} Set Variable { "field":"ad_target_ip", "type":"string", "symbol":"prefix", "value":["10"] } - ${response} log_search 2020-04-26 12:27:03 2020-04-27 13:27:03 active_defence_event_log ${filds} ${conditions} + ${response} log_search ${starttime} ${endtime} active_defence_event_log ${filds} ${conditions} log ${response} Should Be Equal As Strings ${response.code} 200 ${responsedata} Get From Dictionary ${response} data @@ -111,8 +120,9 @@ log-search-009 #${filds} schema ${responsedata} Get-Request /${version}/log/schema?logType=active_defence_event_log ${filds} Set Variable ${responsedata['data']['fields']} + ${starttime} ${endtime} GetLast24HoursStartAndEndTime ${conditions} Set Variable { "field":"ad_target_ip", "type":"string", "symbol":"suffix", "value":["222"] } - ${response} log_search 2020-04-26 12:27:03 2020-04-27 13:27:03 active_defence_event_log ${filds} ${conditions} + ${response} log_search ${starttime} ${endtime} active_defence_event_log ${filds} ${conditions} log ${response} Should Be Equal As Strings ${response.code} 200 ${responsedata} Get From Dictionary ${response} data @@ -125,8 +135,9 @@ log-search-010 #${filds} schema ${responsedata} Get-Request /${version}/log/schema?logType=active_defence_event_log ${filds} Set Variable ${responsedata['data']['fields']} + ${starttime} ${endtime} GetLast24HoursStartAndEndTime ${conditions} Set Variable { "field":"ad_target_ip", "type":"string", "symbol":"exactly", "value":["10.3.22.222"] } - ${response} log_search 2020-04-26 12:27:03 2020-04-27 13:27:03 active_defence_event_log ${filds} ${conditions} + ${response} log_search ${starttime} ${endtime} active_defence_event_log ${filds} ${conditions} log ${response} Should Be Equal As Strings ${response.code} 200 ${responsedata} Get From Dictionary ${response} data @@ -139,8 +150,9 @@ log-search-011 #${filds} schema ${responsedata} Get-Request /${version}/log/schema?logType=active_defence_event_log ${filds} Set Variable ${responsedata['data']['fields']} + ${starttime} ${endtime} GetLast24HoursStartAndEndTime ${conditions} Set Variable { "field":"ad_target_ip", "type":"string", "symbol":"exactly", "value":["10.3.22.222"] },{"field":"common_log_id","type":"long","symbol":"=","value":["59526984506148866"] },{ "field":"common_recv_time", "type":"timestamp", "symbol":"=", "value":["2020-04-27 13:27:02"] },{ "field":"common_policy_id", "type":"int", "symbol":"=", "value":["95"] } - ${response} log_search 2020-04-26 12:27:03 2020-04-27 13:27:03 active_defence_event_log ${filds} [${conditions}] + ${response} log_search ${starttime} ${endtime} active_defence_event_log ${filds} [${conditions}] log ${response} Should Be Equal As Strings ${response.code} 200 ${responsedata} Get From Dictionary ${response} data @@ -158,7 +170,8 @@ log-search-011 log-search-012 ${conditions} Set Variable {"field":"common_log_id","type":"long","symbol":"=","value":["59526984506148866"] } ${simpleCondition} Set Variable "common_server_ips": "40" - ${logCondition} GetLogCondition active_defence_event_log 2020-04-26 12:27:03 2020-04-27 13:27:03 30 1 + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${logCondition} GetLogCondition active_defence_event_log ${starttime} ${endtime} 30 1 ... ${conditions} ${response} BasePostRequest /${version}/log/list ${logCondition} Should Be Equal As Strings ${response.code} 200 @@ -173,7 +186,8 @@ log-search-013 ${responsedata} Get-Request /${version}/log/schema?logType=active_defence_event_log ${filds} Set Variable ${responsedata['data']['fields']} ${conditions} Set Variable { "field":"common_policy_id", "type":"int", "value":["774"] } - ${response} log_search 2020-04-26 12:27:03 2020-04-27 13:27:03 active_defence_event_log ${filds} ${conditions} + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${response} log_search ${starttime} ${endtime} active_defence_event_log ${filds} ${conditions} log ${response} Should Be Equal As Strings ${response.code} 200 ${responsedata} Get From Dictionary ${response} data @@ -187,7 +201,8 @@ log-search-014 ${responsedata} Get-Request /${version}/log/schema?logType=active_defence_event_log ${filds} Set Variable ${responsedata['data']['fields']} ${conditions} Set Variable { "field":"common_policy_id", "type":"int", "symbol":"!=", "value":["774"] } - ${response} log_search 2020-04-26 12:27:03 2020-04-27 13:27:03 active_defence_event_log ${filds} ${conditions} + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${response} log_search ${starttime} ${endtime} active_defence_event_log ${filds} ${conditions} log ${response} Should Be Equal As Strings ${response.code} 200 @@ -196,7 +211,8 @@ log-search-015 ${responsedata} Get-Request /${version}/log/schema?logType=active_defence_event_log ${filds} Set Variable ${responsedata['data']['fields']} ${conditions} Set Variable { "field":"common_policy_id", "type":"int", "symbol":">", "value":["774"] } - ${response} log_search 2020-04-26 12:27:03 2020-04-27 13:27:03 active_defence_event_log ${filds} ${conditions} + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${response} log_search ${starttime} ${endtime} active_defence_event_log ${filds} ${conditions} log ${response} Should Be Equal As Strings ${response.code} 200 @@ -205,7 +221,8 @@ log-search-016 ${responsedata} Get-Request /${version}/log/schema?logType=active_defence_event_log ${filds} Set Variable ${responsedata['data']['fields']} ${conditions} Set Variable { "field":"common_policy_id", "type":"int", "symbol":"<", "value":["774"] } - ${response} log_search 2020-04-26 12:27:03 2020-04-27 13:27:03 active_defence_event_log ${filds} ${conditions} + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${response} log_search ${starttime} ${endtime} active_defence_event_log ${filds} ${conditions} log ${response} Should Be Equal As Strings ${response.code} 200 @@ -214,7 +231,8 @@ log-search-017 ${responsedata} Get-Request /${version}/log/schema?logType=active_defence_event_log ${filds} Set Variable ${responsedata['data']['fields']} ${conditions} Set Variable { "field":"common_policy_id", "type":"int", "symbol":"<=", "value":["774"] } - ${response} log_search 2020-04-26 12:27:03 2020-04-27 13:27:03 active_defence_event_log ${filds} ${conditions} + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${response} log_search ${starttime} ${endtime} active_defence_event_log ${filds} ${conditions} log ${response} Should Be Equal As Strings ${response.code} 200 @@ -223,7 +241,8 @@ log-search-018 ${responsedata} Get-Request /${version}/log/schema?logType=active_defence_event_log ${filds} Set Variable ${responsedata['data']['fields']} ${conditions} Set Variable { "field":"common_policy_id", "type":"int", "symbol":">=", "value":["774"] } - ${response} log_search 2020-04-26 12:27:03 2020-04-27 13:27:03 active_defence_event_log ${filds} ${conditions} + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${response} log_search ${starttime} ${endtime} active_defence_event_log ${filds} ${conditions} log ${response} Should Be Equal As Strings ${response.code} 200 @@ -232,7 +251,8 @@ log-search-019 ${responsedata} Get-Request /${version}/log/schema?logType=active_defence_event_log ${filds} Set Variable ${responsedata['data']['fields']} ${conditions} Set Variable { "field":"common_policy_id", "type":"int", "symbol":"in", "value":["774","95"] } - ${response} log_search 2020-04-26 12:27:03 2020-04-27 13:27:03 active_defence_event_log ${filds} ${conditions} + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${response} log_search ${starttime} ${endtime} active_defence_event_log ${filds} ${conditions} log ${response} Should Be Equal As Strings ${response.code} 200 @@ -240,22 +260,24 @@ log-search-020 #${filds} schema ${responsedata} Get-Request /${version}/log/schema?logType=active_defence_event_log ${filds} Set Variable ${responsedata['data']['fields']} - ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "value":["2020-04-27 12:48:33"] } - ${response} log_search 2020-04-26 12:27:03 2020-04-27 13:27:03 active_defence_event_log ${filds} [${conditions}] + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "value":["${starttime}"] } + ${response} log_search ${starttime} ${endtime} active_defence_event_log ${filds} [${conditions}] log ${response} Should Be Equal As Strings ${response.code} 200 ${responsedata} Get From Dictionary ${response} data log ${responsedata} ${responselist} Get From Dictionary ${responsedata} list ${time} Set Variable ${responselist}[0][common_recv_time] - Should Be Equal As Strings ${time} 2020-04-27 12:48:33 + Should Be Equal As Strings ${time} ${starttime} log-search-021 #${filds} schema ${responsedata} Get-Request /${version}/log/schema?logType=active_defence_event_log ${filds} Set Variable ${responsedata['data']['fields']} - ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "symbol":">", "value":["2020-04-27 12:48:33"] } - ${response} log_search 2020-04-26 12:27:03 2020-04-27 13:27:03 active_defence_event_log ${filds} [${conditions}] + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "symbol":">", "value":["${starttime}"] } + ${response} log_search ${starttime} ${endtime} active_defence_event_log ${filds} [${conditions}] log ${response} Should Be Equal As Strings ${response.code} 200 @@ -264,7 +286,8 @@ log-search-022 ${responsedata} Get-Request /${version}/log/schema?logType=active_defence_event_log ${filds} Set Variable ${responsedata['data']['fields']} ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "symbol":"<", "value":["2020-04-27 12:48:33"] } - ${response} log_search 2020-04-26 12:27:03 2020-04-27 13:27:03 active_defence_event_log ${filds} [${conditions}] + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${response} log_search ${starttime} ${endtime} active_defence_event_log ${filds} [${conditions}] log ${response} Should Be Equal As Strings ${response.code} 200 @@ -272,8 +295,9 @@ log-search-023 #${filds} schema ${responsedata} Get-Request /${version}/log/schema?logType=active_defence_event_log ${filds} Set Variable ${responsedata['data']['fields']} - ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "symbol":"<=", "value":["2020-04-27 12:48:33"] } - ${response} log_search 2020-04-26 12:27:03 2020-04-27 13:27:03 active_defence_event_log ${filds} [${conditions}] + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "symbol":"<=", "value":["${starttime}"] } + ${response} log_search ${starttime} ${endtime} active_defence_event_log ${filds} [${conditions}] log ${response} Should Be Equal As Strings ${response.code} 200 ${responsedata} Get From Dictionary ${response} data @@ -286,8 +310,9 @@ log-search-024 #${filds} schema ${responsedata} Get-Request /${version}/log/schema?logType=active_defence_event_log ${filds} Set Variable ${responsedata['data']['fields']} - ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "symbol":">=", "value":["2020-04-27 12:48:33"] } - ${response} log_search 2020-04-26 12:27:03 2020-04-27 13:27:03 active_defence_event_log ${filds} [${conditions}] + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "symbol":">=", "value":["${starttime}"] } + ${response} log_search ${starttime} ${endtime} active_defence_event_log ${filds} [${conditions}] log ${response} Should Be Equal As Strings ${response.code} 200 @@ -295,8 +320,9 @@ log-search-025 #${filds} schema ${responsedata} Get-Request /${version}/log/schema?logType=active_defence_event_log ${filds} Set Variable ${responsedata['data']['fields']} - ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "symbol":"between", "value":["2020-04-27 12:48:33","2020-04-27 13:27:03"] } - ${response} log_search 2020-04-26 12:27:03 2020-04-27 13:27:03 active_defence_event_log ${filds} [${conditions}] + ${starttime} ${endtime} GetLast24HoursStartAndEndTime + ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "symbol":"between", "value":["${starttime}","${endtime}"] } + ${response} log_search ${starttime} ${endtime} active_defence_event_log ${filds} [${conditions}] log ${response} Should Be Equal As Strings ${response.code} 200 @@ -304,7 +330,7 @@ log-search-026 #${filds} schema ${responsedata} Get-Request /${version}/log/schema?logType=active_defence_event_log ${filds} Set Variable ${responsedata['data']['fields']} - ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "value":["2020-04-27 12:48:33","2020-04-27 13:27:03"] } - ${response} log_search 2020-04-26 12:27:03 2020-04-27 13:27:03 active_defence_event_log ${filds} [${conditions}] + ${conditions} Set Variable { "field":"common_recv_time", "type":"timestamp", "value":["2020-04-27 12:48:33","${endtime}"] } + ${response} log_search ${starttime} ${endtime} active_defence_event_log ${filds} [${conditions}] log ${response} Should Be Equal As Strings ${response.code} 200 diff --git a/01-TestCase/tsg_bfapi/api_log/LogStatistics-Country.robot b/01-TestCase/tsg_bfapi/api_log/LogStatistics-Country.robot index 7ac7e8a..74c3757 100644 --- a/01-TestCase/tsg_bfapi/api_log/LogStatistics-Country.robot +++ b/01-TestCase/tsg_bfapi/api_log/LogStatistics-Country.robot @@ -1,13 +1,14 @@ *** Settings *** Resource ../../../02-Keyword/tsg_bfapi/LogStatistics.robot +Resource ../../../03-Variable/BifangApiVariable.txt Library DateTime *** Test Cases *** Statistics-Country-00001 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable country - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/country/sourceipnum + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/country/sourceipnum #开始时间格式Y-M-D h:i:s ${startTime} set variable 2020-05-10 15:56:05 #结束时间格式Y-M-D h:i:s @@ -20,8 +21,8 @@ Statistics-Country-00002 #最近一小时 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable country - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/country/sourceipnum + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/country/sourceipnum #开始时间 #结束时间格式Y-M-D h:i:s ${Time} get current date @@ -36,8 +37,8 @@ Statistics-Country-00003 #最近一天 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable country - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/country/sourceipnum + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/country/sourceipnum #开始时间 #结束时间格式Y-M-D h:i:s ${Time} get current date @@ -54,8 +55,8 @@ Statistics-Country-00004 #最近一周 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable country - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/country/sourceipnum + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/country/sourceipnum #开始时间 #结束时间格式Y-M-D h:i:s ${Time} get current date @@ -72,8 +73,8 @@ Statistics-Country-00005 #最近一个月(30天) #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable country - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/country/sourceipnum + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/country/sourceipnum #开始时间 #结束时间格式Y-M-D h:i:s ${Time} get current date @@ -90,8 +91,8 @@ Statistics-Country-00006 #最近一年(365天) #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable country - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/country/sourceipnum + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/country/sourceipnum #开始时间 #结束时间格式Y-M-D h:i:s ${Time} get current date diff --git a/01-TestCase/tsg_bfapi/api_log/LogStatistics-domain.robot b/01-TestCase/tsg_bfapi/api_log/LogStatistics-domain.robot index 4cbaf9f..f87027b 100644 --- a/01-TestCase/tsg_bfapi/api_log/LogStatistics-domain.robot +++ b/01-TestCase/tsg_bfapi/api_log/LogStatistics-domain.robot @@ -1,12 +1,13 @@ *** Settings *** Resource ../../../02-Keyword/tsg_bfapi/LogStatistics.robot +Resource ../../../03-Variable/BifangApiVariable.txt *** Test Cases *** Statistics-domain-00001 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable domain #请求地址 例如:/report/domain/recommend - ${url} set variable /report/domain/recommend + ${url} set variable /${version}/report/domain/recommend # \ 统计时间, \ 查询最近24小时数据;例如当前时间为2020-03-26 15:14:00, 查询时间应设为推前1小时的整点,实际传入参数为 "2020-03-26 14:00:00" ${statisticTime} set variable 2020-05-10 15:56:05 GetApi ${apiName} ${url} statisticTime=${statisticTime} diff --git a/01-TestCase/tsg_bfapi/api_log/LogStatistics-domain_resource.robot b/01-TestCase/tsg_bfapi/api_log/LogStatistics-domain_resource.robot index 2bd1d15..a5ced30 100644 --- a/01-TestCase/tsg_bfapi/api_log/LogStatistics-domain_resource.robot +++ b/01-TestCase/tsg_bfapi/api_log/LogStatistics-domain_resource.robot @@ -1,13 +1,14 @@ *** Settings *** Library DateTime Resource ../../../02-Keyword/tsg_bfapi/LogStatistics.robot +Resource ../../../03-Variable/BifangApiVariable.txt *** Test Cases *** LogStatistics-domain_resource-00001 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable domain_resource #请求地址 例如:/report/domain/recommend - ${url} set variable /report/domain/resource/analyze + ${url} set variable /${version}/report/domain/resource/analyze #结束时间格式Y-M-D h:i:s ${Time} get current date ${endTime}= add time to date ${Time} -00:05:00 diff --git a/01-TestCase/tsg_bfapi/api_log/LogStatistics-hijack_srcip_location.robot b/01-TestCase/tsg_bfapi/api_log/LogStatistics-hijack_srcip_location.robot index 80faccb..836be25 100644 --- a/01-TestCase/tsg_bfapi/api_log/LogStatistics-hijack_srcip_location.robot +++ b/01-TestCase/tsg_bfapi/api_log/LogStatistics-hijack_srcip_location.robot @@ -1,13 +1,14 @@ *** Settings *** Resource ../../../02-Keyword/tsg_bfapi/LogStatistics.robot +Resource ../../../03-Variable/BifangApiVariable.txt Library DateTime *** Test Cases *** Statistics-hijack_srcip_location-00001 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable hijack_srcip_location - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/hijack_srcip_location + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/hijack_srcip_location #开始时间格式Y-M-D h:i:s ${startTime} set variable 2020-04-26 16:40:01 #结束时间格式Y-M-D h:i:s @@ -20,8 +21,8 @@ Statistics-hijack_srcip_location-00002 #最近一小时 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable hijack_srcip_location - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/hijack_srcip_location + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/hijack_srcip_location #结束时间格式Y-M-D h:i:s ${Time} get current date ${endTime}= add time to date ${Time} -00:05:00 @@ -37,8 +38,8 @@ Statistics-hijack_srcip_location-00003 #最近一天 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable hijack_srcip_location - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/hijack_srcip_location + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/hijack_srcip_location #结束时间格式Y-M-D h:i:s ${Time} get current date ${endTime}= add time to date ${Time} -00:05:00 @@ -54,8 +55,8 @@ Statistics-hijack_srcip_location-00004 #最近一周 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable hijack_srcip_location - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/hijack_srcip_location + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/hijack_srcip_location #结束时间格式Y-M-D h:i:s ${Time} get current date ${endTime}= add time to date ${Time} -00:05:00 @@ -71,8 +72,8 @@ Statistics-hijack_srcip_location-00005 #最近一个月(30天) #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable hijack_srcip_location - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/hijack_srcip_location + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/hijack_srcip_location #结束时间格式Y-M-D h:i:s ${Time} get current date ${endTime}= add time to date ${Time} -00:05:00 @@ -88,8 +89,8 @@ Statistics-hijack_srcip_location-00006 #最近一年(365天) #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable hijack_srcip_location - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/hijack_srcip_location + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/hijack_srcip_location #结束时间格式Y-M-D h:i:s ${Time} get current date ${endTime}= add time to date ${Time} -00:05:00 diff --git a/01-TestCase/tsg_bfapi/api_log/LogStatistics-hijack_srcip_num.robot b/01-TestCase/tsg_bfapi/api_log/LogStatistics-hijack_srcip_num.robot index a452ca4..6cf2617 100644 --- a/01-TestCase/tsg_bfapi/api_log/LogStatistics-hijack_srcip_num.robot +++ b/01-TestCase/tsg_bfapi/api_log/LogStatistics-hijack_srcip_num.robot @@ -1,5 +1,6 @@ *** Settings *** Resource ../../../02-Keyword/tsg_bfapi/LogStatistics.robot +Resource ../../../03-Variable/BifangApiVariable.txt Library DateTime *** Test Cases *** @@ -7,8 +8,8 @@ LogStatistics-hijack_scrip_num-00001 #120未更新 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable hijack_srcip_num - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/hijack_srcip_num + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/hijack_srcip_num #开始时间格式Y-M-D h:i:s ${startTime} set variable 2020-04-26 16:40:01 #结束时间格式Y-M-D h:i:s @@ -20,8 +21,8 @@ LogStatistics-hijack_scrip_num-00001 LogStatistics-hijack_scrip_num-00002 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable hijack_srcip_num - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/hijack_srcip_num + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/hijack_srcip_num #结束时间格式Y-M-D h:i:s ${Time} get current date ${endTime}= add time to date ${Time} -00:05:00 @@ -36,8 +37,8 @@ LogStatistics-hijack_scrip_num-00002 LogStatistics-hijack_scrip_num-00003 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable hijack_srcip_num - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/hijack_srcip_num + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/hijack_srcip_num #结束时间格式Y-M-D h:i:s ${Time} get current date ${endTime}= add time to date ${Time} -00:05:00 @@ -52,8 +53,8 @@ LogStatistics-hijack_scrip_num-00003 LogStatistics-hijack_scrip_num-00004 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable hijack_srcip_num - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/hijack_srcip_num + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/hijack_srcip_num #结束时间格式Y-M-D h:i:s ${Time} get current date ${endTime}= add time to date ${Time} -00:05:00 @@ -68,8 +69,8 @@ LogStatistics-hijack_scrip_num-00004 LogStatistics-hijack_scrip_num-00005 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable hijack_srcip_num - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/hijack_srcip_num + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/hijack_srcip_num #结束时间格式Y-M-D h:i:s ${Time} get current date ${endTime}= add time to date ${Time} -00:05:00 @@ -84,8 +85,8 @@ LogStatistics-hijack_scrip_num-00005 LogStatistics-hijack_scrip_num-00006 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable hijack_srcip_num - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/hijack_srcip_num + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/hijack_srcip_num #结束时间格式Y-M-D h:i:s ${Time} get current date ${endTime}= add time to date ${Time} -00:05:00 diff --git a/01-TestCase/tsg_bfapi/api_log/LogStatistics-injectionstatistics.robot b/01-TestCase/tsg_bfapi/api_log/LogStatistics-injectionstatistics.robot index 6f072fb..a883b70 100644 --- a/01-TestCase/tsg_bfapi/api_log/LogStatistics-injectionstatistics.robot +++ b/01-TestCase/tsg_bfapi/api_log/LogStatistics-injectionstatistics.robot @@ -1,5 +1,6 @@ *** Settings *** Resource ../../../02-Keyword/tsg_bfapi/LogStatistics.robot +Resource ../../../03-Variable/BifangApiVariable.txt Library DateTime *** Test Cases *** @@ -7,8 +8,8 @@ LogStatistics-injectionstatistics-00001 #120未更新 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable injectionstatistics - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/traffic/injectionstatistics + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/traffic/injectionstatistics #开始时间格式Y-M-D h:i:s ${startTime} set variable 2020-04-26 16:40:01 #结束时间格式Y-M-D h:i:s @@ -25,8 +26,8 @@ LogStatistics-injectionstatistics-00002 #120未更新 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable injectionstatistics - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/traffic/injectionstatistics + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/traffic/injectionstatistics #结束时间格式Y-M-D h:i:s ${Time} get current date ${endTime}= add time to date ${Time} -00:05:00 @@ -42,8 +43,8 @@ LogStatistics-injectionstatistics-00003 #120未更新 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable injectionstatistics - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/traffic/injectionstatistics + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/traffic/injectionstatistics #结束时间格式Y-M-D h:i:s ${Time} get current date ${endTime}= add time to date ${Time} -00:05:00 @@ -60,8 +61,8 @@ LogStatistics-injectionstatistics-00004 #120未更新 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable injectionstatistics - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/traffic/injectionstatistics + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/traffic/injectionstatistics #结束时间格式Y-M-D h:i:s ${Time} get current date ${endTime}= add time to date ${Time} -00:05:00 @@ -78,8 +79,8 @@ LogStatistics-injectionstatistics-00005 #120未更新 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable injectionstatistics - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/traffic/injectionstatistics + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/traffic/injectionstatistics #结束时间格式Y-M-D h:i:s ${Time} get current date ${endTime}= add time to date ${Time} -00:05:00 @@ -96,8 +97,8 @@ LogStatistics-injectionstatistics-00006 #120未更新 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable injectionstatistics - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/traffic/injectionstatistics + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/traffic/injectionstatistics #结束时间格式Y-M-D h:i:s ${Time} get current date ${endTime}= add time to date ${Time} -00:05:00 diff --git a/01-TestCase/tsg_bfapi/api_log/LogStatistics-ip_correlation_domain.robot b/01-TestCase/tsg_bfapi/api_log/LogStatistics-ip_correlation_domain.robot index f0961ed..6f191ea 100644 --- a/01-TestCase/tsg_bfapi/api_log/LogStatistics-ip_correlation_domain.robot +++ b/01-TestCase/tsg_bfapi/api_log/LogStatistics-ip_correlation_domain.robot @@ -1,13 +1,14 @@ *** Settings *** Resource ../../../02-Keyword/tsg_bfapi/LogStatistics.robot +Resource ../../../03-Variable/BifangApiVariable.txt Library DateTime *** Test Cases *** Statistics-ip_correlation_domain-00001 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable ip_correlation_domain - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/ip_correlation_domain + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/ip_correlation_domain #开始时间格式Y-M-D h:i:s ${startTime} set variable 2020-04-01 16:05:04 #结束时间格式Y-M-D h:i:s @@ -19,8 +20,8 @@ Statistics-ip_correlation_domain-00001 Statistics-ip_correlation_domain-00002 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable ip_correlation_domain - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/ip_correlation_domain + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/ip_correlation_domain #开始时间格式Y-M-D h:i:s ${startTime} set variable 2020-04-01 16:05:04 #结束时间格式Y-M-D h:i:s @@ -31,8 +32,8 @@ Statistics-ip_correlation_domain-00003 #最近一小时 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable ip_correlation_domain - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/ip_correlation_domain + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/ip_correlation_domain #结束时间格式Y-M-D h:i:s ${Time} get current date ${endTime}= add time to date ${Time} -00:05:00 @@ -48,8 +49,8 @@ Statistics-ip_correlation_domain-00004 #最近一天 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable ip_correlation_domain - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/ip_correlation_domain + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/ip_correlation_domain #结束时间格式Y-M-D h:i:s ${Time} get current date ${endTime}= add time to date ${Time} -00:05:00 @@ -65,8 +66,8 @@ Statistics-ip_correlation_domain-00005 #最近一周(7天) #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable ip_correlation_domain - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/ip_correlation_domain + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/ip_correlation_domain #结束时间格式Y-M-D h:i:s ${Time} get current date ${endTime}= add time to date ${Time} -00:05:00 @@ -82,8 +83,8 @@ Statistics-ip_correlation_domain-00006 #最近一个月(30天) #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable ip_correlation_domain - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/ip_correlation_domain + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/ip_correlation_domain #结束时间格式Y-M-D h:i:s ${Time} get current date ${endTime}= add time to date ${Time} -00:05:00 @@ -99,8 +100,8 @@ Statistics-ip_correlation_domain-00007 #最近一年 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable ip_correlation_domain - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/ip_correlation_domain + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/ip_correlation_domain #结束时间格式Y-M-D h:i:s ${Time} get current date ${endTime}= add time to date ${Time} -00:05:00 diff --git a/01-TestCase/tsg_bfapi/api_log/LogStatistics-topn.robot b/01-TestCase/tsg_bfapi/api_log/LogStatistics-topn.robot index d2b85b5..887be40 100644 --- a/01-TestCase/tsg_bfapi/api_log/LogStatistics-topn.robot +++ b/01-TestCase/tsg_bfapi/api_log/LogStatistics-topn.robot @@ -1,13 +1,14 @@ *** Settings *** Resource ../../../02-Keyword/tsg_bfapi/LogStatistics.robot +Resource ../../../03-Variable/BifangApiVariable.txt *** Test Cases *** LogStatistics-topn-00001 #131已通过 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable topn - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/traffic/topn/domain + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/traffic/topn/domain #开始时间格式Y-M-D h:i:s ${startTime} set variable 2020-04-26 18:38:07 #结束时间格式Y-M-D h:i:s diff --git a/01-TestCase/tsg_bfapi/api_log/LogStatistics-traffic.robot b/01-TestCase/tsg_bfapi/api_log/LogStatistics-traffic.robot index 04a585e..4d76ff1 100644 --- a/01-TestCase/tsg_bfapi/api_log/LogStatistics-traffic.robot +++ b/01-TestCase/tsg_bfapi/api_log/LogStatistics-traffic.robot @@ -1,13 +1,14 @@ *** Settings *** Resource ../../../02-Keyword/tsg_bfapi/LogStatistics.robot +Resource ../../../03-Variable/BifangApiVariable.txt Library DateTime *** Test Cases *** Statistics-traffic-00001 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable traffic - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/traffic/statisticsbyunit + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/traffic/statisticsbyunit #统计类型: bytes:字节数 packets:包数 sessions:连接数 如不指定,则统计全部 statisticsUnit=${statisticUnit} ${statisticUnit} set variable bytes #开始时间格式Y-M-D h:i:s @@ -22,8 +23,8 @@ Statistics-traffic-00001 Statistics-traffic-00002 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable traffic - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/traffic/statisticsbyunit + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/traffic/statisticsbyunit #开始时间格式Y-M-D h:i:s ${startTime} set variable 2020-04-26 13:36:35 ${endTime} set variable 2020-04-26 23:04:56 @@ -33,8 +34,8 @@ Statistics-traffic-00003 #最近一小时 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable traffic - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/traffic/statisticsbyunit + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/traffic/statisticsbyunit #统计类型: bytes:字节数 packets:包数 sessions:连接数 如不指定,则统计全部 statisticsUnit=${statisticUnit} ${statisticUnit} set variable bytes #结束时间格式Y-M-D h:i:s @@ -53,8 +54,8 @@ Statistics-traffic-00004 #最近一天 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable traffic - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/traffic/statisticsbyunit + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/traffic/statisticsbyunit #统计类型: bytes:字节数 packets:包数 sessions:连接数 如不指定,则统计全部 statisticsUnit=${statisticUnit} ${statisticUnit} set variable bytes #结束时间格式Y-M-D h:i:s @@ -73,8 +74,8 @@ Statistics-traffic-00005 #最近一周(7天) #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable traffic - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/traffic/statisticsbyunit + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/traffic/statisticsbyunit #统计类型: bytes:字节数 packets:包数 sessions:连接数 如不指定,则统计全部 statisticsUnit=${statisticUnit} ${statisticUnit} set variable bytes #结束时间格式Y-M-D h:i:s @@ -93,8 +94,8 @@ Statistics-traffic-00006 #最近一个月(30天) #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable traffic - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/traffic/statisticsbyunit + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/traffic/statisticsbyunit #统计类型: bytes:字节数 packets:包数 sessions:连接数 如不指定,则统计全部 statisticsUnit=${statisticUnit} ${statisticUnit} set variable bytes #结束时间格式Y-M-D h:i:s @@ -113,8 +114,8 @@ Statistics-traffic-00007 #最近一年(365天) #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable traffic - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/traffic/statisticsbyunit + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/traffic/statisticsbyunit #统计类型: bytes:字节数 packets:包数 sessions:连接数 如不指定,则统计全部 statisticsUnit=${statisticUnit} ${statisticUnit} set variable bytes #结束时间格式Y-M-D h:i:s diff --git a/01-TestCase/tsg_bfapi/api_log/LogStatistics-url.robot b/01-TestCase/tsg_bfapi/api_log/LogStatistics-url.robot index d5fff93..b1f60ce 100644 --- a/01-TestCase/tsg_bfapi/api_log/LogStatistics-url.robot +++ b/01-TestCase/tsg_bfapi/api_log/LogStatistics-url.robot @@ -1,12 +1,13 @@ *** Settings *** Resource ../../../02-Keyword/tsg_bfapi/LogStatistics.robot +Resource ../../../03-Variable/BifangApiVariable.txt *** Test Cases *** Statistics-url-00001 #apiName,请求大数据时,用于区分每个接口的sql ${apiName} set variable url - #请求地址 例如:/report/domain/recommend - ${url} set variable /report/url/recommend + #请求地址 例如:/${version}/report/domain/recommend + ${url} set variable /${version}/report/url/recommend #统计时间, \ 查询最近24小时数据;例如当前时间为2020-03-26 15:14:00, 查询时间应设为推前1小时的整点,实际传入参数为 "2020-03-26 14:00:00" \ 响应参数说明 ${statisticTime} set variable 2020-04-27 14:00:00 GetApi ${apiName} ${url} statisticTime=${statisticTime} diff --git a/01-TestCase/tsg_bfapi/api_log/LogStatistics_Trend.robot b/01-TestCase/tsg_bfapi/api_log/LogStatistics_Trend.robot index 5f472ed..1a904c1 100644 --- a/01-TestCase/tsg_bfapi/api_log/LogStatistics_Trend.robot +++ b/01-TestCase/tsg_bfapi/api_log/LogStatistics_Trend.robot @@ -1,8 +1,9 @@ *** Settings *** -Resource ../../02-Keyword/tsg_bfapi/LogStatistics.robot +Resource ../../../02-Keyword/tsg_bfapi/LogStatistics.robot +Resource ../../../03-Variable/BifangApiVariable.txt *** Variables *** -${url} /report/policyevent/hit/trend +${url} /${version}/report/policyevent/hit/trend *** Test Cases *** LogStatistics-Trend-00001 diff --git a/02-Keyword/tsg_bfapi/CommonUtil.robot b/02-Keyword/tsg_bfapi/CommonUtil.robot new file mode 100644 index 0000000..dc8f565 --- /dev/null +++ b/02-Keyword/tsg_bfapi/CommonUtil.robot @@ -0,0 +1,15 @@ +*** Settings *** +Resource ../../03-Variable/BifangApiVariable.txt +Library DateTime +Library String +#Library Collections +#Library RequestsLibrary + +*** Keywords *** +GetLast24HoursStartAndEndTime + [Documentation] + ... 获取当前时间往前一天的开始结束时间,时间格式为:YYY-MM-DD H24:mm:ss + ${endtime} Get Time + ${starttime}= Add Time To Date ${endtime} -1 days + ${starttime} Get Substring ${starttime} 0 19 + [Return] ${starttime} ${endtime} \ No newline at end of file diff --git a/02-Keyword/tsg_bfapi/LogStatistics.robot b/02-Keyword/tsg_bfapi/LogStatistics.robot index 2355442..47cdce1 100644 --- a/02-Keyword/tsg_bfapi/LogStatistics.robot +++ b/02-Keyword/tsg_bfapi/LogStatistics.robot @@ -244,7 +244,7 @@ Recommend Trend [Arguments] ${url} ${startTime} ${endTime} ${logType} ${policyId} ${header} Create Dictionary Content-Type=application/x-www-form-urlencoded Authorization=${token} - Create Session api http://${host}:${port}/${version} headers=${header} + Create Session api http://${host}:${port} headers=${header} ${remoteResponse} Get Request api ${url}?policyId=${policyId}&logType=${logType}&startTime=${startTime}&endTime=${endTime} headers=${header} ${response} to json ${remoteResponse.content} Should Be Equal As Strings ${remoteResponse.status_code} 200 diff --git a/02-Keyword/tsg_bfapi/Log_schema.robot b/02-Keyword/tsg_bfapi/Log_schema.robot index 072a47d..e071117 100644 --- a/02-Keyword/tsg_bfapi/Log_schema.robot +++ b/02-Keyword/tsg_bfapi/Log_schema.robot @@ -7,7 +7,7 @@ Resource ../tsg_bfapi/ApiRequest.robot *** Keywords *** schema - ${responsedata} Get-Request log/schema?logType=active_defence_event_log + ${responsedata} Get-Request /v1/log/schema?logType=active_defence_event_log ${responsedata1} Get From Dictionary ${responsedata} data ${responsefields} Get From Dictionary ${responsedata1} fields [Return] ${responsedata}