Commit 922e33c2 by fanxun

SSO登录修改

parent a93f0ea3
...@@ -3,14 +3,23 @@ ...@@ -3,14 +3,23 @@
class BaseConfig(): class BaseConfig():
"""基础配置类""" """基础配置类"""
# 请求头 # 请求头
headers = {'Content-Type': 'application/json; charset=utf-8'} headers = {'Content-Type': 'application/json'}
# 当前运行的产品名 # 当前运行的产品名
name = "auto" name = "auto"
test_case_dir = "test_case/" test_case_dir = "test_case/"
salt = 'hikcreate_xj' # SSO 登录的东西
secs=0.1 # 测试用例间隔运行时间 secs=0.1 # 测试用例间隔运行时间
test_redis = {"host": "10.197.236.197", "port": 6379, "password": "123456"} test_redis = {"host": "10.197.236.197", "port": 6379, "password": "123456"}
# 钉钉相关
webhook = ''
# SSO相关
username = 'fanxun' # SSO登录名
password = 'fx123456' # sso密码
sso_url = r'http://testtbdzj.hikcreate.com/web/auth/users/login' # sso登录地址
salt = 'hikcreate_xj' # SSO盐值
class BMCConfig(BaseConfig): class BMCConfig(BaseConfig):
"""斑马信用app的配置类""" """斑马信用app的配置类"""
...@@ -18,7 +27,6 @@ class BMCConfig(BaseConfig): ...@@ -18,7 +27,6 @@ class BMCConfig(BaseConfig):
name = "bmc" name = "bmc"
test_case_dir = "test_case/bmc/" test_case_dir = "test_case/bmc/"
test_case_data_dir = "test_case_data/bmc/" test_case_data_dir = "test_case_data/bmc/"
webhook = ''
class BmyConfig(BaseConfig): class BmyConfig(BaseConfig):
...@@ -31,3 +39,4 @@ class BmyConfig(BaseConfig): ...@@ -31,3 +39,4 @@ class BmyConfig(BaseConfig):
# 测试环境 # 测试环境
test_host = "http://testyun.banmago.com/api" test_host = "http://testyun.banmago.com/api"
...@@ -10,14 +10,19 @@ from config import BmyConfig ...@@ -10,14 +10,19 @@ from config import BmyConfig
@pytest.fixture(scope='session') @pytest.fixture(scope='session')
def sso_login(url, headers, method, data): class SSOLogin():
"""SSO登录""" """SSO登录"""
req_data = {"loginName":"fanxun","password":"fx123456"} def _sso_pwd_encrypted(self, org_pwd):
password = req_data['password'] """md5加密"""
md5_password = Encryption().get_md5(password, salt=BaseConfig.salt) encrypted_password = Encryption().get_md5(org_pwd, salt=BaseConfig.salt)
req_data['password'] = md5_password return encrypted_password
def sso_login(self,url, method, headers=None):
"""SSO登录获取token"""
encrypted_password = self._sso_pwd_encrypted(BaseConfig.password)
req_data = {f"loginName":BaseConfig.username,"password":encrypted_password}
res = request_main(url, headers, method, req_data) res = request_main(url, headers, method, req_data)
print(res) return res['data']['token']
class BMY(): class BMY():
...@@ -108,14 +113,12 @@ class BMY(): ...@@ -108,14 +113,12 @@ class BMY():
if __name__ == '__main__': if __name__ == '__main__':
# login = request_main(url=r'http://testtbdzj.hikcreate.com/web/auth/users/login', # SSO登录测试
# method='post', sso_token = SSOLogin().sso_login(url=BaseConfig.sso_url,
# data={"loginName":"fanxun","password":"d67fac1d71943576b6c397d0cca166cb"}, method='post',)
# headers=getattr(BaseConfig, 'headers')) print(sso_token)
# sso_login(r'http://testtbdzj.hikcreate.com/web/auth/users/login',
# headers=getattr(BaseConfig, 'headers'),
# method='post', # indata= {"username":"15150000000","password":"A123456"}
# data=None) # token= BMY().bmy_login(indata,getToken=False)
indata= {"username":"15150000000","password":"A123456"} # print(token)
token= BMY().bmy_login(indata,getToken=False)
print(token)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment