使用封装的对象和策略关键字添加对象和策略;

This commit is contained in:
dongxiaoyan
2020-04-14 18:20:47 +08:00
parent e61d81aad5
commit 8aee95b648
9 changed files with 44 additions and 22 deletions

View File

@@ -1,10 +1,10 @@
*** Settings ***
Test Teardown DeleteAllAfterAdc ${policyIds} ${objectids}
Test Teardown DeletePolicyAndObject ${policyIds} ${objectids}
Force Tags tsg_adc tsg_security all_protol
Library OperatingSystem
Resource ../../../../02-Keyword/tsg_adc/SystemCommand.robot
Resource ../../../../02-Keyword/tsg_bfapi/PolicyObject.robot
Resource ../../../../02-Keyword/tsg_bfapi/LogVariable.robot
Resource ../../../02-Keyword/tsg_adc/SystemCommand.robot
Resource ../../../02-Keyword/tsg_bfapi/PolicyObject.robot
Resource ../../../02-Keyword/tsg_bfapi/LogVariable.robot
Library Custometest
Library json
@@ -28,9 +28,9 @@ SecurityPolicy-Deny-AllProtol-00001
${objectDict} Create Dictionary
... objectType=ip
... isValid=${1}
... addItemList=range|192.168.100.5|192.168.100.5|0/65535
... addItemList=CIDR|192.168.100.5|32|0/0
${rescode} ${objectId} AddObject2 ${1} ${objectDict}
${objectids} set Variable ${object_FQDN_Id}
${objectids} set Variable ${objectId}
Comment 创建安全策略针对所有协议相当于BlackIP
${policyDict} Create Dictionary
@@ -42,18 +42,18 @@ SecurityPolicy-Deny-AllProtol-00001
... effectiveRange=Nursurtan|Transtelecom&Astel,|Astel&Transtelecom
... userRegion=method:rst
... referenceObject=${objectId}|TSG_SECURITY_DESTINATION_ADDR
... isValid=${0}
... isValid=${1}
... appObjectIdArray=2,3,4,5,6
${rescode} ${policyId} AddPolicy2 ${1} ${policyDict}
${policyId1} set Variable {"policyType":"tsg_security","policyIds":[${policyId}]}
${policyId} set Variable {"policyType":"tsg_security","policyIds":[${policyId}]}
${s} Convert to String ${policyId}
Comment 功能端验证HTTP验证
${commandstr} run keyword if '${systemType}'=='Windows' set variable curl -kv http://open.node.com/ | iconv -f utf-8 -t gbk
${commandstr} run keyword if '${systemType}'=='Windows' set variable ${curlbatpath}/selfserver/SecurityPolicy-Deny-AllProtol-00001_HTTP.bat
... ELSE set variable curl -kv http://open.node.com/
${stringlist} run keyword if '${systemType}'=='Windows' Create List Recv failure: Connection was reset
... ELSE Create List Recv failure: Connection reset by peer
${stringlist} run keyword if '${systemType}'=='Windows' Create List Connection was reset
... ELSE Create List Connection reset by peer
${starttime} Get Time
Sleep ${policyVerificationSleepSeconds}s
@@ -64,11 +64,11 @@ SecurityPolicy-Deny-AllProtol-00001
GetLogList security_event_log ${starttime} ${endtime} ${testClentIP} ${s} http_host open.node.com
Comment 功能端验证SSL验证
${commandstr} run keyword if '${systemType}'=='Windows' set variable curl -kv https://open.node.com/ | iconv -f utf-8 -t gbk
${commandstr} run keyword if '${systemType}'=='Windows' set variable ${curlbatpath}/selfserver/SecurityPolicy-Deny-AllProtol-00001_SSL.bat
... ELSE set variable curl -kv https://open.node.com/
${stringlist} run keyword if '${systemType}'=='Windows' Create List Connection was reset
... #OpenSSL SSL_connect: Connection was reset in connection to
#OpenSSL SSL_connect: Connection was reset in connection to
#Send failure: Connection was reset
... ELSE Create List OpenSSL SSL_connect: Connection reset by peer in connection to

View File

@@ -6,7 +6,7 @@ Library OperatingSystem
Library Selenium2Library
Library Collections
Resource ../../../02-Keyword/tsg_bfapi/common.robot
Resource ../../../02-Keyword/tsg_bfapi/policy_file_interface/functionalKeywords.robot
Resource ../../../02-Keyword/tsg_bfapi/policy_file_interface/FunctionalKeywords.robot
Resource ../../../03-Variable/bifangapivariable.txt
*** Variables ***

View File

