summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhebingning <[email protected]>2022-07-11 19:36:53 +0800
committerhebingning <[email protected]>2022-07-11 19:36:53 +0800
commita83b2ad74133ce1ace4d5ca3ce9f7e7ed04c1681 (patch)
tree6f576b32a4916eee53b29110d1cb6fcfc3f945c5
parent10188feaa02dd70d652b6b20e37703b0c7d04a4f (diff)
日志验证相关逻辑调整:增加对空和非空的判断
-rw-r--r--keyword/common/common.robot22
-rw-r--r--keyword/common/log_variable.robot25
-rw-r--r--keyword/common/login_logout.robot18
-rw-r--r--keyword/objects/object.robot4
-rw-r--r--keyword/objects/process_object_body.robot2
-rw-r--r--keyword/policys/policy.robot9
6 files changed, 48 insertions, 32 deletions
diff --git a/keyword/common/common.robot b/keyword/common/common.robot
index f794189..6e96824 100644
--- a/keyword/common/common.robot
+++ b/keyword/common/common.robot
@@ -49,7 +49,7 @@ BasePostRequestOK
BasePostRequestForV2
[Arguments] ${requestUri} ${data} ${apiVersion}
- ${headers} set variable {"Authorization":"${token}","Content-Type":"application/json"}
+ ${headers} Set Variable {"Authorization":"${token}","Content-Type":"application/json"}
Create Session api ${httpVersion}://${host}:${port}/${apiVersion} ${headers} verify=false
${response}= Post Request api ${requestUri} data=${data}
log ${data}
@@ -80,6 +80,20 @@ BaseGetRequest
${response} Set Variable ${httpResponse.body}
Delete All Sessions
[Return] ${response}
+
+BaseGetRequestWithToken
+ [Arguments] ${requestUri} ${data} ${accessToken} ${apiVersion} ${code}
+ ${headers} Set Variable {"Authorization":"${accessToken}","Content-Type":"application/json"}
+ Create Session api ${httpVersion}://${host}:${port}/${apiVersion} ${headers} verify=false
+ ${response}= Get Request api ${requestUri}${data}
+ log ${data}
+ log return data =${response}
+ #Should Be Equal As Strings ${response.status_code} 200
+ ${response} to json ${response.content}
+ Delete All Sessions
+ [Return] ${response}
+
+
BaseGetRequestOK
[Arguments] ${apistr} ${body}
${response} BaseGetRequest ${apistr} ${body}
@@ -339,11 +353,17 @@ ExecuteScript
Comment 登录并且执行命令
${returnConnect} ${connect} Run Keyword And Ignore Error Open Connection ${manageIp}
+ Run Keyword If "${returnConnect}"=="FAIL" Wait Until Keyword Succeeds 5min 30sec RetryConnection
${returnLogin} ${login} Run Keyword And Ignore Error SSHLibrary.Login ${manageUser} ${managePassword}
Write cd ${scriptsPath} && ./pcap.sh -a ${contractTime} -b ${threadCount} -c ${runMode} -u ${pcapPath} -s ${sourceIPRange} -d ${desIPRange}
${res} Read delay=${contractTime}
Should Contain ${res} ${commandRes}
[Return] ${res}
+
+RetryConnection
+ [Arguments] ${manageIp}
+ Open Connection ${manageIp}
+
CreatePolicyByJson
[Arguments] ${policyJson} ${code}=null
${response} BasePostRequestForV2 /policy/compile ${policyJson} ${version2}
diff --git a/keyword/common/log_variable.robot b/keyword/common/log_variable.robot
index 7fdffbe..29af385 100644
--- a/keyword/common/log_variable.robot
+++ b/keyword/common/log_variable.robot
@@ -124,7 +124,7 @@ GetLogListMulti
[Arguments] ${logType} ${startTime} ${endTime} ${client_ip} ${policy_id} ${logQueryParam} ${schemaType}=${EMPTY}
${logCondition} GetLogCondition ${logType} ${startTime} ${endTime} ${client_ip} ${policy_id} ${schemaType}
log ${logCondition}
- ${LogListResponse} PostRemoteData /${version}/log/list ${logCondition}
+ ${returnLogListResponse} ${LogListResponse} Run Keyword And Ignore Error PostRemoteData /${version}/log/list ${logCondition}
Should Be Equal As Strings ${LogListResponse.status_code} 200
${returnData} To Json ${LogListResponse.content}
${responseCode} Get From Dictionary ${returnData} code
@@ -142,12 +142,25 @@ GetLogListMulti
${queryValue} Get From Dictionary ${logQueryParams} queryValue
${queryValue} Run Keyword If "${queryValue}"=="hostip" Set Variable ${host}
... ELSE Set Variable ${queryValue}
- Should Contain ${logs}"" ${queryFiledKey}
- Should Contain ${logs}"${queryFiledKey}" ${queryValue}
+ log ${logs}""
+ ${type} Evaluate type(${logs})
+ Run Keyword If "${queryValue}"=="empty" Should Not Contain ${logs}"" ${queryFiledKey}
+ ... ELSE Should Contain ${logs}"" ${queryFiledKey}
+ # Run Keyword If "${queryValue}"=="empty" Should Not Contain ${logs}"${queryFiledKey}" ${queryValue}
+ # ... ELSE Should Contain ${logs}"${queryFiledKey}" ${queryValue}
+ Run Keyword If "${queryValue}"=="empty" Should Not Contain ${logs}[0][${queryFiledKey}] ${queryValue}
+ ... ELSE IF "${queryValue}"=="notEmpty" Should Not Be Empty ${logs}[0][${queryFiledKey}] ${queryValue}
+ ... ELSE Should Contain ${logs}[0][${queryFiledKey}] ${queryValue}
+ log ${logs}[0][${queryFiledKey}]
+ log %%%%%%%%%%%%%%%%%%%%%%%%${logs}
+ Run Keyword If "${queryValue}"=="empty" Should Not Contain ${logs}"" ${client_ip}
+ ... ELSE Should Contain ${logs}"" ${client_ip}
+ Run Keyword If ("${logType}"=="security_event" or "${logType}"=="proxy_event") and "${queryValue}"!="empty" Should Contain ${logs}"" ${policy_id}
+ ... ELSE Should Not Contain ${logs}"" ${policy_id}
END
- log %%%%%%%%%%%%%%%%%%%%%%%%${logs}
- Should Contain ${logs}"" ${client_ip}
- Run Keyword If "${logType}"=="security_event" or "${logType}"=="proxy_event" Should Contain ${logs}"" ${policy_id}
+ # log %%%%%%%%%%%%%%%%%%%%%%%%${logs}
+ # Should Contain ${logs}"" ${client_ip}
+ # Run Keyword If "${logType}"=="security_event" or "${logType}"=="proxy_event" Should Contain ${logs}"" ${policy_id}
GetPolicySessionRecords
diff --git a/keyword/common/login_logout.robot b/keyword/common/login_logout.robot
index 2897552..9ef07c0 100644
--- a/keyword/common/login_logout.robot
+++ b/keyword/common/login_logout.robot
@@ -164,33 +164,15 @@ ApiLogin
# 云测系统登录
${sidCode} TestinLogin
# 毕方接口密码加密
- # Get Request api ${requestUri}?${data}
- # GET /${version}/user/encryptpwd?password=${password}
${headers} Set variable {"Authorization":"${token}","Content-Type":"application/json"}
Create session api ${httpVersion}://${host}:${port} ${headers} verify=false
${response}= Get Request api /${version}/user/encryptpwd?password=${password}
${response} to json ${response.content}
- # Object response body
- # Integer $.code 200
Should Be Equal As Strings ${response['code']} 200
- #log ${rescode}
- # ${pwd} String $.data.encryptpwd
${pwdstr} Get From Dictionary ${response['data']} encryptpwd
- #log ${pwd}
- # ${pwdstr} Get From List ${pwd} 0
log ${pwdstr}
SET GLOBAL VARIABLE ${encodePassword} ${pwdstr}
log ${encodePassword}
- #log ${username}
- #log ${pwdstr}
- # POST /${version}/user/login?username=${username}&password=${encodePassword}&authMode=${authmode}
- # Object response body
- # #OUTPUT response body
- # Integer $.code 200
- # ${rescode} Integer $.code
- # log ${rescode}
- # ${tokenGlobal} String $.data.token
- # ${tokenStr} Get From List ${tokenGlobal} 0
${headers} Set variable {"Authorization":"${token}","Content-Type":"application/json"}
Create session api ${httpVersion}://${host}:${port} ${headers} verify=false
diff --git a/keyword/objects/object.robot b/keyword/objects/object.robot
index aa71003..927c086 100644
--- a/keyword/objects/object.robot
+++ b/keyword/objects/object.robot
@@ -839,7 +839,7 @@ DeleteGroupObject
[Arguments] ${objectids}
#删除对象
log todeleteobjAndCategory
- ${response} BaseDeleteRequest /${version}/policy/object {"objectIds":${objectids}}
+ ${response} BaseDeleteRequest /${version}/policy/object {"objectIds":${objectids},"vsysId":1}
${response_code} Get From Dictionary ${response} code
Should Be Equal As Strings ${response_code} 200
${response} Convert to String ${response}
@@ -856,7 +856,7 @@ DeleteGroupCategory
[Arguments] ${categoryids}
#删除对象
log todeleteobjAndCategory
- ${response} BaseDeleteRequest /${version}/category/dict {"categoryIds":${categoryids}}
+ ${response} BaseDeleteRequest /${version}/category/dict {"categoryIds":${categoryids},"vsysId":1}
${response_code} Get From Dictionary ${response} code
Should Be Equal As Strings ${response_code} 200
${response} Convert to String ${response}
diff --git a/keyword/objects/process_object_body.robot b/keyword/objects/process_object_body.robot
index caad7e8..a4099a1 100644
--- a/keyword/objects/process_object_body.robot
+++ b/keyword/objects/process_object_body.robot
@@ -132,7 +132,7 @@ CategoryOperation
${json} CategoryOrganize ${category} ${opAction}
# 转为json结构并返回
- ${dict} Create Dictionary opAction=${opAction} returnData=${returnData} list=replace:objectList
+ ${dict} Create Dictionary opAction=${opAction} returnData=${returnData} list=replace:objectList vsysId=1
${bodyJson} json.Dumps ${dict} ensure_ascii=False
${json} Replace String ${bodyJson} "replace:objectList" ${json}
diff --git a/keyword/policys/policy.robot b/keyword/policys/policy.robot
index 4620fb4..f3fb0a6 100644
--- a/keyword/policys/policy.robot
+++ b/keyword/policys/policy.robot
@@ -779,7 +779,7 @@ ExcuteFtpCommand
sleep ${policyLogVerificationSleepSeconds}
Log 获取结束时间
- ${endtime} Run Keyword If "${isUTC}"=="True" Get Current Date UTC exclude_millis=True
+ ${endtime} Run Keyword If "${isUTC}"=="True" Get Current Date UTC increment=00:00:10 exclude_millis=True
... ELSE Get Time
${returnLogSuccess} ${log} Run Keyword And Ignore Error GetLogListMulti ${logType} ${startTime} ${endTime} ${operationIp} ${logPolicyId} ${logQueryParam}
${excuteSuccessful} Run Keyword If "${returnConnect}"=="PASS" and "${returnIsExcute}"=="PASS" and "${returnLogSuccess}"=="PASS" Evaluate ${excuteSuccessful}+1
@@ -838,7 +838,7 @@ EmailSend
${returnIsExcute} ${excute} Run Keyword And Ignore Error Should Contain ${res} ${hopeResult}
sleep ${policyLogVerificationSleepSeconds}
Log 获取结束时间
- ${endtime} Run Keyword If "${isUTC}"=="True" Get Current Date UTC exclude_millis=True
+ ${endtime} Run Keyword If "${isUTC}"=="True" Get Current Date UTC increment=00:00:10 exclude_millis=True
... ELSE Get Time
${returnLogSuccess} ${log} Run Keyword And Ignore Error GetLogListMulti ${logType} ${startTime} ${endTime} ${operationIp} ${logPolicyId} ${logQueryParam}
${excuteSuccessful} Run Keyword If "${returnConnect}"=="PASS" and "${returnIsExcute}"=="PASS" and "${returnLogSuccess}"=="PASS" Evaluate ${excuteSuccessful}+1
@@ -1405,8 +1405,9 @@ CreatePolicysAndObjects
... ELSE IF "${action}" == "deny" and "${method}" == "drop" Set Variable {"protocol":"${key}","method": "${method}","send_icmp_unreachable":${sendIcmpUnreachable}}
... ELSE IF "${action}" == "deny" and "${return}" != "FAIL" Set Variable {"protocol":"${key}","method": "${method}","packet_capture":{"enable":${logCapture},"capture_depth":${captureDepth}}}
... ELSE IF "${action}" == "deny" and "${method}" != "block" and "${return}" == "FAIL" Set Variable {"protocol":"${key}","method": "${method}"}
- ... ELSE IF "${action}" == "monitor" and "${returnMirrorVlan}"!="FAIL" and "${mirrorVlan}"!= "None" and "${policyType}" == "tsg_security" Set Variable {"protocol":"${key}","traffic_mirror":{"enable":${mirrorEnable},"mirror_vlan":${mirrorVlan}}}
- ... ELSE IF "${action}" == "monitor" and "${returnMirrorVlan}"=="FAIL" and "${policyType}" == "tsg_security" Set Variable {"protocol":"${key}","traffic_mirror":{"enable":${mirrorEnable},"mirror_vlan":null}}
+ ... ELSE IF "${action}" == "monitor" and "${returnMirrorVlan}"!="FAIL" and "${mirrorVlan}"!= "None" and "${policyType}" == "tsg_security" and "${return}" == "FAIL" Set Variable {"protocol":"${key}","traffic_mirror":{"enable":${mirrorEnable},"mirror_vlan":${mirrorVlan}}}
+ ... ELSE IF "${action}" == "monitor" and "${returnMirrorVlan}"=="FAIL" and "${policyType}" == "tsg_security" and "${return}" == "FAIL" Set Variable {"protocol":"${key}","traffic_mirror":{"enable":${mirrorEnable},"mirror_vlan":null}}
+ ... ELSE IF "${action}" == "monitor" and "${returnMirrorVlan}"=="FAIL" and "${policyType}" == "tsg_security" and "${return}" != "FAIL" Set Variable {"protocol":"${key}","traffic_mirror":{"enable":${mirrorEnable},"mirror_vlan":null},"packet_capture":{"enable":${logCapture},"capture_depth":${captureDepth}}}
... ELSE IF "${action}" == "intercept" and "${key}" == "ssl" Set Variable {"protocol":"SSL","keyring": ${keyring},"decryption":${decryption},"traffic_mirror":${traffic_mirror}}
... ELSE IF "${return}" != "FAIL" Set Variable {"protocol":"${key}","packet_capture":{"enable":${logCapture},"capture_depth":${captureDepth}}}
... ELSE Set Variable {"protocol":"${key}"}