Commit fc850bc5 by dengmaosheng

提交代码

parent 6944ec4c
...@@ -53,6 +53,7 @@ class BMCConfig(BaseConfig): ...@@ -53,6 +53,7 @@ class BMCConfig(BaseConfig):
'Token': bmc_token, 'Token': bmc_token,
'Version': "2.2.5", 'Version': "2.2.5",
} }
#注册和注销专用账号
class BmyConfig(BaseConfig): class BmyConfig(BaseConfig):
......
...@@ -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)
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