Commit 07b75db5 by jiaqiying

fix confict

parents fca68c7a b27b9a47
...@@ -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的配置类"""
...@@ -53,6 +45,7 @@ class BMCConfig(BaseConfig): ...@@ -53,6 +45,7 @@ class BMCConfig(BaseConfig):
'Token': bmc_token, 'Token': bmc_token,
'Version': "2.2.5", 'Version': "2.2.5",
} }
#注册和注销专用账号
class BmyConfig(BaseConfig): class BmyConfig(BaseConfig):
...@@ -72,3 +65,10 @@ class BmyConfig(BaseConfig): ...@@ -72,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 = ''
...@@ -7,6 +7,7 @@ from common.utils.encryption import Encryption ...@@ -7,6 +7,7 @@ from common.utils.encryption import Encryption
from common.tools import request_main from common.tools import request_main
from common.db import RedisString from common.db import RedisString
from config import BmyConfig from config import BmyConfig
from config import BMCConfig
class SSOLogin(): class SSOLogin():
...@@ -85,8 +86,8 @@ class BMY(): ...@@ -85,8 +86,8 @@ class BMY():
else: else:
return resp.json() return resp.json()
class BMC():
def get_token(self, indata): def bmc_login(self, indata):
"""斑马信用登录获取token""" """斑马信用登录获取token"""
url = "http://testbmcapp.hikcreate.com/v1/user/login/gesture" url = "http://testbmcapp.hikcreate.com/v1/user/login/gesture"
header = {"Content-Type": "application/json; charset=utf-8", header = {"Content-Type": "application/json; charset=utf-8",
......
__author__ = 'dengmaosheng' __author__ = 'dengmaosheng'
__data__ = "2021-05-08 10:26" __data__ = "2021-05-08 10:26"
import pytest import pytest
from service.login import BMC
import config import config
from config import BMCConfig from config import BMCConfig
from common.utils.encryption import Encryption from common.utils.encryption import Encryption
import requests import requests
@pytest.fixture(scope='module', autouse=True) @pytest.fixture(scope='module', autouse=True)
def bmc_login(indata): def bmc_login_fixture():
"""bmc登录获取token""" """bmc登录获取token"""
url = config.BMCConfig.host+"/v1/user/login/gesture"
header = {"Content-Type": "application/json; charset=utf-8", indata = {"phone":"17822000000",
"device-type": "Android", "encodedGesture": "67e6d10010533eed4bbe9659863bf6ee"}
"device-name": "vivo+X20", res = BMC.bmc_login(indata)
"device-model": "vivo vivo X20", setattr(BMCConfig, 'bmc_token', res[0])
"city-code": "520100", setattr(BMCConfig, 'bmc_token', res[1])
"Version": "2.2.0",
"Device-Code": "000000001e167ed7000000001e167ed7"}
res = requests.post(url, json=indata, headers=header)
print(res.json())
encrypted_token = Encryption().aes_token(res.json()["data"]["token"])
print(encrypted_token)
# 获取专网token
header1 = header.copy()
header1["Token"] = encrypted_token
url = config.BMCConfig.host+"/token"
resp = requests.get(url=url, headers=header1)
print(resp.json())
pvt_token = resp.json()["data"]["token"]
print(pvt_token)
setattr(BMCConfig, 'bmc_token', encrypted_token)
setattr(BMCConfig, 'bmc_pvt_token', pvt_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