@@ -2,6 +2,7 @@
Resource ../../03-Variable/BifangApiVariable.txt
Resource ../tsg_common/ManagePolicyBody.robot
Resource ../tsg_common/ManageObjectBody.robot
Resource ../../02-Keyword/tsg_bfapi/policy_file_interface/FunctionalKeywords.robot
Library REST http://${host}:${port}
Library Collections
Library RequestsLibrary
@@ -11,14 +12,30 @@ Resource Common.robot
AddLocalIPObject
#创建对象IP
log to_AddLocalIPObject
${localIP} set variable {"opAction":"add","returnData":1,"objectList":{"objectType":"ip","objectSubType":"endpoint","isValid":1,"isInitialize":0,"isExclusion":0,"objectName":"autotestLocalIPObject_${testClentIP}","objectDesc":"LocalIPObject_${testClentIP}自动化测试机IP","subObjectIds":[],"addItemList":[{"addrType":4,"protocol":0,"direction":0,"isSession":"endpoint","clientIp1":"${testClentIP}","clientIp2":"${testClentIP}","clientIpFormat":"range","clientPortFormat":"range","clientPort1":0,"clientPort2":0,"serverIpFormat":"range","serverIp1":"","serverIp2":"","serverPortFormat":"range","serverPort1":0,"serverPort2":0}],"updateItemList":[],"deleteItemIds":[]}}
${rescodeip} ${objidip} AddObject ${localIP}
#${localIP} set variable {"opAction":"add","returnData":1,"objectList":{"objectType":"ip","objectSubType":"endpoint","isValid":1,"isInitialize":0,"isExclusion":0,"objectName":"autotestLocalIPObject_${testClentIP}","objectDesc":"LocalIPObject_${testClentIP}自动化测试机IP","subObjectIds":[],"addItemList":[{"addrType":4,"protocol":0,"direction":0,"isSession":"endpoint","clientIp1":"${testClentIP}","clientIp2":"${testClentIP}","clientIpFormat":"range","clientPortFormat":"range","clientPort1":0,"clientPort2":0,"serverIpFormat":"range","serverIp1":"","serverIp2":"","serverPortFormat":"range","serverPort1":0,"serverPort2":0}],"updateItemList":[],"deleteItemIds":[]}}
#${rescodeip} ${objidip} AddObject ${localIP}
#${localSubIP} set variable {"opAction":"add","returnData":1,"objectList":{"objectType":"subscriberid","objectSubType":"","isValid":1,"isInitialize":0,"isExclusion":0,"objectName":"test57","objectDesc":"${testSubscriberID}","subObjectIds":[],"addItemList":[{"keywordArray":["${testSubscriberID}"],"itemId":"","isHexbin":0}],"updateItemList":[],"deleteItemIds":[]}}
#${rescodesub} ${subiid} AddObject ${localSubIP}
# 创建对象-IP
Create Dictionary
${objectDict} Create Dictionary
... objectType=ip
... objectName=autotest_localIP_${testClentIP}
... isValid=${1}
... addItemList=range|${testClentIP}|${testClentIP}|0/0
${rescode} ${objectId} AddObject2 ${1} ${objectDict}
#log ${rescodeip}
log LocalIP${objidip}
SET GLOBAL VARIABLE ${testClentID} ${objidip}
log LocalIP${objectId}
SET GLOBAL VARIABLE ${testClentID} ${objectId}
log to_AddLocalSubidObject
${localSubIP} set variable {"opAction":"add","returnData":1,"objectList":{"objectType":"subscriberid","objectSubType":"","isValid":1,"isInitialize":0,"isExclusion":0,"objectName":"test57","objectDesc":"${testSubscriberID}","subObjectIds":[],"addItemList":[{"keywordArray":["${testSubscriberID}"],"itemId":"","isHexbin":0}],"updateItemList":[],"deleteItemIds":[]}}
${rescodesub} ${subiid} AddObject ${localSubIP}
${objectDict} Create Dictionary
... objectType=subscriberid
... objectName=autotest_localSubId_${testSubscriberID}
... isValid=${1}
... addItemList=${testSubscriberID}
${rescode} ${subiid} AddObject2 ${1} ${objectDict}
#log ${subiid}
log LocalSubIP${subiid}
SET GLOBAL VARIABLE ${testClentSubID} ${subiid}
@@ -139,3 +156,5 @@ DeletePolicyAndObject
#删除对象
log todeleteobj_DeletePolicyAndObject
DeleteObject ${objectids}

View File

@@ -199,7 +199,7 @@ ManageReferenceObject
ManageClientObject
# 增加引用测试终端IP策略对象
${emptyList} Create List
${emptyList} Create List TSG_SECURITY_SOURCE_ADDR
${obj} Create Dictionary objectId=${testClentID} protocolFields=${emptyList}
[Return] ${obj}

View File

@@ -1 +0,0 @@
curl -kv https://www.baidu.com | iconv -f utf-8 -t gbk

View File

@@ -0,0 +1 @@
curl -kv https://open.node.com/ | iconv -f utf-8 -t gbk

View File

@@ -0,0 +1 @@
curl -kv http://open.node.com/ | iconv -f utf-8 -t gbk

View File

@@ -0,0 +1 @@
curl -kv https://open.node.com/ | iconv -f utf-8 -t gbk

View File

@@ -2,6 +2,7 @@
docker images
2、进入docker镜像
docker run -it auto-rf-library:1.0 /bin/bash
docker run --name autotest.open.node.com --add-host=open.node.com:192.168.100.5 -it auto-rf-library:2.0
3、执行自动化项目
docker run -it -v /home/autoTest_tsg/:/usr/src/python -w /usr/src/python auto-rf-lib:latest[docker最新镜像] -d /newrepot/ robot tsg_autotest0406[project path]
执行添加hosts文件使用自建服务器作为网页访问