feat:(策略验证)1.策略验证提交;2:Wx开头的关键字修改;
3:修复删除策略一行关键字名写错
This commit is contained in:
@@ -31,7 +31,7 @@ Resource ../../tsg_common/ManagePolicyBody.robot
|
||||
# ... filterList= ${265}|${257}:TSG_FIELD_HTTP_HOST,${266}|${299}:TSG_FIELD_SSL_SNI&TSG_FIELD_SSL_SAN
|
||||
# ... filterList由多个数字用‘|’分隔,加上:对上对应的protocolFiled,
|
||||
# ... 一个filter中的protocolFiled是确定的,一个protocolFiled对应多个objectId
|
||||
WxPolicyListOperation
|
||||
PolicyListDataOperation
|
||||
[Documentation]
|
||||
... 描述:入口,opAction参数可为'add','update','disable','enable'
|
||||
... 参数:returnData: 必传,是否返回请求数据。可选${0}(不返回)/${1}(返回)。
|
||||
@@ -41,7 +41,7 @@ WxPolicyListOperation
|
||||
... 多个策略处理
|
||||
|
||||
[Arguments] ${returnData} ${policyList} ${opAction} ${policyObjectVersion}
|
||||
Log To Console Call WxPolicyListOperation
|
||||
Log To Console Call PolicyListDataOperation
|
||||
${policyListJson} Set Variable [
|
||||
FOR ${policy} IN @{policyList}
|
||||
${json} WxPolicyOrganize ${policy} ${opAction} ${policyObjectVersion}
|
||||
@@ -55,7 +55,7 @@ WxPolicyListOperation
|
||||
Log Policy_Request_Body-${json}
|
||||
[Return] ${json}
|
||||
|
||||
WxPolicyOperation
|
||||
PolicyDataOperation
|
||||
[Documentation]
|
||||
... 描述:入口,opAction参数可为'add','update','disable','enable'
|
||||
... 参数:returnData: 必传,是否返回请求数据。可选${0}(不返回)/${1}(返回)。
|
||||
@@ -65,7 +65,7 @@ WxPolicyOperation
|
||||
... 单个策略处理
|
||||
|
||||
[Arguments] ${returnData} ${policy} ${opAction} ${policyObjectVersion}
|
||||
Log To Console Call WxPolicyOperation
|
||||
Log To Console Call PolicyDataOperation
|
||||
${json} WxPolicyOrganize ${policy} ${opAction} ${policyObjectVersion}
|
||||
# 转为json结构并返回
|
||||
${dict} Create Dictionary opAction=${opAction} returnData=${returnData} policyList=replace:policyList
|
||||
@@ -333,7 +333,7 @@ ManageFilter
|
||||
${filterObject} Create Dictionary filter=${filterObjectList}
|
||||
[Return] ${filterObject}
|
||||
|
||||
WxGet-PolicyIds
|
||||
Get-PolicyIds
|
||||
[Documentation]
|
||||
... 获取结果中的策略ID
|
||||
[Arguments] ${value}
|
||||
@@ -348,4 +348,127 @@ WxGet-PolicyIds
|
||||
#Log To Console ${objectType}
|
||||
|
||||
END
|
||||
[Return] ${policyIds}
|
||||
[Return] ${policyIds}
|
||||
DeletePolicyWithParamDict
|
||||
[Documentation]
|
||||
... 删除策略
|
||||
... params,传入的删除字典
|
||||
... 结构为policyIds=${policyIds} (List) policyType=${policyType} (variable)
|
||||
[Arguments] ${params}
|
||||
${response} BaseDeleteRequest /${version}${policyUrl} ${params}
|
||||
${rescode} Set Variable ${response['code']}
|
||||
Should Be Equal As Strings ${rescode} 200
|
||||
[Return] ${rescode}
|
||||
VerifyPolicyList
|
||||
[Documentation]
|
||||
... 策略验证
|
||||
... 多个策略验证
|
||||
[Arguments] ${verifyList}
|
||||
Log To Console Call VerifyPolicyList
|
||||
${verifyListJson} Set Variable [
|
||||
FOR ${verifyObj} IN @{verifyList}
|
||||
${json} VerifyPolicyObj ${verifyObj}
|
||||
${verifyListJson} Set Variable ${verifyListJson}${json},
|
||||
END
|
||||
${verifyListJson}= Replace String Using Regexp ${verifyListJson} ,$ ]
|
||||
Log Policy_Request_Body-${verifyListJson}
|
||||
[Return] ${verifyListJson}
|
||||
VerifyPolicyObj
|
||||
[Documentation]
|
||||
... 策略验证
|
||||
... 单个策略验证
|
||||
[Arguments] ${verifyObj}
|
||||
Log To Console Call VerifyPolicyObj
|
||||
${emptyList} Create List
|
||||
${return} ${policyType} Run Keyword And Ignore Error Get From Dictionary ${verifyObj} policyType
|
||||
#Should Not Be Empty ${policyType}
|
||||
${verifySession} Get From Dictionary ${verifyObj} verifySession
|
||||
Should Not Be Empty ${verifySession}
|
||||
${attributes} Get From Dictionary ${verifySession} attributes
|
||||
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
|
||||
#将json转换为dict
|
||||
${attributeValue} Convert To String ${attributeValue}
|
||||
${start} Get Regexp Matches ${attributeValue} ^{\"
|
||||
${start1} Get Regexp Matches ${attributeValue} ^{\'
|
||||
${len} Get Length ${start}
|
||||
${len1} Get Length ${start1}
|
||||
${attributeValue} Run Keyword If ${len}>0 Evaluate eval('${attributeValue}')
|
||||
... ELSE IF ${len1}>0 Evaluate eval("${attributeValue}")
|
||||
... ELSE Set Variable ${attributeValue}
|
||||
${type} Run Keyword If ${len}>0 or ${len1}>0 Set Variable dict
|
||||
... ELSE Set Variable str
|
||||
${attributeValue} Run Keyword If "${attributeType}"=="ip" ManageIpAttributeValue ${attributeValue} ${attributeName} ${type}
|
||||
... ELSE IF "${attributeType}"=="signature" ManageSignatureAttributeValue ${attributeValue} ${type}
|
||||
... ELSE ManageStringAttributeValue ${attributeValue} ${type}
|
||||
Set To Dictionary ${attribute} attributeValue=${attributeValue}
|
||||
END
|
||||
Set To Dictionary ${verifyObj} verifySession=${verifySession}
|
||||
# 转为json结构并返回
|
||||
${json} json.Dumps ${verifyObj} ensure_ascii=False
|
||||
Log VerifyPolicy-${json}
|
||||
[Return] ${json}
|
||||
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
|
||||
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
|
||||
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}
|
||||
[Return] ${dict}
|
||||
ManageSignatureAttributeValue
|
||||
[Arguments] ${attributeValue} ${type}
|
||||
Run Keyword And Return If "${type}"=="str" ExtractSignatureAttributeValue ${attributeValue}
|
||||
${dict} Create Dictionary
|
||||
${district} Get From Dictionary ${attributeValue} district
|
||||
Should Not Be Empty ${district}
|
||||
Set To Dictionary ${dict} district=${district}
|
||||
${string} Get From Dictionary ${attributeValue} string
|
||||
Should Not Be Empty ${string}
|
||||
Set To Dictionary ${dict} string=${string}
|
||||
[Return] ${dict}
|
||||
ExtractSignatureAttributeValue
|
||||
[Arguments] ${attributeValue}
|
||||
${list} Split String ${attributeValue} |
|
||||
${len} Get Length ${list}
|
||||
Should Be Equal As Integers ${len} 2
|
||||
${dict} Create Dictionary district=${list}[0] string=${list}[1]
|
||||
[Return] ${dict}
|
||||
ManageStringAttributeValue
|
||||
[Arguments] ${attributeValue} ${type}
|
||||
${dict} Create Dictionary
|
||||
Run Keyword And Return If "${type}"=="str" Create Dictionary string=${attributeValue}
|
||||
${string} Get From Dictionary ${attributeValue} string
|
||||
Should Not Be Empty ${string}
|
||||
Set To Dictionary ${dict} string=${string}
|
||||
[Return] ${dict}
|
||||
Reference in New Issue
Block a user