Commit b27b9a47 by fanxun

添加SSOConfig类

parent fc850bc5
...@@ -16,14 +16,6 @@ class BaseConfig(): ...@@ -16,14 +16,6 @@ class BaseConfig():
# 钉钉相关 # 钉钉相关
webhook = '' webhook = ''
# SSO相关
sso_username = 'robot_fanxun' # SSO登录名
sso_password = 'fx123456' # sso密码
sso_url = r'http://testtbdzj.hikcreate.com/web/auth/users/login' # sso登录地址
sso_salt = 'hikcreate_xj' # SSO盐值
sso_token = ''
class BMCConfig(BaseConfig): class BMCConfig(BaseConfig):
"""斑马信用app的配置类""" """斑马信用app的配置类"""
...@@ -73,3 +65,10 @@ class BmyConfig(BaseConfig): ...@@ -73,3 +65,10 @@ class BmyConfig(BaseConfig):
bmy_token = '' bmy_token = ''
class SSOConfig(BaseConfig):
"""SSO配置类"""
sso_username = 'robot_fanxun' # SSO登录名
sso_password = 'fx123456' # sso密码
sso_url = r'http://testtbdzj.hikcreate.com/web/auth/users/login' # sso登录地址
sso_salt = 'hikcreate_xj' # SSO盐值
sso_token = ''
__author__ = 'fanxun' __author__ = 'fanxun'
__data__ = "2021-05-08 10:26" __data__ = "2021-05-08 10:26"
import pytest import pytest
from config import BaseConfig from config import SSOConfig
from common.utils.encryption import Encryption from common.utils.encryption import Encryption
from common.tools import request_main from common.tools import request_main
@pytest.fixture(scope='module', autouse=True) @pytest.fixture(scope='module', autouse=True)
def sso_login(): def sso_login():
"""SSO登录获取token""" """SSO登录获取token"""
encrypted_password = Encryption().get_md5(BaseConfig.sso_password, salt=BaseConfig.sso_salt) encrypted_password = Encryption().get_md5(SSOConfig.sso_password, salt=SSOConfig.sso_salt)
req_data = {"loginName": BaseConfig.sso_username, "password": encrypted_password} req_data = {"loginName": SSOConfig.sso_username, "password": encrypted_password}
res = request_main(BaseConfig.sso_url, headers=None, method='post', data=req_data) res = request_main(SSOConfig.sso_url, headers=None, method='post', data=req_data)
setattr(BaseConfig, 'sso_token', res['data']['token']) setattr(SSOConfig, 'sso_token', res['data']['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