2020-04-17 19:33:15 +08:00
|
|
|
*** Settings ***
|
|
|
|
|
Library OperatingSystem
|
|
|
|
|
Library Selenium2Library
|
|
|
|
|
Library RequestsLibrary
|
|
|
|
|
Library Collections
|
|
|
|
|
Library json
|
|
|
|
|
Resource ../tsg_bfapi/Common.robot
|
|
|
|
|
Resource ../../03-Variable/BifangApiVariable.txt
|
|
|
|
|
|
|
|
|
|
*** Keywords ***
|
|
|
|
|
PolicyVertify
|
|
|
|
|
[Arguments] ${dict}
|
|
|
|
|
Should Not Be Empty ${dict}[policyType]
|
|
|
|
|
Should Not Be Empty ${dict}[appId]
|
|
|
|
|
Should Not Be Empty ${dict}[cfg]
|
|
|
|
|
|
|
|
|
|
# APP ID
|
|
|
|
|
${appId} Evaluate '${dict}[appId]'.lower()
|
|
|
|
|
${attrVDict1} Create Dictionary string=${appId}.
|
|
|
|
|
${attrDict1} Create Dictionary attributeType=string attributeName=app_id attributeValue=${attrVDict1}
|
|
|
|
|
|
|
|
|
|
# IP/Str
|
|
|
|
|
${attributes} Create List ${attrDict1}
|
|
|
|
|
${unCfg} Set Variable ${dict}[cfg]
|
|
|
|
|
${cfgList} Evaluate re.split('[|]', '${unCfg}') re
|
|
|
|
|
|
|
|
|
|
# 区分 IP/String/Signature
|
|
|
|
|
${type} Evaluate '${cfgList}[0]'.lower()
|
|
|
|
|
Run Keyword If '${type}' == 'ip' ManageIpCfg ${cfgList} ${attributes}
|
|
|
|
|
... ELSE IF '${type}' == 'str' ManageStrCfg ${cfgList} ${attributes} ${appId}
|
|
|
|
|
... ELSE ManageSignatureCfg ${cfgList} ${attributes} ${appId}
|
|
|
|
|
|
|
|
|
|
${vsDict} Create Dictionary attributes=${attributes}
|
|
|
|
|
${verify1} Create Dictionary policyType=${dict}[policyType] verifySession=${vsDict}
|
|
|
|
|
${verifyList} Create List ${verify1}
|
|
|
|
|
${resultObj} Create Dictionary verifyList=${verifyList}
|
|
|
|
|
|
|
|
|
|
${json} json.Dumps ${resultObj} ensure_ascii=False
|
2020-04-28 17:03:28 +08:00
|
|
|
${response} BasePostRequest /policy/verify body=${json}
|
2020-04-17 19:33:15 +08:00
|
|
|
Log REQ = ${json}
|
|
|
|
|
Log RES = ${response}
|
|
|
|
|
Should Be True ${response['code']} == 200
|
|
|
|
|
Should Not Be Empty ${response['data']['hitPolicyList']}
|
|
|
|
|
Should Not Be Empty ${response['data']['verifySession']}
|
|
|
|
|
|
|
|
|
|
ManageIpCfg
|
|
|
|
|
[Arguments] ${cfgList} ${attributes}
|
|
|
|
|
# IP CFG
|
|
|
|
|
${addrType} Evaluate int('${cfgList}[1]'[1:])
|
|
|
|
|
${protocolDict} Create Dictionary Any=0 TCP=6 UDP=17
|
|
|
|
|
${protocolkey} Set Variable ${cfgList}[6]
|
|
|
|
|
${protocol} Evaluate int(${protocolDict}[${protocolkey}])
|
|
|
|
|
${attrValueDict} Create Dictionary addrType=${addrType} clientIp=${cfgList}[2] clientPort=${cfgList}[3] serverIp=${cfgList}[4] serverPort=${cfgList}[5] protocol=${protocol}
|
|
|
|
|
${attrDict} Create Dictionary attributeType=ip attributeName=ip attributeValue=${attrValueDict}
|
|
|
|
|
Append To List ${attributes} ${attrDict}
|
|
|
|
|
|
|
|
|
|
ManageStrCfg
|
|
|
|
|
[Arguments] ${cfgList} ${attributes} ${appId}
|
|
|
|
|
# Subscriber ID
|
|
|
|
|
${attrValueDict} Create Dictionary string=${cfgList}[1]
|
|
|
|
|
${attrDict} Create Dictionary attributeType=string attributeName=subscriberid attributeValue=${attrValueDict}
|
|
|
|
|
Append To List ${attributes} ${attrDict}
|
|
|
|
|
|
|
|
|
|
# APP CFG
|
|
|
|
|
${list} Evaluate re.split('[&]', '${cfgList}[2]') re
|
|
|
|
|
FOR ${var} IN @{list}
|
|
|
|
|
${i} Evaluate '${var}'.find('=')
|
|
|
|
|
${name} Evaluate '${var}'[:${i}]
|
|
|
|
|
${value} Evaluate '${var}'[${i}+1:]
|
|
|
|
|
${attributeValue} Create Dictionary string=${value}
|
|
|
|
|
${obj} Create Dictionary attributeType=string attributeName=${name} protocol=${appId} attributeValue=${attributeValue}
|
|
|
|
|
Append To List ${attributes} ${obj}
|
|
|
|
|
END
|
|
|
|
|
|
|
|
|
|
ManageSignatureCfg
|
|
|
|
|
[Documentation]
|
|
|
|
|
... cfg=dstr|$jwctest|account=User-Agent#anony*&url=added&content=added
|
|
|
|
|
[Arguments] ${cfgList} ${attributes} ${appId}
|
|
|
|
|
# Subscriber ID
|
|
|
|
|
${attrValueDict} Create Dictionary string=${cfgList}[1]
|
|
|
|
|
${attrDict} Create Dictionary attributeType=string attributeName=subscriberid attributeValue=${attrValueDict}
|
|
|
|
|
Append To List ${attributes} ${attrDict}
|
|
|
|
|
|
|
|
|
|
# APP CFG
|
|
|
|
|
${list} Evaluate re.split('[&]', '${cfgList}[2]') re
|
|
|
|
|
FOR ${var} IN @{list}
|
|
|
|
|
${i} Evaluate '${var}'.find('=')
|
|
|
|
|
${name} Evaluate '${var}'[:${i}]
|
|
|
|
|
${value} Evaluate '${var}'[${i}+1:]
|
|
|
|
|
${y} Evaluate '${value}'.find('#')
|
|
|
|
|
${district} Evaluate '${value}'[:${y}]
|
|
|
|
|
${string} Evaluate '${value}'[${y}+1:]
|
|
|
|
|
${attributeValue} Create Dictionary string=${string} district=${district}
|
|
|
|
|
${obj} Create Dictionary attributeType=signature attributeName=${name} protocol=${appId} attributeValue=${attributeValue}
|
|
|
|
|
Append To List ${attributes} ${obj}
|
|
|
|
|
END
|
|
|
|
|
|
|
|
|
|
|