This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
dongxiaoyan-tsg-autotest/02-Keyword/tsg_bfapi/LoginLogout.robot
dongxiaoyan 21e0834607 1、IP类适配GEO类型;
2、appid变量内置初始化补全;
3、策略对象删除必填部分校验;
4、公共对象适配addobjects;
2021-01-26 17:56:36 +08:00

121 lines
4.7 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

*** Settings ***
Resource ../../03-Variable/BifangApiVariable.txt
Resource ../../03-Variable/ApplicationID.txt
Library REST http://${host}:${port}
Library Collections
Library SSHLibrary
Resource PolicyObject.robot
Resource ../tsg_ui/logout/Logout.robot
Resource ../tsg_ui/login/Login.robot
#Resource ../../02-Keyword/tsg_bfapi/PolicyObject.robot
Resource ../../02-Keyword/tsg_bfapi/policy_object/Policy.robot
Resource Tag.robot
*** Keywords ***
Login
[Tags] tsg_adc tsg_bf_api
#[Arguments] ${username} ${password} ${authmode} ${authCode} ${ldapId}
# 毕方接口用户名密码
GET /${version}/user/encryptpwd?password=${password}
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}
POST /${version}/user/login?username=${username}&password=${encodePassword}&authMode=${authmode}
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
[Tags] tsg_adc tsg_bf_api
POST /${version}/user/logout headers=${headers}
Object response body
Integer $.code 200
${rescode} Integer $.code
#[Return] ${rescode}
ApiLoginAndAddLocalIP
[Tags] tsg_adc tsg_bf_api
log ApiLoginAndAddLocalIP
loginlogout.Login
#log **********
Run Keyword If ${addTestClentIPFlag}==1 AddLocalIPObject
log ApiLoginAndAddLocalIP
#ApiAddAutoTagsCase
#[Return] ${rescode}
#添加tsgUIAPI
Run Keyword If ${addTsgUIAPIFlag}==1 SecurityPolicy-Allow-TSGUIAPI-Add
ApiLogoutAndDelLocalIP
[Tags] tsg_adc tsg_bf_api
log ApiLogoutAndDelLocalIP
log to_LogoutAndDelLocalIP_LogoutAndDelLocalIP
#删除tsgUIAPI 先删除白名单是因为此策略也引用了本机IP
Run Keyword If ${addTsgUIAPIFlag}==1 SecurityPolicy-Allow-TSGUIAPI-DEL
Run Keyword If ${addTestClentIPFlag}==1 DelLocalIPObject
#ApiDeleteAutoTagsCase
loginlogout.Logout
#[Return] ${rescode}
CliLogin
[Tags] tsg_cli cli_login
Open Connection ${cliHost}
SSHLibrary.Login ${cliUsername} ${cliPassword}
CliLogout
[Tags] tsg_cli cli_logout
Close Connection
Log Close CLI Connection
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对象
${objectDict} Create Dictionary objectType=ip objectSubType=endpoint isValid=${1} addItemList=${addItemLists}
${rescode} ${objectId} AddObjects ${1} ${objectDict}
SET GLOBAL VARIABLE ${testBifangIP} ${objectId}
Comment 创建安全策略
${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}
log ${policyDict}
${rescode} ${policyId} AddPolicies 1 ${policyDict} v2
SET GLOBAL VARIABLE ${testBifangPolicy} ${policyId}
log addTSGUIAPISucess
SecurityPolicy-Allow-TSGUIAPI-DEL
[Tags] uiallow
log toDelTSGUIAPI
#${policyId1} set Variable {"policyType":"tsg_security","policyIds":[${testBifangPolicy}]}
#${policyIds} Create List ${testBifangPolicy}
DeletePolicyAndGroupObject ${testBifangPolicy} ${testBifangIP}
log delTSGUIAPISucess