数据驱动方式尝试
This commit is contained in:
89
02-Keyword/common/Test_ApiHttpRequest.robot
Normal file
89
02-Keyword/common/Test_ApiHttpRequest.robot
Normal file
@@ -0,0 +1,89 @@
|
||||
*** Settings ***
|
||||
Test Teardown DeletePolicyAndGroupObject ${policyIds} ${objectIds}
|
||||
Resource ../../03-Variable/BifangApiVariable.txt
|
||||
Resource ../../02-Keyword/tsg_bfapi/PolicyObject.robot
|
||||
|
||||
*** Variables ***
|
||||
${host} Set Variable http://${host}:${port}
|
||||
${api} Set Variable /v2/policy/compile
|
||||
${header} Create Dictionary Content-Type=application/json Authorization=${token}
|
||||
*** Test Cases ***
|
||||
Test-GetRequestBase
|
||||
${host} Set Variable http://${host}:${port}
|
||||
${api} Set Variable /v2/policy/compile
|
||||
${data} Set Variable pageSize=20&pageNo=1&policyType=tsg_security
|
||||
${header} Create Dictionary Content-Type=application/json Authorization=${token}
|
||||
${response} GetRequestBase ${host} ${api} ${header} ${data}
|
||||
${responsejson} to json ${response}
|
||||
${code} get from dictionary ${responsejson} code
|
||||
${msg} get from dictionary ${responsejson} msg
|
||||
${success} get from dictionary ${responsejson} success
|
||||
${data} get from dictionary ${responsejson} data
|
||||
${list} get from dictionary ${data} list
|
||||
${policyId} get from dictionary ${list}[0] policyId
|
||||
${length} Get Length ${list}
|
||||
#:FOR ${element} IN ${list}
|
||||
#\ log ${element}
|
||||
:FOR ${i} IN RANGE ${length}
|
||||
\ ${policyId} get from dictionary ${list}[${i}] policyId
|
||||
\ log ${policyId}
|
||||
log ${response}
|
||||
|
||||
Test-GetRequestResposeCode
|
||||
${host} Set Variable http://${host}:${port}
|
||||
${api} Set Variable /v2/policy/compile?pageSize=20&pageNo=1&policyType=tsg_security
|
||||
${header} Create Dictionary Content-Type=application/json Authorization=${token}
|
||||
${code} GetRequestResposeCode ${host} ${api} ${header} ${EMPTY}
|
||||
Should Be Equal As Strings ${code} 200
|
||||
log ${code}
|
||||
|
||||
Test-GetRequestResposeData
|
||||
${host} Set Variable http://${host}:${port}
|
||||
${api} Set Variable /v2/policy/compile?pageSize=20&pageNo=1&policyType=tsg_security
|
||||
${header} Create Dictionary Content-Type=application/json Authorization=${token}
|
||||
${code} GetRequestResposeData ${host} ${api} ${header} ${EMPTY} code
|
||||
Should Be Equal As Strings ${code} 200
|
||||
log ${code}
|
||||
|
||||
Test-PostRequestBase
|
||||
${host} Set Variable http://${host}:${port}
|
||||
${api} Set Variable /v2/policy/compile
|
||||
${body} Set Variable {"opAction":"add","returnData":1,"refuseCode":true,"policyList":{"policyId":"","policyName":"dxytest","policyType":"tsg_security","action":"intercept","userTags":"3","doBlacklist":0,"doLog":1,"policyDesc":"Intercept","effectiveRange":{"tag_sets":[[{"tag":"data_center","value":["Nur-sultan"],"ids":[2]}]]},"userRegion":{"protocol":"SSL","keyring":1,"decryption":1,"decrypt_mirror":{"enable":1,"mirror_profile":1}},"source":[{"objectId":197,"protocolField":"TSG_SECURITY_SOURCE_ADDR"}],"destination":[{"objectId":222,"protocolField":"TSG_SECURITY_DESTINATION_ADDR"}],"filterList":[],"appIdObjects":[44],"appSelectorObjects":[],"isValid":1,"scheduleId":[1]}}
|
||||
${header} Create Dictionary Content-Type=application/json Authorization=${token}
|
||||
${response} PostRequestBase ${host} ${api} ${header} ${body}
|
||||
${responsejson} to json ${response}
|
||||
${code} get from dictionary ${responsejson} code
|
||||
${msg} get from dictionary ${responsejson} msg
|
||||
${success} get from dictionary ${responsejson} success
|
||||
${datastr} get from dictionary ${responsejson} data
|
||||
${list} get from dictionary ${datastr} policyList
|
||||
${policyId} get from dictionary ${list}[0] policyId
|
||||
#${policyIds1} set Variable {"policyType":"tsg_security","policyIds":[${policyId}]}
|
||||
${policyIds} Create List {"policyType":"tsg_security","policyIds":[${policyId}]}
|
||||
${length} Get Length ${list}
|
||||
#:FOR ${element} IN ${list}
|
||||
#\ log ${element}
|
||||
:FOR ${i} IN RANGE ${length}
|
||||
\ ${policyId} get from dictionary ${list}[${i}] policyId
|
||||
\ log ${policyId}
|
||||
|
||||
#DeleteRequestBase /v1/policy/compile {"policyType":"tsg_security","policyIds":[${policyId}]}
|
||||
log ${response}
|
||||
|
||||
Test-PostRequestResposeCode
|
||||
${host} Set Variable http://${host}:${port}
|
||||
${api} Set Variable /v2/policy/compile
|
||||
${data} Set Variable {"opAction":"add","returnData":1,"refuseCode":true,"policyList":{"policyId":"","policyName":"dxytest","policyType":"tsg_security","action":"intercept","userTags":"3","doBlacklist":0,"doLog":1,"policyDesc":"Intercept","effectiveRange":{"tag_sets":[[{"tag":"data_center","value":["Nur-sultan"],"ids":[2]}]]},"userRegion":{"protocol":"SSL","keyring":1,"decryption":1,"decrypt_mirror":{"enable":1,"mirror_profile":1}},"source":[{"objectId":197,"protocolField":"TSG_SECURITY_SOURCE_ADDR"}],"destination":[{"objectId":222,"protocolField":"TSG_SECURITY_DESTINATION_ADDR"}],"filterList":[],"appIdObjects":[44],"appSelectorObjects":[],"isValid":1,"scheduleId":[1]}}
|
||||
${header} Create Dictionary Content-Type=application/json Authorization=${token}
|
||||
${code} PostRequestResposeCode ${host} ${api} ${header} ${data}
|
||||
Should Be Equal As Strings ${code} 200
|
||||
log ${code}
|
||||
|
||||
Test-PostRequestResposeData
|
||||
${host} Set Variable http://${host}:${port}
|
||||
${api} Set Variable /v2/policy/compile
|
||||
${data} Set Variable {"opAction":"add","returnData":1,"refuseCode":true,"policyList":{"policyId":"","policyName":"dxytest","policyType":"tsg_security","action":"intercept","userTags":"3","doBlacklist":0,"doLog":1,"policyDesc":"Intercept","effectiveRange":{"tag_sets":[[{"tag":"data_center","value":["Nur-sultan"],"ids":[2]}]]},"userRegion":{"protocol":"SSL","keyring":1,"decryption":1,"decrypt_mirror":{"enable":1,"mirror_profile":1}},"source":[{"objectId":197,"protocolField":"TSG_SECURITY_SOURCE_ADDR"}],"destination":[{"objectId":222,"protocolField":"TSG_SECURITY_DESTINATION_ADDR"}],"filterList":[],"appIdObjects":[44],"appSelectorObjects":[],"isValid":1,"scheduleId":[1]}}
|
||||
${header} Create Dictionary Content-Type=application/json Authorization=${token}
|
||||
${code} PostRequestResposeData ${host} ${api} ${header} ${data} code
|
||||
Should Be Equal As Strings ${code} 200
|
||||
log ${code}
|
||||
Reference in New Issue
Block a user