2020-04-01 12:42:05 +08:00
|
|
|
|
*** Settings ***
|
|
|
|
|
|
Resource ../../03-Variable/BifangApiVariable.txt
|
2020-09-07 19:23:55 +08:00
|
|
|
|
Resource ../../03-Variable/ApplicationID.txt
|
2020-06-16 16:42:04 +08:00
|
|
|
|
Library REST http://${host}:${port}
|
2020-04-01 12:42:05 +08:00
|
|
|
|
Library Collections
|
|
|
|
|
|
Library SSHLibrary
|
|
|
|
|
|
Resource PolicyObject.robot
|
2020-05-29 20:17:44 +08:00
|
|
|
|
Resource ../tsg_ui/logout/Logout.robot
|
|
|
|
|
|
Resource ../tsg_ui/login/Login.robot
|
2020-09-01 15:24:15 +08:00
|
|
|
|
#Resource ../../02-Keyword/tsg_bfapi/PolicyObject.robot
|
|
|
|
|
|
Resource ../../02-Keyword/tsg_bfapi/policy_object/Policy.robot
|
2020-04-01 12:42:05 +08:00
|
|
|
|
Resource Tag.robot
|
|
|
|
|
|
|
|
|
|
|
|
*** Keywords ***
|
|
|
|
|
|
Login
|
2020-04-08 17:13:17 +08:00
|
|
|
|
[Tags] tsg_adc tsg_bf_api
|
2020-04-01 12:42:05 +08:00
|
|
|
|
#[Arguments] ${username} ${password} ${authmode} ${authCode} ${ldapId}
|
|
|
|
|
|
# 毕方接口用户名密码
|
2020-06-16 16:42:04 +08:00
|
|
|
|
GET /${version}/user/encryptpwd?password=${password}
|
2020-04-01 12:42:05 +08:00
|
|
|
|
Object response body
|
|
|
|
|
|
#OUTPUT response body
|
|
|
|
|
|
#${rescode} Integer $.code
|
|
|
|
|
|
Integer $.code 200
|
|
|
|
|
|
#log ${rescode}
|
|
|
|
|
|
${pwd} String $.data.encryptpwd
|
|
|
|
|
|
#log ${pwd}
|
|
|
|
|
|
${pwdstr} Get From List ${pwd} 0
|
|
|
|
|
|
#log aaaaaaa
|
|
|
|
|
|
log ${pwdstr}
|
|
|
|
|
|
#log bbb
|
|
|
|
|
|
SET GLOBAL VARIABLE ${encodePassword} ${pwdstr}
|
|
|
|
|
|
#log aaaaaaa
|
|
|
|
|
|
log ${encodePassword}
|
|
|
|
|
|
#log aaaaaaa
|
|
|
|
|
|
#log ${host}:${port}
|
|
|
|
|
|
#getToken##################################################################################
|
|
|
|
|
|
#log ${username}
|
|
|
|
|
|
#log ${pwdstr}
|
2020-06-16 16:42:04 +08:00
|
|
|
|
POST /${version}/user/login?username=${username}&password=${encodePassword}&authMode=${authmode}
|
2020-04-01 12:42:05 +08:00
|
|
|
|
Object response body
|
|
|
|
|
|
#OUTPUT response body
|
|
|
|
|
|
Integer $.code 200
|
|
|
|
|
|
#${rescodelist} Integer $.code
|
|
|
|
|
|
#${rescode} Get From List ${rescodelist} 0
|
|
|
|
|
|
${rescode} Integer $.code
|
|
|
|
|
|
log ${rescode}
|
|
|
|
|
|
${tokenGlobal} String $.data.token
|
|
|
|
|
|
${tokenStr} Get From List ${tokenGlobal} 0
|
|
|
|
|
|
log ${tokenStr}
|
|
|
|
|
|
SET GLOBAL VARIABLE ${token} ${tokenStr}
|
|
|
|
|
|
log ${token}
|
|
|
|
|
|
SET GLOBAL VARIABLE ${headers} {"Contest-Type":"application/json","Authorization":"${token}"}
|
|
|
|
|
|
#Return ${rescode}
|
|
|
|
|
|
Logout
|
2020-04-08 17:13:17 +08:00
|
|
|
|
[Tags] tsg_adc tsg_bf_api
|
2020-06-16 16:42:04 +08:00
|
|
|
|
POST /${version}/user/logout headers=${headers}
|
2020-04-01 12:42:05 +08:00
|
|
|
|
Object response body
|
|
|
|
|
|
Integer $.code 200
|
|
|
|
|
|
${rescode} Integer $.code
|
|
|
|
|
|
#[Return] ${rescode}
|
|
|
|
|
|
|
|
|
|
|
|
ApiLoginAndAddLocalIP
|
2020-04-08 17:13:17 +08:00
|
|
|
|
[Tags] tsg_adc tsg_bf_api
|
|
|
|
|
|
log ApiLoginAndAddLocalIP
|
2020-04-01 12:42:05 +08:00
|
|
|
|
loginlogout.Login
|
|
|
|
|
|
#log **********
|
|
|
|
|
|
Run Keyword If ${addTestClentIPFlag}==1 AddLocalIPObject
|
|
|
|
|
|
log ApiLoginAndAddLocalIP
|
|
|
|
|
|
#ApiAddAutoTagsCase
|
|
|
|
|
|
#[Return] ${rescode}
|
|
|
|
|
|
|
2020-09-01 15:24:15 +08:00
|
|
|
|
#添加tsgUIAPI
|
|
|
|
|
|
Run Keyword If ${addTsgUIAPIFlag}==1 SecurityPolicy-Allow-TSGUIAPI-Add
|
|
|
|
|
|
|
2020-04-01 12:42:05 +08:00
|
|
|
|
ApiLogoutAndDelLocalIP
|
2020-04-08 17:13:17 +08:00
|
|
|
|
[Tags] tsg_adc tsg_bf_api
|
|
|
|
|
|
log ApiLogoutAndDelLocalIP
|
2020-04-01 12:42:05 +08:00
|
|
|
|
log to_LogoutAndDelLocalIP_LogoutAndDelLocalIP
|
2020-09-01 16:39:09 +08:00
|
|
|
|
#删除tsgUIAPI 先删除白名单,是因为此策略也引用了本机IP
|
|
|
|
|
|
Run Keyword If ${addTsgUIAPIFlag}==1 SecurityPolicy-Allow-TSGUIAPI-DEL
|
|
|
|
|
|
|
2020-04-01 12:42:05 +08:00
|
|
|
|
Run Keyword If ${addTestClentIPFlag}==1 DelLocalIPObject
|
2020-09-01 16:39:09 +08:00
|
|
|
|
|
|
|
|
|
|
|
2020-04-01 12:42:05 +08:00
|
|
|
|
#ApiDeleteAutoTagsCase
|
|
|
|
|
|
loginlogout.Logout
|
|
|
|
|
|
#[Return] ${rescode}
|
|
|
|
|
|
|
|
|
|
|
|
CliLogin
|
2020-04-08 17:13:17 +08:00
|
|
|
|
[Tags] tsg_cli cli_login
|
2020-04-01 12:42:05 +08:00
|
|
|
|
Open Connection ${cliHost}
|
|
|
|
|
|
SSHLibrary.Login ${cliUsername} ${cliPassword}
|
|
|
|
|
|
|
2020-04-08 17:13:17 +08:00
|
|
|
|
CliLogout
|
|
|
|
|
|
[Tags] tsg_cli cli_logout
|
2020-04-01 12:42:05 +08:00
|
|
|
|
Close Connection
|
2020-04-13 19:29:32 +08:00
|
|
|
|
Log Close CLI Connection
|
2020-09-01 15:24:15 +08:00
|
|
|
|
|
|
|
|
|
|
SecurityPolicy-Allow-TSGUIAPI-Add
|
|
|
|
|
|
[Tags] uiallow
|
|
|
|
|
|
log toAddTSGUIAPI
|
|
|
|
|
|
${addItemList1} Create Dictionary isSession=endpoint ip=${host}/32 port=0-0 direction=0 protocol=0 isInitialize=0
|
|
|
|
|
|
#可以添加多个
|
|
|
|
|
|
${addItemLists} Create list ${addItemList1}
|
|
|
|
|
|
#objectList对象
|
2021-01-26 17:56:36 +08:00
|
|
|
|
${objectDict} Create Dictionary objectType=ip objectSubType=endpoint isValid=${1} addItemList=${addItemLists}
|
2020-09-01 15:24:15 +08:00
|
|
|
|
${rescode} ${objectId} AddObjects ${1} ${objectDict}
|
|
|
|
|
|
SET GLOBAL VARIABLE ${testBifangIP} ${objectId}
|
|
|
|
|
|
Comment 创建安全策略
|
2020-09-07 19:23:55 +08:00
|
|
|
|
${policyDict} Create Dictionary policyName=SecurityPolicy-Allow-TSGUIAPI policyType=tsg_security policyDesc=autotest action=allow destination=${objectId}|TSG_SECURITY_DESTINATION_ADDR userRegion={} isValid=${1} appIdObjects=${HTTP_ID},${SSL_ID}
|
2020-09-01 15:24:15 +08:00
|
|
|
|
log ${policyDict}
|
|
|
|
|
|
${rescode} ${policyId} AddPolicies 1 ${policyDict} v2
|
|
|
|
|
|
SET GLOBAL VARIABLE ${testBifangPolicy} ${policyId}
|
|
|
|
|
|
log addTSGUIAPISucess
|
|
|
|
|
|
SecurityPolicy-Allow-TSGUIAPI-DEL
|
|
|
|
|
|
[Tags] uiallow
|
|
|
|
|
|
log toDelTSGUIAPI
|
2021-01-26 17:56:36 +08:00
|
|
|
|
#${policyId1} set Variable {"policyType":"tsg_security","policyIds":[${testBifangPolicy}]}
|
|
|
|
|
|
#${policyIds} Create List ${testBifangPolicy}
|
|
|
|
|
|
DeletePolicyAndGroupObject ${testBifangPolicy} ${testBifangIP}
|
2020-09-01 15:24:15 +08:00
|
|
|
|
log delTSGUIAPISucess
|