Commit 818bd494 authored by liguangyu06's avatar liguangyu06
Browse files

用例新增:登录接口新增雅培配置字段验证

parent 5597f470
# -* coding: utf-8 -*- # -*- encoding=utf8 -*-
# @Time: 2024/1/31 5:00 PM __author__ = "liguangyu"
# @File: 登录接口新增雅培配置字段验证.py
"""
case_tag:cmdc_api,cmdc登录接口新增雅培配置字段验证,32,32-1,sit,be
主数据平台:后台运营系统登录接口
"""
from common.common_func import commonFuc
import requests
import uuid
from common.verification_code_ocr import VerificationCodeOcr
import json
import os
import hashlib
module = "cmdc_32st"
username = commonFuc().get_business_data(module, "username1_be")
password = commonFuc().get_business_data(module, "password1_be")
# 获取唯一识别码
uuid_handle = uuid.uuid4()
# 获取验证码报文
param = {"uuid": uuid_handle}
# 获取登录页面获取验证码地址
code_url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "getVerifyCode_url")
# 发送请求获取验证码
result = requests.get(code_url, params=param)
# print(result.content)
# 获取当前文件路径
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
code_path = BASE_DIR + "/verifycode.png"
# 获取到验证码存入本地文件
with open(code_path, 'wb') as f:
f.write(result.content)
# 识别并获取验证码
code = VerificationCodeOcr(code_path, "rainbow123","rainbow123").base64_api()
# 获取登录地址
cmdc_url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "do_login_url")
md = hashlib.md5(password.encode()) # 创建md5对象
EncryptPassword = md.hexdigest() # 登录密码进行md5加密
print('加密后的密码', EncryptPassword) # 加密后的密码
# 组装请求报文
request_body = {"userName": username, "password": EncryptPassword, "validateCode": code, "uuid": uuid_handle}
# 发送请求
result = requests.post(cmdc_url, params=request_body)
result = json.loads(result.content)
"""
场景: 登录接口新增雅培配置字段验证
用例名称:登录接口新增雅培配置字段验证
输出:{"productCode":"%s"}
"""
# 新增雅培配置字段
check_list = ["exceedSign", "examineSign", "materialSign", "purchaseSign"]
# 断言实际结果中是否包含预期结果的内容
# commonFuc().check_result(cmdc_access_token, result)
commonFuc().check_variable_exist(check_list, result["data"])
# 多采商城图形验证码url
"getVerifyCode_url": "/sso/getVerifyCode"
# 多采商城登录地址
"maii_login_url": "/sso/mallLogin"
# 多采商城登录信息
"do_username": "BJ0621"
"do_password": "Aa123456"
# 国药运营后台管理系统登录地址
"do_login_url": "/sso/doLogin"
# 多采商城登录信息 # 多采商城登录信息
"username": "BJ0621" "username": "BJ0621"
"password": "Aa123456" "password": "Aa123456"
......
Supports Markdown
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