fix(策略验证):策略验证修复,取消client,server的IP,Port区分,只有ip,port两个字段

This commit is contained in:
wangxin
2020-07-21 19:40:32 +08:00
parent a469fcc409
commit efe41fe5ac
3 changed files with 42 additions and 38 deletions

View File

@@ -390,7 +390,7 @@ VerifyPolicyObj
[Arguments] ${verifyObj}
Log To Console Call VerifyPolicyObj
${emptyList} Create List
${return} ${policyType} Run Keyword And Ignore Error Get From Dictionary ${verifyObj} policyType
${return} ${policyType} Run Keyword And Ignore Error Set Variable ${verifyObj['policyType']}
#Should Not Be Empty ${policyType}
${verifySession} Get From Dictionary ${verifyObj} verifySession
Should Not Be Empty ${verifySession}
@@ -398,10 +398,10 @@ VerifyPolicyObj
Should Not Be Empty ${attributes}
FOR ${attribute} IN @{attributes}
${attributeType} Get From Dictionary ${attribute} attributeType
${return} ${tableName} Run Keyword And Ignore Error Get From Dictionary ${attribute} tableName
${return} ${protocol} Run Keyword And Ignore Error Get From Dictionary ${attribute} protocol
${attributeName} Get From Dictionary ${attribute} attributeName
${attributeValue} Get From Dictionary ${attribute} attributeValue
${return} ${tableName} Run Keyword And Ignore Error Set Variable ${attribute['tableName']}
${return} ${protocol} Run Keyword And Ignore Error Set Variable ${attribute['protocol']}
${attributeName} Get From Dictionary ${attribute} attributeName
${attributeValue} Get From Dictionary ${attribute} attributeValue
#将json转换为dict
${attributeValue} Convert To String ${attributeValue}
${start} Get Regexp Matches ${attributeValue} ^{\"
@@ -427,34 +427,32 @@ ManageIpAttributeValue
[Arguments] ${attributeValue} ${attributeName} ${type}
Run Keyword And Return If "${type}"=="str" ExtractIpAttributeValue ${attributeValue}
${dict} Create Dictionary
${return} ${clientIp} Run Keyword And Ignore Error Get From Dictionary ${attributeValue} clientIp
Run Keyword If "${clientIp}"=="${EMPTY}" and "${attributeName}"=="src_ip" Should Not Be Empty ${clientIp}
Set To Dictionary ${dict} clientIp=${clientIp}
${return} ${clientPort} Run Keyword And Ignore Error Get From Dictionary ${attributeValue} clientPort
Run Keyword If "${clientPort}"=="${EMPTY}" and "${attributeName}"=="src_ip" Should Not Be Empty ${clientPort}
Set To Dictionary ${dict} clientPort=${clientPort}
${return} ${serverIp} Run Keyword And Ignore Error Get From Dictionary ${attributeValue} serverIp
Run Keyword If "${serverIp}"=="${EMPTY}" and "${attributeName}"=="dest_ip" Should Not Be Empty ${serverIp}
Set To Dictionary ${dict} serverIp=${serverIp}
${return} ${serverPort} Run Keyword And Ignore Error Get From Dictionary ${attributeValue} serverPort
Run Keyword If "${serverPort}"=="${EMPTY}" and "${attributeName}"=="dest_ip" Should Not Be Empty ${serverPort}
Set To Dictionary ${dict} serverPort=${serverPort}
${return} ${addrType} Run Keyword And Ignore Error Get From Dictionary ${attributeValue} addrType
Should Be Equal As Strings ${return} PASS
${return} ${ip} Run Keyword And Ignore Error Set Variable ${attributeValue['ip']}
Run Keyword If "${ip}"=="${EMPTY}" and "${attributeName}"=="source" Should Not Be Empty ${ip}
Run Keyword If "${ip}"=="${EMPTY}" and "${attributeName}"=="destination" Should Not Be Empty ${ip}
Set To Dictionary ${dict} ip=${ip}
${return} ${port} Run Keyword And Ignore Error Set Variable ${attributeValue['port']}
Run Keyword If "${port}"=="${EMPTY}" and "${attributeName}"=="source" Should Not Be Empty ${port}
Run Keyword If "${port}"=="${EMPTY}" and "${attributeName}"=="destination" Should Not Be Empty ${port}
Set To Dictionary ${dict} port=${port}
${return} ${addrType} Run Keyword And Ignore Error Set Variable ${attributeValue['addrType']}
Run Keyword If "${port}"=="${EMPTY}" and "${attributeName}"=="source" Should Not Be Empty ${addrType}
Run Keyword If "${port}"=="${EMPTY}" and "${attributeName}"=="destination" Should Not Be Empty ${addrType}
Set To Dictionary ${dict} addrType=${addrType}
${return} ${protocol} Run Keyword And Ignore Error Get From Dictionary ${attributeValue} protocol
Should Be Equal As Strings ${return} PASS
${return} ${protocol} Run Keyword And Ignore Error Set Variable ${attributeValue['protocol']}
Run Keyword If "${port}"=="${EMPTY}" and "${attributeName}"=="source" Should Not Be Empty ${protocol}
Run Keyword If "${port}"=="${EMPTY}" and "${attributeName}"=="destination" Should Not Be Empty ${protocol}
Set To Dictionary ${dict} protocol=${protocol}
[Return] ${dict}
ExtractIpAttributeValue
[Arguments] ${attributeValue}
${list} Split String ${attributeValue} |
${len} Get Length ${list}
Should Be Equal As Integers ${len} 6
${addrType} Evaluate int(${list}[4])
${protocol} Evaluate int(${list}[5])
${dict} Create Dictionary clientIp=${list}[0] clientPort=${list}[1] serverIp=${list}[2]
... serverPort=${list}[3] addrType=${addrType} protocol=${protocol}
Should Be Equal As Integers ${len} 4
${addrType} Evaluate int(${list}[2])
${protocol} Evaluate int(${list}[3])
${dict} Create Dictionary ip=${list}[0] port=${list}[1]
... addrType=${addrType} protocol=${protocol}
[Return] ${dict}
ManageSignatureAttributeValue
[Arguments] ${attributeValue} ${type}