Commit 6e0b252f by taoke

调试企业云登录

parent 96e6d581
......@@ -113,7 +113,7 @@ class BmyConfig(BaseConfig):
# 测试环境host
test_host = "http://testyun.banmago.com/api"
# 登录账号
test_name_password = {"username": "15151500000", "password": "bmy123456"}
test_name_password = {"username": "15151500000", "password": "bmy123456", "Register-Origin": "yun"}
# 企业云接口的Authorization
bmy_token = ''
headers = {"Content-Type":"application/json"}
......
......@@ -27,7 +27,7 @@ if __name__ == "__main__":
pytest.main(['-v', '-s', test_case_dir, '--alluredir', './report/tmp'])
# 打开报告
os.system('allure serve ./report/tmp')
# 发送钉钉
send_dingding(args.product)
......
......@@ -64,7 +64,7 @@ class BMY():
"""企业云登录"""
# token加密
authorization = BMY().get_authorization()
header = {"Authorization": authorization}
header = {"Authorization": authorization,"Register-Origin":indata['Register-Origin']}
payload = {"username": "","password": "", "imageId": "", "grant_type": "passwordImageCode", "imageCode": ""}
# 账号
payload['username'] = indata['username']
......@@ -113,8 +113,8 @@ class BMC():
if __name__ == '__main__':
# indata= {"username":"15150000000","password":"A123456"}
# token= BMY().bmy_login(indata,getToken=False)
# print(token)
LIST1=BMY().get_imageCode( '15150000000', '8e4b595babec901009ff84f269ee5147')
print(LIST1)
indata= {"username":"15150000000","password":"A123456","Register-Origin":"yun"}
token= BMY().bmy_login(indata,getToken=False)
print(token)
# LIST1=BMY().get_imageCode( '15150000000', '8e4b595babec901009ff84f269ee5147')
# print(LIST1)
......@@ -8,6 +8,7 @@ from common.utils.getExcelData import get_excelData
from service.login import BMY
from common.tools import request_main
from config import BmyConfig
from service.login import BMY
@allure.epic("登录模块")
......@@ -20,39 +21,12 @@ class TestLogin():
@allure.testcase("http://yapi.hikcreate.com/")
@allure.description("url:/auth/login 。。。。")
@pytest.mark.parametrize("inData", get_excelData(workBook,'登录模块', 'Login'))
def test_login(self,inData):
url = f"{BmyConfig().test_host}{inData['url']}"
method = inData['method']
req_data = inData['reqData']
expectData= inData['expectData']
headers = inData['headers']
"""处理"""
req_data['grant_type'] = "passwordImageCode" # 请求体中的固定值
authorization = BMY().get_authorization() # 获取当前时间戳的Authorization
headers["Authorization"] = authorization
password_Encrypted = BMY().pwd_encrypted(req_data['password']) # 密码加密
req_data['password'] = password_Encrypted
imageinfo = BMY().get_imageCode(req_data['username'], req_data['password']) # 获取图片信息
req_data['imageId'] = imageinfo[0]
req_data['imageCode'] = imageinfo[1]
# """请求"""
# res = request_main(url, headers, method, req_data)
# # print(res)
# """断言"""
# assert res['code'] == expectData['code']
""" 请求和断言若不使用通用方法"""
res = requests.post(f"http://testyun.banmago.com/api{url}", data=req_data, headers=headers)
print("我是headers",headers)
print("我是data",req_data)
print(res.json())
assert res.json()['code'] == expectData['code']
def test_login(self, inData):
res = BMY().bmy_login(inData['reqData'], getToken=False)
# print(res)
assert res['code'] == inData['expectData']['code']
def teardown_class(self):
"""清除"""
if __name__ == '__main__':
for one in os.listdir('../../report/tmp'): # 列出对应文件夹的数据
......
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