diff --git a/01-TestCase/tsg_bfapi/active_defence_event_log/.gitkeep b/01-TestCase/tsg_bfapi/active_defence_event_log/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/01-TestCase/tsg_bfapi/active_defence_event_log/Log-count.robot b/01-TestCase/tsg_bfapi/active_defence_event_log/Log-count.robot new file mode 100644 index 0000000..3593d81 --- /dev/null +++ b/01-TestCase/tsg_bfapi/active_defence_event_log/Log-count.robot @@ -0,0 +1,362 @@ +*** Settings *** +Force Tags api api-log api-log-active_defence_event_log api-log-active_defence_event_log-count +Resource ../../../02-Keyword/tsg_bfapi/Log_keyword.robot +Resource ../../../02-Keyword/tsg_bfapi/Common.robot +Library OperatingSystem +Library Selenium2Library +Library RequestsLibrary +Library Collections +Library string +Library REST http://${host}:${port}/${version} +Library json + +*** Test Cases *** +CountLog-001 + ${condition} Set Variable { "field":"ad_target_ip", "type":"string", "symbol":"sub", "value":["22"] } + ${pageSize} Set Variable 30 + ${pageNo} Set Variable 1 + ${starttime} Set Variable 2020-04-26 12:27:03 + ${endtime} Set Variable 2020-04-27 13:27:03 + ${logname} Set Variable active_defence_event_log + ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}","conditions":${condition}} + ${url} Set Variable log/count + ${response} Post-Request ${url} ${logCondition} + ${responsejson} Evaluate type($response) + Should Be Equal As Strings ${response}[code] 200 + log ${response}[data][total] + +CountLog-002 + ${condition} Set Variable [] + ${pageSize} Set Variable 30 + ${pageNo} Set Variable 1 + ${starttime} Set Variable 2020-04-26 12:27:03 + ${endtime} Set Variable 2020-04-27 13:27:03 + ${logname} Set Variable active_defence_event_log + ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}","conditions":${condition}} + ${url} Set Variable log/count + ${response} Post-Request ${url} ${logCondition} + ${responsejson} Evaluate type($response) + Should Be Equal As Strings ${response}[code] 200 + log ${response}[data][total] + +CountLog-003 + ${condition} Set Variable {"field":"common_log_id","type":"long","symbol":"=","value":["59526984506148866"] } + ${pageSize} Set Variable 30 + ${pageNo} Set Variable 1 + ${starttime} Set Variable 2020-04-26 12:27:03 + ${endtime} Set Variable 2020-04-27 13:27:03 + ${logname} Set Variable active_defence_event_log + ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}","conditions":${condition}} + ${url} Set Variable log/count + ${response} Post-Request ${url} ${logCondition} + ${responsejson} Evaluate type($response) + Should Be Equal As Strings ${response}[code] 200 + log ${response}[data][total] + +CountLog-004 + ${condition} Set Variable { "field":"common_recv_time", "type":"timestamp", "symbol":"=", "value":["2020-04-27 12:48:33"] } + ${pageSize} Set Variable 30 + ${pageNo} Set Variable 1 + ${starttime} Set Variable 2020-04-26 12:27:03 + ${endtime} Set Variable 2020-04-27 13:27:03 + ${logname} Set Variable active_defence_event_log + ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}","conditions":${condition}} + ${url} Set Variable log/count + ${response} Post-Request ${url} ${logCondition} + ${responsejson} Evaluate type($response) + Should Be Equal As Strings ${response}[code] 200 + log ${response}[data][total] + +CountLog-005 + ${condition} Set Variable { "field":"common_policy_id", "type":"int", "symbol":"=", "value":["774"] } + ${pageSize} Set Variable 30 + ${pageNo} Set Variable 1 + ${starttime} Set Variable 2020-04-26 12:27:03 + ${endtime} Set Variable 2020-04-27 13:27:03 + ${logname} Set Variable active_defence_event_log + ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}","conditions":${condition}} + ${url} Set Variable log/count + ${response} Post-Request ${url} ${logCondition} + ${responsejson} Evaluate type($response) + Should Be Equal As Strings ${response}[code] 200 + log ${response}[data][total] + +CountLog-006 + ${condition} Set Variable { "field":"ad_cc_target_url", "type":"string", "symbol":"sub", "value":["www.jianshu.com"] } + ${pageSize} Set Variable 30 + ${pageNo} Set Variable 1 + ${starttime} Set Variable 2020-04-26 12:27:03 + ${endtime} Set Variable 2020-04-27 13:27:03 + ${logname} Set Variable active_defence_event_log + ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}","conditions":${condition}} + ${url} Set Variable log/count + ${response} Post-Request ${url} ${logCondition} + ${responsejson} Evaluate type($response) + Should Be Equal As Strings ${response}[code] 200 + log ${response}[data][total] + +CountLog-007 + ${condition} 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"] } + ${pageSize} Set Variable 30 + ${pageNo} Set Variable 1 + ${starttime} Set Variable 2020-04-26 12:27:03 + ${endtime} Set Variable 2020-04-27 13:27:03 + ${logname} Set Variable active_defence_event_log + ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}","condaiapi-logaa tions":[${condition}]} + ${url} Set Variable log/count + ${response} Post-Request ${url} ${logCondition} + ${responsejson} Evaluate type($response) + Should Be Equal As Strings ${response}[code] 200 + log ${response}[data][total] + +CountLog-008 + ${condition} Set Variable { "field":"ad_target_ip", "type":"string", "symbol":"prefix", "value":["10"] } + ${pageSize} Set Variable 30 + ${pageNo} Set Variable 1 + ${starttime} Set Variable 2020-04-26 12:27:03 + ${endtime} Set Variable 2020-04-27 13:27:03 + ${logname} Set Variable active_defence_event_log + ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}","conditions":${condition}} + ${url} Set Variable log/count + ${response} Post-Request ${url} ${logCondition} + ${responsejson} Evaluate type($response) + Should Be Equal As Strings ${response}[code] 200 + log ${response}[data][total] + +CountLog-009 + ${condition} Set Variable { "field":"ad_target_ip", "type":"string", "symbol":"suffix", "value":["222"] } + ${pageSize} Set Variable 30 + ${pageNo} Set Variable 1 + ${starttime} Set Variable 2020-04-26 12:27:03 + ${endtime} Set Variable 2020-04-27 13:27:03 + ${logname} Set Variable active_defence_event_log + ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}","conditions":${condition}} + ${url} Set Variable log/count + ${response} Post-Request ${url} ${logCondition} + ${responsejson} Evaluate type($response) + Should Be Equal As Strings ${response}[code] 200 + log ${response}[data][total] + +CountLog-010 + ${condition} Set Variable { "field":"ad_target_ip", "type":"string", "symbol":"exactly", "value":["10.3.22.222"] } + ${pageSize} Set Variable 30 + ${pageNo} Set Variable 1 + ${starttime} Set Variable 2020-04-26 12:27:03 + ${endtime} Set Variable 2020-04-27 13:27:03 + ${logname} Set Variable active_defence_event_log + ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}","conditions":${condition}} + ${url} Set Variable log/count + ${response} Post-Request ${url} ${logCondition} + ${responsejson} Evaluate type($response) + Should Be Equal As Strings ${response}[code] 200 + log ${response}[data][total] + +CountLog-011 + ${condition} Set Variable { "field":"ad_target_ip", "type":"string", "value":["10"] } + ${pageSize} Set Variable 30 + ${pageNo} Set Variable 1 + ${starttime} Set Variable 2020-04-26 12:27:03 + ${endtime} Set Variable 2020-04-27 13:27:03 + ${logname} Set Variable active_defence_event_log + ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}","conditions":${condition}} + ${url} Set Variable log/count + ${response} Post-Request ${url} ${logCondition} + ${responsejson} Evaluate type($response) + Should Be Equal As Strings ${response}[code] 200 + log ${response}[data][total] + +CountLog-012 + ${condition} Set Variable { "field":"ad_target_ip", "type":"string", "value":["10"] } + ${pageSize} Set Variable 30 + ${pageNo} Set Variable 1 + ${starttime} Set Variable 2020-04-26 12:27:03 + ${endtime} Set Variable 2020-04-27 13:27:03 + ${logname} Set Variable active_defence_event_log + ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}","conditions":${condition}} + ${url} Set Variable log/count + ${response} Post-Request ${url} ${logCondition} + ${responsejson} Evaluate type($response) + Should Be Equal As Strings ${response}[code] 200 + log ${response}[data][total] + +CountLog-013 + ${condition} Set Variable { "field":"common_policy_id", "type":"int", "symbol":"!=", "value":["774"] } + ${pageSize} Set Variable 30 + ${pageNo} Set Variable 1 + ${starttime} Set Variable 2020-04-26 12:27:03 + ${endtime} Set Variable 2020-04-27 13:27:03 + ${logname} Set Variable active_defence_event_log + ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}","conditions":${condition}} + ${url} Set Variable log/count + ${response} Post-Request ${url} ${logCondition} + ${responsejson} Evaluate type($response) + Should Be Equal As Strings ${response}[code] 200 + log ${response}[data][total] + +CountLog-014 + ${condition} Set Variable { "field":"common_policy_id", "type":"int", "symbol":"!=", "value":["774"] } + ${pageSize} Set Variable 30 + ${pageNo} Set Variable 1 + ${starttime} Set Variable 2020-04-26 12:27:03 + ${endtime} Set Variable 2020-04-27 13:27:03 + ${logname} Set Variable active_defence_event_log + ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}","conditions":${condition}} + ${url} Set Variable log/count + ${response} Post-Request ${url} ${logCondition} + ${responsejson} Evaluate type($response) + Should Be Equal As Strings ${response}[code] 200 + log ${response}[data][total] + +CountLog-015 + ${condition} Set Variable { "field":"common_policy_id", "type":"int", "symbol":"<", "value":["774"] } + ${pageSize} Set Variable 30 + ${pageNo} Set Variable 1 + ${starttime} Set Variable 2020-04-26 12:27:03 + ${endtime} Set Variable 2020-04-27 13:27:03 + ${logname} Set Variable active_defence_event_log + ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}","conditions":${condition}} + ${url} Set Variable log/count + ${response} Post-Request ${url} ${logCondition} + ${responsejson} Evaluate type($response) + Should Be Equal As Strings ${response}[code] 200 + log ${response}[data][total] + +CountLog-016 + ${condition} Set Variable { "field":"common_policy_id", "type":"int", "symbol":"<=", "value":["774"] } + ${pageSize} Set Variable 30 + ${pageNo} Set Variable 1 + ${starttime} Set Variable 2020-04-26 12:27:03 + ${endtime} Set Variable 2020-04-27 13:27:03 + ${logname} Set Variable active_defence_event_log + ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}","conditions":${condition}} + ${url} Set Variable log/count + ${response} Post-Request ${url} ${logCondition} + ${responsejson} Evaluate type($response) + Should Be Equal As Strings ${response}[code] 200 + log ${response}[data][total] + +CountLog-017 + ${condition} Set Variable { "field":"common_policy_id", "type":"int", "symbol":">=", "value":["774"] } + ${pageSize} Set Variable 30 + ${pageNo} Set Variable 1 + ${starttime} Set Variable 2020-04-26 12:27:03 + ${endtime} Set Variable 2020-04-27 13:27:03 + ${logname} Set Variable active_defence_event_log + ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}","conditions":${condition}} + ${url} Set Variable log/count + ${response} Post-Request ${url} ${logCondition} + ${responsejson} Evaluate type($response) + Should Be Equal As Strings ${response}[code] 200 + log ${response}[data][total] + +CountLog-018 + ${condition} Set Variable { "field":"common_policy_id", "type":"int", "symbol":"in", "value":["774","95"] } + ${pageSize} Set Variable 30 + ${pageNo} Set Variable 1 + ${starttime} Set Variable 2020-04-26 12:27:03 + ${endtime} Set Variable 2020-04-27 13:27:03 + ${logname} Set Variable active_defence_event_log + ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}","conditions":${condition}} + ${url} Set Variable log/count + ${response} Post-Request ${url} ${logCondition} + ${responsejson} Evaluate type($response) + Should Be Equal As Strings ${response}[code] 200 + log ${response}[data][total] + +CountLog-019 + ${condition} Set Variable { "field":"common_recv_time", "type":"timestamp", "value":["2020-04-27 12:48:33"] } + ${pageSize} Set Variable 30 + ${pageNo} Set Variable 1 + ${starttime} Set Variable 2020-04-26 12:27:03 + ${endtime} Set Variable 2020-04-27 13:27:03 + ${logname} Set Variable active_defence_event_log + ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}","conditions":${condition}} + ${url} Set Variable log/count + ${response} Post-Request ${url} ${logCondition} + ${responsejson} Evaluate type($response) + Should Be Equal As Strings ${response}[code] 200 + log ${response}[data][total] + +CountLog-020 + ${condition} Set Variable { "field":"common_recv_time", "type":"timestamp", "symbol":">", "value":["2020-04-27 12:48:33"] } + ${pageSize} Set Variable 30 + ${pageNo} Set Variable 1 + ${starttime} Set Variable 2020-04-26 12:27:03 + ${endtime} Set Variable 2020-04-27 13:27:03 + ${logname} Set Variable active_defence_event_log + ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}","conditions":${condition}} + ${url} Set Variable log/count + ${response} Post-Request ${url} ${logCondition} + ${responsejson} Evaluate type($response) + Should Be Equal As Strings ${response}[code] 200 + log ${response}[data][total] + +CountLog-021 + ${condition} Set Variable { "field":"common_recv_time", "type":"timestamp", "symbol":"<", "value":["2020-04-27 12:48:33"] } + ${pageSize} Set Variable 30 + ${pageNo} Set Variable 1 + ${starttime} Set Variable 2020-04-26 12:27:03 + ${endtime} Set Variable 2020-04-27 13:27:03 + ${logname} Set Variable active_defence_event_log + ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}","conditions":${condition}} + ${url} Set Variable log/count + ${response} Post-Request ${url} ${logCondition} + ${responsejson} Evaluate type($response) + Should Be Equal As Strings ${response}[code] 200 + log ${response}[data][total] + +CountLog-022 + ${condition} Set Variable { "field":"common_recv_time", "type":"timestamp", "symbol":"<=", "value":["2020-04-27 12:48:33"] } + ${pageSize} Set Variable 30 + ${pageNo} Set Variable 1 + ${starttime} Set Variable 2020-04-26 12:27:03 + ${endtime} Set Variable 2020-04-27 13:27:03 + ${logname} Set Variable active_defence_event_log + ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}","conditions":${condition}} + ${url} Set Variable log/count + ${response} Post-Request ${url} ${logCondition} + ${responsejson} Evaluate type($response) + Should Be Equal As Strings ${response}[code] 200 + log ${response}[data][total] + +CountLog-023 + ${condition} Set Variable { "field":"common_recv_time", "type":"timestamp", "symbol":">=", "value":["2020-04-27 12:48:33"] } + ${pageSize} Set Variable 30 + ${pageNo} Set Variable 1 + ${starttime} Set Variable 2020-04-26 12:27:03 + ${endtime} Set Variable 2020-04-27 13:27:03 + ${logname} Set Variable active_defence_event_log + ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}","conditions":${condition}} + ${url} Set Variable log/count + ${response} Post-Request ${url} ${logCondition} + ${responsejson} Evaluate type($response) + Should Be Equal As Strings ${response}[code] 200 + log ${response}[data][total] + +CountLog-024 + ${condition} Set Variable { "field":"common_recv_time", "type":"timestamp", "symbol":"between", "value":["2020-04-27 12:48:33","2020-04-27 13:27:03"] } + ${pageSize} Set Variable 30 + ${pageNo} Set Variable 1 + ${starttime} Set Variable 2020-04-26 12:27:03 + ${endtime} Set Variable 2020-04-27 13:27:03 + ${logname} Set Variable active_defence_event_log + ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}","conditions":${condition}} + ${url} Set Variable log/count + ${response} Post-Request ${url} ${logCondition} + ${responsejson} Evaluate type($response) + Should Be Equal As Strings ${response}[code] 200 + log ${response}[data][total] + +CountLog-025 + ${condition} Set Variable { "field":"common_recv_time", "type":"timestamp", "value":["2020-04-27 12:48:33","2020-04-27 13:27:03"] } + ${pageSize} Set Variable 30 + ${pageNo} Set Variable 1 + ${starttime} Set Variable 2020-04-26 12:27:03 + ${endtime} Set Variable 2020-04-27 13:27:03 + ${logname} Set Variable active_defence_event_log + ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}","conditions":${condition}} + ${url} Set Variable log/count + ${response} Post-Request ${url} ${logCondition} + ${responsejson} Evaluate type($response) + Should Be Equal As Strings ${response}[code] 200 + log ${response}[data][total] 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 new file mode 100644 index 0000000..bebd611 --- /dev/null +++ b/01-TestCase/tsg_bfapi/active_defence_event_log/Log_batch.robot @@ -0,0 +1,285 @@ +*** Settings *** +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 + +*** Variables *** +@{logType} security_event_log proxy_event_log connection_record_log radius_record_log + +*** Test Cases *** +ExportLog-001 + ${conditions} Set Variable {"field":"common_log_id","type":"long","symbol":"=","value":["59526984506148866"] } + ${logname} Set Variable active_defence_event_log + ${logCondition} GetLogCondition ${logname} 2020-04-26 12:27:03 2020-04-27 13:27:03 30 1 + ... ${conditions} + log ${logCondition} + ${header} Create Dictionary Content-Type=application/json Authorization=${token} + ${success} downloadexcel ${header} ${logCondition} http://${host}:${port}/${version}/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 + ${logCondition} GetLogCondition ${logname} 2020-04-26 12:27:03 2020-04-27 13:27:03 30 1 + ... ${conditions} + log ${logCondition} + ${header} Create Dictionary Content-Type=application/json Authorization=${token} + ${success} downloadexcel ${header} ${logCondition} http://${host}:${port}/${version}/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 + ${logCondition} GetLogCondition ${logname} 2020-04-26 12:27:03 2020-04-27 13:27:03 30 1 + ... ${conditions} + log ${logCondition} + ${header} Create Dictionary Content-Type=application/json Authorization=${token} + ${success} downloadexcel ${header} ${logCondition} http://${host}:${port}/${version}/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 + ${logCondition} GetLogCondition ${logname} 2020-04-26 12:27:03 2020-04-27 13:27:03 30 1 + ... ${conditions} + log ${logCondition} + ${header} Create Dictionary Content-Type=application/json Authorization=${token} + ${success} downloadexcel ${header} ${logCondition} http://${host}:${port}/${version}/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 + ${logCondition} GetLogCondition ${logname} 2020-04-26 12:27:03 2020-04-27 13:27:03 30 1 + ... ${conditions} + log ${logCondition} + ${header} Create Dictionary Content-Type=application/json Authorization=${token} + ${success} downloadexcel ${header} ${logCondition} http://${host}:${port}/${version}/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 + ${logCondition} GetLogCondition ${logname} 2020-04-26 12:27:03 2020-04-27 13:27:03 30 1 + ... ${conditions} + log ${logCondition} + ${header} Create Dictionary Content-Type=application/json Authorization=${token} + ${success} downloadexcel ${header} ${logCondition} http://${host}:${port}/${version}/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 + ${logCondition} GetLogCondition ${logname} 2020-04-26 12:27:03 2020-04-27 13:27:03 30 1 + ... [${conditions}] + log ${logCondition} + ${header} Create Dictionary Content-Type=application/json Authorization=${token} + ${success} downloadexcel ${header} ${logCondition} http://${host}:${port}/${version}/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 + ${logCondition} GetLogCondition ${logname} 2020-04-26 12:27:03 2020-04-27 13:27:03 30 1 + ... ${conditions} + log ${logCondition} + ${header} Create Dictionary Content-Type=application/json Authorization=${token} + ${success} downloadexcel ${header} ${logCondition} http://${host}:${port}/${version}/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 + ${logCondition} GetLogCondition ${logname} 2020-04-26 12:27:03 2020-04-27 13:27:03 30 1 + ... ${conditions} + log ${logCondition} + ${header} Create Dictionary Content-Type=application/json Authorization=${token} + ${success} downloadexcel ${header} ${logCondition} http://${host}:${port}/${version}/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 + ${logCondition} GetLogCondition ${logname} 2020-04-26 12:27:03 2020-04-27 13:27:03 30 1 + ... ${conditions} + log ${logCondition} + ${header} Create Dictionary Content-Type=application/json Authorization=${token} + ${success} downloadexcel ${header} ${logCondition} http://${host}:${port}/${version}/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 + ${logCondition} GetLogCondition ${logname} 2020-04-26 12:27:03 2020-04-27 13:27:03 30 1 + ... ${conditions} + log ${logCondition} + ${header} Create Dictionary Content-Type=application/json Authorization=${token} + ${success} downloadexcel ${header} ${logCondition} http://${host}:${port}/${version}/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 + ${logCondition} GetLogCondition ${logname} 2020-04-26 12:27:03 2020-04-27 13:27:03 30 1 + ... ${conditions} + log ${logCondition} + ${header} Create Dictionary Content-Type=application/json Authorization=${token} + ${success} downloadexcel ${header} ${logCondition} http://${host}:${port}/${version}/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 + ${logCondition} GetLogCondition ${logname} 2020-04-26 12:27:03 2020-04-27 13:27:03 30 1 + ... ${conditions} + log ${logCondition} + ${header} Create Dictionary Content-Type=application/json Authorization=${token} + ${success} downloadexcel ${header} ${logCondition} http://${host}:${port}/${version}/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 + ${logCondition} GetLogCondition ${logname} 2020-04-26 12:27:03 2020-04-27 13:27:03 30 1 + ... ${conditions} + log ${logCondition} + ${header} Create Dictionary Content-Type=application/json Authorization=${token} + ${success} downloadexcel ${header} ${logCondition} http://${host}:${port}/${version}/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 + ${logCondition} GetLogCondition ${logname} 2020-04-26 12:27:03 2020-04-27 13:27:03 30 1 + ... ${conditions} + log ${logCondition} + ${header} Create Dictionary Content-Type=application/json Authorization=${token} + ${success} downloadexcel ${header} ${logCondition} http://${host}:${port}/${version}/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 + ${logCondition} GetLogCondition ${logname} 2020-04-26 12:27:03 2020-04-27 13:27:03 30 1 + ... ${conditions} + log ${logCondition} + ${header} Create Dictionary Content-Type=application/json Authorization=${token} + ${success} downloadexcel ${header} ${logCondition} http://${host}:${port}/${version}/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 + ${logCondition} GetLogCondition ${logname} 2020-04-26 12:27:03 2020-04-27 13:27:03 30 1 + ... ${conditions} + log ${logCondition} + ${header} Create Dictionary Content-Type=application/json Authorization=${token} + ${success} downloadexcel ${header} ${logCondition} http://${host}:${port}/${version}/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 + ${logCondition} GetLogCondition ${logname} 2020-04-26 12:27:03 2020-04-27 13:27:03 30 1 + ... ${conditions} + log ${logCondition} + ${header} Create Dictionary Content-Type=application/json Authorization=${token} + ${success} downloadexcel ${header} ${logCondition} http://${host}:${port}/${version}/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 + ${logCondition} GetLogCondition ${logname} 2020-04-26 12:27:03 2020-04-27 13:27:03 30 1 + ... ${conditions} + log ${logCondition} + ${header} Create Dictionary Content-Type=application/json Authorization=${token} + ${success} downloadexcel ${header} ${logCondition} http://${host}:${port}/${version}/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 + ${logCondition} GetLogCondition ${logname} 2020-04-26 12:27:03 2020-04-27 13:27:03 30 1 + ... ${conditions} + log ${logCondition} + ${header} Create Dictionary Content-Type=application/json Authorization=${token} + ${success} downloadexcel ${header} ${logCondition} http://${host}:${port}/${version}/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 + ${logCondition} GetLogCondition ${logname} 2020-04-26 12:27:03 2020-04-27 13:27:03 30 1 + ... ${conditions} + log ${logCondition} + ${header} Create Dictionary Content-Type=application/json Authorization=${token} + ${success} downloadexcel ${header} ${logCondition} http://${host}:${port}/${version}/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 + ${logCondition} GetLogCondition ${logname} 2020-04-26 12:27:03 2020-04-27 13:27:03 30 1 + ... ${conditions} + log ${logCondition} + ${header} Create Dictionary Content-Type=application/json Authorization=${token} + ${success} downloadexcel ${header} ${logCondition} http://${host}:${port}/${version}/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 + ${logCondition} GetLogCondition ${logname} 2020-04-26 12:27:03 2020-04-27 13:27:03 30 1 + ... ${conditions} + log ${logCondition} + ${header} Create Dictionary Content-Type=application/json Authorization=${token} + ${success} downloadexcel ${header} ${logCondition} http://${host}:${port}/${version}/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","2020-04-27 13:27:03"] } + ${logname} Set Variable active_defence_event_log + ${logCondition} GetLogCondition ${logname} 2020-04-26 12:27:03 2020-04-27 13:27:03 30 1 + ... ${conditions} + log ${logCondition} + ${header} Create Dictionary Content-Type=application/json Authorization=${token} + ${success} downloadexcel ${header} ${logCondition} http://${host}:${port}/${version}/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","2020-04-27 13:27:03"] } + ${logname} Set Variable active_defence_event_log + ${logCondition} GetLogCondition ${logname} 2020-04-26 12:27:03 2020-04-27 13:27:03 30 1 + ... ${conditions} + log ${logCondition} + ${header} Create Dictionary Content-Type=application/json Authorization=${token} + ${success} downloadexcel ${header} ${logCondition} http://${host}:${port}/${version}/log/batch + log ${success} + Should Be Equal ${success} ${200} active_defence_event_log\ test query export failed + +*** Keywords *** 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 new file mode 100644 index 0000000..ecce2e0 --- /dev/null +++ b/01-TestCase/tsg_bfapi/active_defence_event_log/Log_search.robot @@ -0,0 +1,310 @@ +*** Settings *** +Force Tags api api-log api-log-active_defence_event_log api-log-active_defence_event_log-search +Library OperatingSystem +Library Selenium2Library +Library RequestsLibrary +Library Collections +Resource ../../../02-Keyword/tsg_bfapi/Log_schema.robot +Resource ../../../02-Keyword/tsg_bfapi/Log_search.robot +Library string +Library REST http://${host}:${port}/${version} +Resource ../../../02-Keyword/tsg_bfapi/Log_keyword.robot + +*** Test Cases *** +log-schema-001 + ${filds} schema + log ${filds} + +log-search-002 + #${filds} schema + ${responsedata} Get-Request 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} [] + log ${response} + Should Be Equal As Strings ${response.code} 200 + +log-search-003 + #${filds} schema + ${responsedata} Get-Request log/schema?logType=active_defence_event_log + ${filds} Set Variable ${responsedata['data']['fields']} + ${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}] + log ${response} + Should Be Equal As Strings ${response.code} 200 + ${responsedata} Get From Dictionary ${response} data + log ${responsedata} + ${responselist} Get From Dictionary ${responsedata} list + ${logid} Set Variable ${responselist}[0][common_log_id] + Should Be Equal As Strings ${logid} 59526984506148866 + +log-search-004 + #${filds} schema + ${responsedata} Get-Request 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}] + 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 + +log-search-005 + #${filds} schema + ${responsedata} Get-Request 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} + log ${response} + Should Be Equal As Strings ${response.code} 200 + ${responsedata} Get From Dictionary ${response} data + log ${responsedata} + ${responselist} Get From Dictionary ${responsedata} list + ${policyid} Set Variable ${responselist}[0][common_policy_id] + Should Be Equal As Strings ${policyid} 774 + +log-search-006 + #${filds} schema + ${responsedata} Get-Request log/schema?logType=active_defence_event_log + ${filds} Set Variable ${responsedata['data']['fields']} + ${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} + log ${response} + Should Be Equal As Strings ${response.code} 200 + ${responsedata} Get From Dictionary ${response} data + log ${responsedata} + ${responselist} Get From Dictionary ${responsedata} list + log ${responselist} + should be empty ${responselist} + +log-search-007 + #${filds} schema + ${responsedata} Get-Request log/schema?logType=active_defence_event_log + ${filds} Set Variable ${responsedata['data']['fields']} + ${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} + log ${response} + Should Be Equal As Strings ${response.code} 200 + ${responsedata} Get From Dictionary ${response} data + log ${responsedata} + ${responselist} Get From Dictionary ${responsedata} list + ${ip} Set Variable ${responselist}[0][ad_target_ip] + should contain ${ip} 22 + +log-search-008 + #${filds} schema + ${responsedata} Get-Request log/schema?logType=active_defence_event_log + ${filds} Set Variable ${responsedata['data']['fields']} + ${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} + log ${response} + Should Be Equal As Strings ${response.code} 200 + ${responsedata} Get From Dictionary ${response} data + log ${responsedata} + ${responselist} Get From Dictionary ${responsedata} list + ${ip} Set Variable ${responselist}[0][ad_target_ip] + should contain ${ip} 10 + +log-search-009 + #${filds} schema + ${responsedata} Get-Request log/schema?logType=active_defence_event_log + ${filds} Set Variable ${responsedata['data']['fields']} + ${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} + log ${response} + Should Be Equal As Strings ${response.code} 200 + ${responsedata} Get From Dictionary ${response} data + log ${responsedata} + ${responselist} Get From Dictionary ${responsedata} list + ${ip} Set Variable ${responselist}[0][ad_target_ip] + should contain ${ip} 222 + +log-search-010 + #${filds} schema + ${responsedata} Get-Request log/schema?logType=active_defence_event_log + ${filds} Set Variable ${responsedata['data']['fields']} + ${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} + log ${response} + Should Be Equal As Strings ${response.code} 200 + ${responsedata} Get From Dictionary ${response} data + log ${responsedata} + ${responselist} Get From Dictionary ${responsedata} list + ${ip} Set Variable ${responselist}[0][ad_target_ip] + Should Be Equal As Strings ${ip} 10.3.22.222 + +log-search-011 + #${filds} schema + ${responsedata} Get-Request log/schema?logType=active_defence_event_log + ${filds} Set Variable ${responsedata['data']['fields']} + ${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}] + log ${response} + Should Be Equal As Strings ${response.code} 200 + ${responsedata} Get From Dictionary ${response} data + log ${responsedata} + ${responselist} Get From Dictionary ${responsedata} list + ${ip} Set Variable ${responselist}[0][ad_target_ip] + Should Be Equal As Strings ${ip} 10.3.22.222 + ${time} Set Variable ${responselist}[0][common_recv_time] + Should Be Equal As Strings ${time} 2020-04-27 13:27:02 + ${logid} Set Variable ${responselist}[0][common_log_id] + Should Be Equal As Strings ${logid} 59526984506148866 + ${policyid} Set Variable ${responselist}[0][common_policy_id] + Should Be Equal As Strings ${policyid} 95 + +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 + ... ${conditions} + ${response} BasePostRequest v1/log/list ${logCondition} + Should Be Equal As Strings ${response.code} 200 + ${responsedata} Get From Dictionary ${response} data + log ${responsedata} + ${responselist} Get From Dictionary ${responsedata} list + ${logid} Set Variable ${responselist}[0][common_log_id] + Should Be Equal As Strings ${logid} 59526984506148866 + +log-search-013 + #${filds} schema + ${responsedata} Get-Request 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} + log ${response} + Should Be Equal As Strings ${response.code} 200 + ${responsedata} Get From Dictionary ${response} data + log ${responsedata} + ${responselist} Get From Dictionary ${responsedata} list + ${policyid} Set Variable ${responselist}[0][common_policy_id] + Should Be Equal As Strings ${policyid} 774 + +log-search-014 + #${filds} schema + ${responsedata} Get-Request 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} + log ${response} + Should Be Equal As Strings ${response.code} 200 + +log-search-015 + #${filds} schema + ${responsedata} Get-Request 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} + log ${response} + Should Be Equal As Strings ${response.code} 200 + +log-search-016 + #${filds} schema + ${responsedata} Get-Request 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} + log ${response} + Should Be Equal As Strings ${response.code} 200 + +log-search-017 + #${filds} schema + ${responsedata} Get-Request 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} + log ${response} + Should Be Equal As Strings ${response.code} 200 + +log-search-018 + #${filds} schema + ${responsedata} Get-Request 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} + log ${response} + Should Be Equal As Strings ${response.code} 200 + +log-search-019 + #${filds} schema + ${responsedata} Get-Request 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} + log ${response} + Should Be Equal As Strings ${response.code} 200 + +log-search-020 + #${filds} schema + ${responsedata} Get-Request 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}] + 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 + +log-search-021 + #${filds} schema + ${responsedata} Get-Request 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}] + log ${response} + Should Be Equal As Strings ${response.code} 200 + +log-search-022 + #${filds} schema + ${responsedata} Get-Request 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}] + log ${response} + Should Be Equal As Strings ${response.code} 200 + +log-search-023 + #${filds} schema + ${responsedata} Get-Request 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}] + 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 + +log-search-024 + #${filds} schema + ${responsedata} Get-Request 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}] + log ${response} + Should Be Equal As Strings ${response.code} 200 + +log-search-025 + #${filds} schema + ${responsedata} Get-Request 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}] + log ${response} + Should Be Equal As Strings ${response.code} 200 + +log-search-026 + #${filds} schema + ${responsedata} Get-Request 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}] + log ${response} + Should Be Equal As Strings ${response.code} 200 diff --git a/01-TestCase/tsg_bfapi/active_defence_event_log/__pycache__/downloadexcel.cpython-36.pyc b/01-TestCase/tsg_bfapi/active_defence_event_log/__pycache__/downloadexcel.cpython-36.pyc new file mode 100644 index 0000000..5814042 Binary files /dev/null and b/01-TestCase/tsg_bfapi/active_defence_event_log/__pycache__/downloadexcel.cpython-36.pyc differ diff --git a/01-TestCase/tsg_bfapi/active_defence_event_log/__pycache__/downloadexcel.cpython-37.pyc b/01-TestCase/tsg_bfapi/active_defence_event_log/__pycache__/downloadexcel.cpython-37.pyc new file mode 100644 index 0000000..ad87edb Binary files /dev/null and b/01-TestCase/tsg_bfapi/active_defence_event_log/__pycache__/downloadexcel.cpython-37.pyc differ diff --git a/01-TestCase/tsg_bfapi/active_defence_event_log/downloadexcel.py b/01-TestCase/tsg_bfapi/active_defence_event_log/downloadexcel.py new file mode 100644 index 0000000..110cee9 --- /dev/null +++ b/01-TestCase/tsg_bfapi/active_defence_event_log/downloadexcel.py @@ -0,0 +1,14 @@ +import requests + + +def downloadexcel(headers,data,url): + response = requests.post(url, headers=headers, data=data) + if response.status_code == 200: + with open("active_defence_event_log"+".xlsx", "wb") as code: + code.write(response.content) + return 200; + else: + print('导出失败'+response.content) + return 500; +if __name__ == '__main__': + downloadexcel(header,data,url) \ No newline at end of file diff --git a/02-Keyword/tsg_bfapi/ApiRequest.robot b/02-Keyword/tsg_bfapi/ApiRequest.robot index 6226ba8..2acf7e7 100644 --- a/02-Keyword/tsg_bfapi/ApiRequest.robot +++ b/02-Keyword/tsg_bfapi/ApiRequest.robot @@ -1,7 +1,7 @@ *** Settings *** -Library Collections -Library RequestsLibrary -Resource ../../03-Variable/BifangApiVariable.txt +Library Collections +Library RequestsLibrary +Resource ../../03-Variable/BifangApiVariable.txt *** Keywords *** Post-Request @@ -21,30 +21,30 @@ Get-Request ${response} to json ${remoteResponse.content} Should Be Equal As Strings ${remoteResponse.status_code} 200 [Return] ${response} - + Delete-Request [Arguments] ${url} ${data} ${header} Create Dictionary Content-Type=application/json Authorization=${token} Create Session api http://${host}:${port}/${version} headers=${header} - ${remoteResponse} Delete Request api ${url} data=${data} headers=${header} + ${remoteResponse} Delete Request api ${url} data=${data} headers=${header} ${response} to json ${remoteResponse.content} Should Be Equal As Strings ${remoteResponse.status_code} 200 [Return] ${response} - + UpFilePostRequest [Arguments] ${url} ${data} ${files} ${fileDesc} ${header} Set To Dictionary ${fileDesc} Authorization=${token} Create Session api http://${host}:${port}/${version} headers=${header} - ${remoteResponse} Post Request api ${url} data=${data} files=${files} headers=${header} + ${remoteResponse} Post Request api ${url} data=${data} files=${files} headers=${header} ${response} to json ${remoteResponse.content} Should Be Equal As Strings ${remoteResponse.status_code} 200 [Return] ${response} - + UpFilePutRequest [Arguments] ${url} ${data} ${files} ${fileDesc} - ${header} Set To Dictionary ${fileDesc} Authorization=${token} + ${header} Set To Dictionary ${fileDesc} Authorization=${token} Create Session api http://${host}:${port}/${version} headers=${header} - ${remoteResponse} Put Request api ${url} params=${data} files=${files} headers=${header} + ${remoteResponse} Put Request api ${url} params=${data} files=${files} headers=${header} ${response} to json ${remoteResponse.content} Should Be Equal As Strings ${remoteResponse.status_code} 200 - [Return] ${response} + [Return] ${response} diff --git a/02-Keyword/tsg_bfapi/Common.robot b/02-Keyword/tsg_bfapi/Common.robot index f827db1..7dd8217 100644 --- a/02-Keyword/tsg_bfapi/Common.robot +++ b/02-Keyword/tsg_bfapi/Common.robot @@ -8,6 +8,7 @@ Library RequestsLibrary BasePostRequest [Arguments] ${apistr} ${body} Set Headers {"Authorization":"${token}","Content-Type":"application/json"} + log 111111111111111111111111${apistr} &{httpResponse} Post ${apistr} ${body} #Output response body Object response body diff --git a/02-Keyword/tsg_bfapi/LogSchema.robot b/02-Keyword/tsg_bfapi/LogSchema.robot index fcb8681..7bda6a0 100644 --- a/02-Keyword/tsg_bfapi/LogSchema.robot +++ b/02-Keyword/tsg_bfapi/LogSchema.robot @@ -4,13 +4,13 @@ Library RequestsLibrary Library OperatingSystem Library Collections Library string -Library REST http://${host}:${port} +Library REST http://${host}:${port}/${version} *** Keywords *** GetLogCondition [Arguments] ${logname} ${startTime} ${endTime} ${client_ip} ${policy_id} Set Headers {"Content-Type":"application/x-www-form-urlencoded","Authorization":"${token}"} - &{LogSchemaResponse}= GET /v1/log/schema?logType=${logname} + &{LogSchemaResponse}= GET /log/schema?logType=${logname} log ${logname} #Output Schema response body Object response body @@ -31,3 +31,39 @@ PostRemoteData Create Session api http://${host}:${port}/${version} headers=${header} ${remoteResponse} Post Request api ${url} data=${data} headers=${header} [Return] ${remoteResponse} + +GetALLLogCondition + [Arguments] ${logname} ${startTime} ${endTime} ${client_ip} ${policy_id} ${pageSize} ${pageNo} + Set Headers {"Content-Type":"application/x-www-form-urlencoded","Authorization":"${token}"} + &{LogSchemaResponse}= GET /log/schema?logType=${logname} + log ${logname} + #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 + log ${field} + #${pageSize} Set Variable 30 + #${pageNo} Set Variable 1 + ${condition} Set Variable [{"value":["${startTime}","${endTime}"],"symbol":"between","field":"common_recv_time","type":"timestamp"}] + ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","fields":${field},"start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}","conditions":${condition} ,"common_client_ips":"${client_ip}","common_policy_ids":"${policy_id}"} + log this time query condition:${logCondition} + [Return] ${logCondition} + +GetLogCountConditon + [Arguments] ${logname} ${startTime} ${endTime} ${client_ip} ${policy_id} ${pageSize} ${pageNo} + Set Headers {"Content-Type":"application/x-www-form-urlencoded","Authorization":"${token}"} + &{LogSchemaResponse}= GET /log/schema?logType=${logname} + log ${logname} + #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 + log ${field} + #${pageSize} Set Variable 30 + #${pageNo} Set Variable 1 + ${condition} Set Variable [{"value":["${startTime}","${endTime}"],"symbol":"between","field":"common_recv_time","type":"timestamp"}] + ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","fields":${field},"start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}","conditions":${condition} ,"common_client_ips":"${client_ip}","common_policy_ids":"${policy_id}"} + log this time query condition:${logCondition} + [Return] ${logCondition} \ No newline at end of file diff --git a/02-Keyword/tsg_bfapi/Log_keyword.robot b/02-Keyword/tsg_bfapi/Log_keyword.robot new file mode 100644 index 0000000..90e941b --- /dev/null +++ b/02-Keyword/tsg_bfapi/Log_keyword.robot @@ -0,0 +1,27 @@ +*** Settings *** +Library REST +Library string +Library Collections +Library OperatingSystem +Library RequestsLibrary +Resource ../tsg_bfapi/ApiRequest.robot +Resource ../../03-Variable/BifangApiVariable.txt +Library json + +*** Variables *** + +*** Keywords *** +GetLogCondition + [Arguments] ${logname} ${start_time} ${end_time} ${page_size} ${page_no} ${condition1} + ${responsedata} Get-Request log/schema?logType=active_defence_event_log + ${fields} Set Variable ${responsedata['data']['fields']} + ${field} json.dumps ${fields} + log ${field} + ${startTime} Set Variable ${start_time} + ${endTime} Set Variable ${end_time} + ${pageSize} Set Variable ${page_size} + ${pageNo} Set Variable ${page_no} + ${condition} Set Variable ${condition1} + ${logCondition} Set Variable {"pageNo":${pageNo},"pageSize":${pageSize},"logType":"${logname}","fields":${field},"start_common_recv_time":"${startTime}","end_common_recv_time":"${endTime}","conditions":${condition}} + log this time query condition:${logCondition} + [Return] ${logCondition} diff --git a/02-Keyword/tsg_bfapi/Log_schema.robot b/02-Keyword/tsg_bfapi/Log_schema.robot new file mode 100644 index 0000000..072a47d --- /dev/null +++ b/02-Keyword/tsg_bfapi/Log_schema.robot @@ -0,0 +1,13 @@ +*** Settings *** +Library OperatingSystem +Library Selenium2Library +Library RequestsLibrary +Library Collections +Resource ../tsg_bfapi/ApiRequest.robot + +*** Keywords *** +schema + ${responsedata} Get-Request log/schema?logType=active_defence_event_log + ${responsedata1} Get From Dictionary ${responsedata} data + ${responsefields} Get From Dictionary ${responsedata1} fields + [Return] ${responsedata} diff --git a/02-Keyword/tsg_bfapi/Log_search.robot b/02-Keyword/tsg_bfapi/Log_search.robot new file mode 100644 index 0000000..dd00124 --- /dev/null +++ b/02-Keyword/tsg_bfapi/Log_search.robot @@ -0,0 +1,20 @@ +*** Settings *** +Library json +Library OperatingSystem +Library Selenium2Library +Library RequestsLibrary +Library Collections +Resource ../tsg_bfapi/ApiRequest.robot +Resource Log_schema.robot +Resource ../tsg_bfapi/Common.robot + +*** Keywords *** +log_search + [Arguments] ${start-time} ${end-time} ${type} ${filds} ${conditions} + log 111111${filds} + ${filedsJson} json.dumps ${filds} + ${requestbody} Set Variable {"start_common_recv_time":"${start-time}","end_common_recv_time":"${end-time}","logType":"${type}","fields":${filedsJson},"conditions":${conditions},"refuseCode":true} + log %%%%%%%%%%${requestbody} + ${response} BasePostRequest v1/log/list ${requestbody} + log ${response} + [Return] ${response} diff --git a/03-Variable/BifangApiVariable.txt b/03-Variable/BifangApiVariable.txt index b009b8e..77ce247 100644 --- a/03-Variable/BifangApiVariable.txt +++ b/03-Variable/BifangApiVariable.txt @@ -4,20 +4,20 @@ ${loginType} api #执行环境是否Widonws ${systemType} Windows #API配置信息 -${host} 192.168.40.120 +${host} 192.168.40.131 ${port} 8080 ${authmode} 1 ${authCode} ${EMPTY} ${ldapId} 27 ${version} v1 -${username} uitest +${username} lyf ${password} 111111 ${encodePassword} ${EMPTY} ${token} ${EMPTY} #[Documentation] 测试终端IP统一配置 -${testClentIP} 192.168.50.57 -${testSubscriberID} $test57 -#自动化标签 +${testClentIP} 192.168.50.37 +${testSubscriberID} $test57 +#自动化标签 ${userTagIds} ${EMPTY} #Documentation] 是否添加测试终端IP到策略统一配置,0为不添加测试终端IP,1为添加测试终端IP,默认1 ${addTestClentIPFlag} 1 @@ -29,7 +29,7 @@ ${policyLogVerificationSleepSeconds} 60 ${path} E:/auto_git/eclipsegit/tsg_autotest/05-Other ${curlbatpath} ${path}/curl ${mailpath} ${path}/mail -${responsePageFiles} ${path}/response_pages_files/ +${responsePageFiles} ${path}/response_pages_files/ #全流程分阶段测试参数 #[Documentation] 当前测试部分,all为一个终端全网全流程测试, #1为添加策略和对象测试; @@ -46,13 +46,14 @@ ${cliHost} 192.168.40.165 ${cliUsername} tsgadmin ${cliPassword} Cli2019 ${timeout} 600s -${retryInterval} 300s +${retryInterval} 300s @{PolicyTypes} tsg_security pxy_manipulation -@{ObjectTypes} ip url fqdn keywords subscriberid fqdn_category account http_signature +@{ObjectTypes} ip url fqdn keywords subscriberid fqdn_category account +... http_signature # Cli自动化测试变量[end] # SNMP服务测试变量[start] -${snmpHost} 192.168.40.165 -${snmpPort} 50161 -${snmpConnTimeout} 5 # 默认超时时间为6s,设置timeout值后超时时间为n*6s -${snmpCommunity} public +${snmpHost} 192.168.40.165 +${snmpPort} 50161 +${snmpConnTimeout} 5 # 默认超时时间为6s,设置timeout值后超时时间为n*6s +${snmpCommunity} public # SNMP服务测试变量[end]