Commit 922e33c2 by fanxun

SSO登录修改

parent a93f0ea3
......@@ -3,14 +3,23 @@
class BaseConfig():
"""基础配置类"""
# 请求头
headers = {'Content-Type': 'application/json; charset=utf-8'}
headers = {'Content-Type': 'application/json'}
# 当前运行的产品名
name = "auto"
test_case_dir = "test_case/"
salt = 'hikcreate_xj' # SSO 登录的东西
secs=0.1 # 测试用例间隔运行时间
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):
"""斑马信用app的配置类"""
......@@ -18,7 +27,6 @@ class BMCConfig(BaseConfig):
name = "bmc"
test_case_dir = "test_case/bmc/"
test_case_data_dir = "test_case_data/bmc/"
webhook = ''
class BmyConfig(BaseConfig):
......@@ -31,3 +39,4 @@ class BmyConfig(BaseConfig):
# 测试环境
test_host = "http://testyun.banmago.com/api"
......@@ -10,14 +10,19 @@ from config import BmyConfig
@pytest.fixture(scope='session')
def sso_login(url, headers, method, data):
class SSOLogin():
"""SSO登录"""
req_data = {"loginName":"fanxun","password":"fx123456"}
password = req_data['password']
md5_password = Encryption().get_md5(password, salt=BaseConfig.salt)
req_data['password'] = md5_password
res = request_main(url, headers, method, req_data)
print(res)
def _sso_pwd_encrypted(self, org_pwd):
"""md5加密"""
encrypted_password = Encryption().get_md5(org_pwd, salt=BaseConfig.salt)
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)
return res['data']['token']
class BMY():
......@@ -108,14 +113,12 @@ class BMY():
if __name__ == '__main__':
# login = request_main(url=r'http://testtbdzj.hikcreate.com/web/auth/users/login',
# method='post',
# data={"loginName":"fanxun","password":"d67fac1d71943576b6c397d0cca166cb"},
# headers=getattr(BaseConfig, 'headers'))
# sso_login(r'http://testtbdzj.hikcreate.com/web/auth/users/login',
# headers=getattr(BaseConfig, 'headers'),
# method='post',
# data=None)
indata= {"username":"15150000000","password":"A123456"}
token= BMY().bmy_login(indata,getToken=False)
print(token)
# SSO登录测试
sso_token = SSOLogin().sso_login(url=BaseConfig.sso_url,
method='post',)
print(sso_token)
# indata= {"username":"15150000000","password":"A123456"}
# 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