Exemplo n.º 1
0
def test_login_pass_error():
    login_url = server_ip('test') + yamldict['test_login_pass']["url"]
    # username, password_error = get_excel_value(3)
    #
    # params = {
    #     "email": username,
    #     "user_pwd": password_error,
    #     "ajax": 1,
    #     "auto_login": 1
    #
    # }

    login_result = RequestsHandler().post_Req(
        url=login_url, data=yamldict['test_login_pass']["paramsErrorPassword"])
    re_login_cookie = login_result.cookies
    content = login_result.text.encode('utf-8').decode('unicode_escape')
    content = json.loads(content)
    statusCode = content["status"]
    print(statusCode)
    try:
        assert statusCode == 0, "登录异常"
        logger.info("statusCode返回正确,密码错误无法登录逻辑正确------》 %s", statusCode)
        return re_login_cookie
    except Exception:
        logger.error("statusCode返回错误------》 %s", statusCode)
        raise
Exemplo n.º 2
0
def test_find12306_care():
    find_url = "https://kyfw.12306.cn/otn/leftTicket/queryT"
    headers = {
        'User-Agent': 'Mozilla / 5.0(WindowsNT10.0;Win64;x64) AppleWebKit / 537.36(KHTML, likeGecko) Chrome / 83.0.4103.97Safari / 537.36'
        ,
        'Cookie': '_uab_collina=161544183234765335496295; JSESSIONID=B90217EAC34540B11F0F2885DE3C6CA5; BIGipServerotn=133169674.38945.0000; RAIL_EXPIRATION=1615739643443; RAIL_DEVICEID=VjKjGkPV3U8fxI1yECgj-SFyiy9PP1P_NEVygkhOzV72ax0KqucIlXEQRxZb04RXMwpQK-pXGHFFF2pexNU6ZcjUMB_R6z9FVVUlAApl1nbD7sudatMGY1A_Dc_tvAO_v4wZZF-3XfRZPYhMFqN4OnJlXXoJQhkp; BIGipServerpool_passport=132383242.50215.0000; route=c5c62a339e7744272a54643b3be5bf64; _jc_save_fromStation=%u4E0A%u6D77%2CSHH; _jc_save_toStation=%u5317%u4EAC%2CBJP; _jc_save_fromDate=2021-03-11; _jc_save_toDate=2021-03-11; _jc_save_wfdc_flag=dc'
    }
    data = {
        "cxlx": 0,
        "cz": "上海",
        "cc": "G7259",
        "czEn": '-E4-B8-8A-E6-B5-B7',
        "randCode": ''
    }

    r = RequestsHandler().post_Req(url=find_url, data=data, headers=headers)
    # r = requests.get(url= find_url, data=data,headers=headers)
    # print('_' * 50)
    # print(r.content.decode())
    # print(r)
    # print(r.text.encode('utf-8').decode('unicode_escape'))
    statusCode = r.status_code
    # c = r.status_code
    # print(c)
    # return statusCode
    print(statusCode)

    try:
        assert statusCode == 200, "返回状态码错误,接口请求失败"

        logger.info("statusCode返回正确-----> %s", statusCode)
    except Exception:
        logger.error("statusCode返回错误-----》 %s", statusCode)
        raise
Exemplo n.º 3
0
def test_rl_add():
    def_name = sys._getframe().f_code.co_name
    test_Assert = Assert.Assertions(def_name)
    logger.info("开始执行脚本%s:\n", def_name)
    # url = 'http://testcalapi.hellogeek.com/feedBack/add'
    url = server_ip('realse') + yamldict['test_rl_add']['url']
    r = RequestsHandler().post_Req(url=url, json=yamldict['test_rl_add']['json'],
                                   headers=yamldict['test_rl_add']['headers'])
    sting_response = r.content.decode()
    # json_response = dict_style(sting_response)
    # assert json_response['code'] == 0
    # try:
    #     assert json_response['code'] == 0
    #     logger.info("code状态码返回正确:%s ----> PASS", json_response['code'])
    # except Exception:
    #     logger.info("code状态码返回错误:%s ----> FAIL", json_response['code'])
    #
    # assert json_response['msg'] == '执行成功'
    # try:
    #     assert json_response['msg'] == '执行成功'
    #     logger.info("msg信息返回正确:%s ----> PASS", json_response['msg'])
    # except Exception:
    #     logger.info("msg信息返回错误:%s ----> FAIL", json_response['msg'])

    json_response = dict_style(sting_response)
    # json_response = json.loads(sting_response)
    test_Assert.assert_code(json_response['code'], 0)
    test_Assert.assert_body(json_response, 'msg', '执行成功')
    Consts.RESULT_LIST.append('pass')
Exemplo n.º 4
0
def test_rl_common():
    def_name = sys._getframe().f_code.co_name
    test_Assert = Assert.Assertions(def_name)
    logger.info("开始执行脚本%s:\n", def_name)
    url = server_ip('realse') + yamldict['test_rl_common']['url']
    r = RequestsHandler().get_Req(
        url=url, params='', headers=yamldict['test_rl_common']['headers'])
    sting_response = r.content.decode()
    json_response = dict_style(sting_response)

    test_Assert.assert_code(json_response['code'], 0)
    test_Assert.assert_body(json_response, 'msg', '执行成功')
    Consts.RESULT_LIST.append('pass')
def test_operation_list():
    def_name = sys._getframe().f_code.co_name
    test_Assert = Assert.Assertions(def_name)
    logger.info("开始执行脚本%s:\n", def_name)
    opera_url = server_ip('realse') + yamldict['test_operation_list']['url']
    opera_result = RequestsHandler().get_Req(
        url=opera_url,
        params=yamldict['test_operation_list']["params"],
        headers=yamldict['test_operation_list']["headers"])
    sting_response = opera_result.content.decode()
    json_response = dict_style(sting_response)
    test_Assert.assert_code(json_response['code'], 0)
    test_Assert.assert_body(json_response, 'msg', '执行成功')
    Consts.RESULT_LIST.append('pass')
Exemplo n.º 6
0
def gettoken():
    # flag = 1 :财政是否同意  flag = 0 :查看绑定状态
    flag = 1
    appid = "zcd"
    timeNow = str(time.strftime('%Y%m%d%H%M%S', time.localtime(time.time())))
    checkCode = "zcd" + timeNow + "87288aae-49e5-42e5-be97-609ae7fc35ba"
    md5Pas = hashlib.md5(checkCode.encode())
    url = "http://124.70.221.250:8080/gpl/webservice/security/getToken?appid=" + appid + "&timestamp=" + timeNow + "&checkcode=" + md5Pas.hexdigest(
    )
    opera_result = RequestsHandler().post_Req(url=url, params='')
    sting_response = opera_result.content.decode()
    json_response = dict_style(sting_response)
    token = json_response.get("token")
    if token is None:
        print('ERROR,Token没拿到')
    headers = {'X-PM-API-TOKENID': token}
    if flag == 1:
        url1 = 'http://124.70.221.250:8080/gpl/webservice/procurement/updatePurchaserOpinion'
        r0 = RequestsHandler().post_Req(url=url1,
                                        params={
                                            "id": "40039522980651008",
                                            "auditOpinion": "NO",
                                            "auditRemark": "不同意",
                                            "lockId": "40039521349066752",
                                        },
                                        headers=headers)
    # # else:
    # #     url1 = 'http://124.70.221.250:8080/gpl/webservice/procurement/querylockAccountInfo'
    # #     r0 = RequestsHandler().post_Req(url=url1,
    # #                                     params={"loanId": "", "id": "38239715142197248"}, headers=headers)
    # #
    # url1 = 'http://124.70.221.250:8080/gpl/webservice/procurement/getLoan'
    # r0 = RequestsHandler().post_Req(url=url1,
    #                                 params={"loanId": "", "id": "38239713886003200"}, headers=headers)

    print(r0.text)
Exemplo n.º 7
0
def fun_ApiTimeLoop():
    # 优化格式化化版本
    timeNow = str(time.strftime('%Y%m%d%H%M%S', time.localtime(time.time())))
    appid = 'cjt'
    checkcode = 'cjt' + timeNow + 'e14b7c06-f127-4f7c-86f0-eec9bbcdc8d6'
    m = hashlib.md5()
    m.update(checkcode.encode('utf-8'))

    opera_url = "http://123.133.28.226:60011/gpl/webservice/security/getToken?appid=" + appid + "&timestamp=" + timeNow + "&checkcode=" + m.hexdigest()
    opera_result = RequestsHandler().post_Req(url=opera_url, params='')
    sting_response = opera_result.content.decode()
    json_response = dict_style(sting_response)
    token = json_response.get("token")
    if token is None:
        print('ERROR,Token没拿到')
    print(json_response)
    global timer
    timer = threading.Timer(1, fun_ApiTimeLoop)
    timer.start()
Exemplo n.º 8
0
def test_loopApiAccuracy():
    # 优化格式化化版本
    timeNow = str(time.strftime('%Y%m%d%H%M%S', time.localtime(time.time())))
    appid = 'cjt'
    checkcode = 'cjt' + timeNow + 'e14b7c06-f127-4f7c-86f0-eec9bbcdc8d6'
    m = hashlib.md5()
    m.update(checkcode.encode('utf-8'))

    opera_url = "http://123.133.28.226:60011/gpl/webservice/security/getToken?appid=" + appid + "&timestamp=" + timeNow + "&checkcode=" + m.hexdigest(
    )
    opera_result = RequestsHandler().post_Req(url=opera_url, params='')
    sting_response = opera_result.content.decode()
    json_response = dict_style(sting_response)
    token = json_response.get("token")
    f.write(str(json_response) + os.linesep)
    print(json_response)
    if token is None:
        print(json_response + '  失败  ')
    else:
        return 'sucess'
Exemplo n.º 9
0
    def tokenGet():
        handle_yaml = Yaml_Data.HandleYaml()
        yaml_dict = handle_yaml.file_load()
        def_name = sys._getframe().f_code.co_name
        test_assert = Assert.Assertions(def_name)
        logger.info("开始执行脚本%s:\n", def_name)
        opera_url = server_ip('uat1') + yaml_dict['test_config_token']['token_url']
        # print(opera_url)

        """ 测试http://10.88.2.23:12342/app/access_token接口 """
        opera_result = RequestsHandler().post_Req(url=opera_url, json=yaml_dict['test_config_token']['token_headers'],
                                                  data=yaml_dict['test_config_token']['token_params'])
        sting_response = opera_result.content.decode()  # 返回的请求结果
        json_response = dict_style(sting_response)  # 请求结果转换为json格式
        value = (json_response['data']['accessToken'])  # 获取请求结果中的token值
        token = 'bearer ' + value
        handle_yaml.file_dump(name='headers', key='Authorization', value=token)  # 写入组合后的token值
        test_assert.assert_code(json_response['code'], yaml_dict['code'])  # 断言请求的code值
        test_assert.assert_body(json_response, 'message', yaml_dict['message'])  # 断言请求的message值
        Consts.RESULT_LIST.append('pass')  # 接口执行结果为pass
Exemplo n.º 10
0
def getVerification():
    while True:
        userID = str(getUserId()[0])
        if userID is None:
            continue
        else:
            break
    if evn != 'SIT':
        url_fin = 'https://uat.chengtay.com/cjt/v1/certification/%s/callback'
    else:
        url_fin = 'http://sit.free.vipnps.vip/v1/certification/%s/callback'
    url_fin = url_fin.replace('%s', userID)
    r1 = RequestsHandler().post_Req(
        url=url_fin,
        data={
            "Message":
            "q4o3qIRdHmQMmiECxSDEO8cOFdCngJCxluyefZ55scmFEcBSdgPbDxosxvUiGQbyP3XfOZ8cojLuDrVqWn/pvR2vJCxIxmCRbhMwe7ThciXRQpXF0O4blrizzkqx/9IqbYXYsQ6J0RrPKVJHEDgm2e6V8w2AWzMU00HUyclPXJAZU04QuX2rKLMAps3cg9WwXUUC+L6TokaSNmV8dRBKOYWx8J3TszXW3oOzLTmJFY/pSBOp3ObeG1N1+CnQnyc9mOkedroE9ZDx+1P7zKJ4qsI1jyYRJ1+2OxLBshbIqY4=",
            "Dgtlenvlp":
            "MvXuUCz6PVUBb7xJhkJ6eU8QmPrgNL3lSgt5XQRiAsjdbeoQf3WapDlmHKIgr9Kj9wJFCw6ovl+5xd77xAtWynr8Xl+puaihAFhXN05DWEvBBv5Qjhm7gmzFdf1davKM/DMMWParIVusIDWJvKTyviSIuUsnIA50RFBuHcSC9KWXLioLEQht1L4BFR3F1M0/pFDnT2///VjM3PsvT/iFlDB82pXL4y+AA7EADE5aD5PrLG6ah57iNOrQUeJBmf8FCXXG8JoU/W/a3KqgOG0DwCi0fgSFWC7XuJXrTCJZBROi7LvLnWkvRaKk9LOHseUGAyuUJUENi5C3TbztDRfXSg=="
        },
    )
    print(r1.status_code)
Exemplo n.º 11
0
def getVerification_ui(url, act):
    userId = ''
    r0 = RequestsHandler().post_Req(
        url=url,
        json={
            "userName": str(act),
            "password": "******"
        },
    )
    sting_response = r0.content.decode()
    json_response = dict_style(sting_response)
    data = json_response.get('data')
    print('token为:' + str(data))

    r = RedisSqldata()
    keys = r.keys()
    pipe = r.pipeline()
    pipe_size = 100000
    len = 0
    key_list = []
    print(r.pipeline())

    for key in keys:
        key_list.append(key)
        pipe.get(key)
        if len < pipe_size:
            len += 1
        else:
            for (k, v) in zip(key_list, pipe.execute()):
                len = 0
                key_list = []

    for (k, v) in zip(key_list, pipe.execute()):
        k = bytes.decode(k)
        v = bytes.decode(v)
        if k == 'token:' + str(data):
            v = v.replace('null', '\"' + 'ok' + '\"')
            dic = eval(v)
            userId = dic.get('userId')
            break

    while 1:
        value1 = r.get('live:check:' + str(userId))
        if value1 is None:
            continue
        else:
            break
    strValue1 = bytes.decode(value1).replace('"', "")
    if evn != 'SIT':
        url_fin = 'https://uat.chengtay.com/cjt/v1/certification/%s/callback'
    else:
        url_fin = 'http://sit.free.vipnps.vip/v1/certification/%s/callback'
    url_fin = url_fin.replace('%s', str(strValue1))
    while 1:
        value1 = r.get('live:check:' + str(userId))
        if value1 is None:
            break
        else:
            continue
    r1 = RequestsHandler().post_Req(
        url=url_fin,
        data={
            "Message":
            "q4o3qIRdHmQMmiECxSDEO8cOFdCngJCxluyefZ55scmFEcBSdgPbDxosxvUiGQbyP3XfOZ8cojLuDrVqWn/pvR2vJCxIxmCRbhMwe7ThciXRQpXF0O4blrizzkqx/9IqbYXYsQ6J0RrPKVJHEDgm2e6V8w2AWzMU00HUyclPXJAZU04QuX2rKLMAps3cg9WwXUUC+L6TokaSNmV8dRBKOYWx8J3TszXW3oOzLTmJFY/pSBOp3ObeG1N1+CnQnyc9mOkedroE9ZDx+1P7zKJ4qsI1jyYRJ1+2OxLBshbIqY4=",
            "Dgtlenvlp":
            "MvXuUCz6PVUBb7xJhkJ6eU8QmPrgNL3lSgt5XQRiAsjdbeoQf3WapDlmHKIgr9Kj9wJFCw6ovl+5xd77xAtWynr8Xl+puaihAFhXN05DWEvBBv5Qjhm7gmzFdf1davKM/DMMWParIVusIDWJvKTyviSIuUsnIA50RFBuHcSC9KWXLioLEQht1L4BFR3F1M0/pFDnT2///VjM3PsvT/iFlDB82pXL4y+AA7EADE5aD5PrLG6ah57iNOrQUeJBmf8FCXXG8JoU/W/a3KqgOG0DwCi0fgSFWC7XuJXrTCJZBROi7LvLnWkvRaKk9LOHseUGAyuUJUENi5C3TbztDRfXSg=="
        },
    )
    print(r1)
Exemplo n.º 12
0
def test_coupon_create():
    create_url = "https://www.cantonfair.org.cn/api/exhibitsSreach/getSearchGoods"
    headers = {
        'User-Agent':
        'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
        'Chrome/83.0.4103.97 Safari/537.36 '
    }
    data = {
        "area": {
            "china": 0,
            "other": 0
        },
        "busType": {
            "isProduct": 0,
            "isExport": 0,
            "other": 0
        },
        "companyType": {
            "isBrand": 0,
            "isGreen": 0,
            "isInvite": 0,
            "isAeo": 0,
            "isCf": 0,
            "isPoorSpecial": 0
        },
        "history": {
            "isFirst": 0,
            "isSecond": 0
        },
        "productType": {
            "isNew": 0,
            "isCf": 0,
            "domesticSales": 0
        },
        "tradeType": {
            "isOem": 0,
            "isOBM": 0,
            "isCDM": 0
        },
        "lang": "cn",
        "order": {
            "relevant": 1
        },
        "pageIndex": 1,
        "searchType": "keyword",
        "pageSize": 60,
        "sessionId": "50ad2647-c75e-4e66-b05c-3d5f106ab1af",
        "keyword": "",
        "category": id,
        "isRecommend": 0
    }

    r = RequestsHandler().post_Req(url=create_url, data=data, headers=headers)
    statusCode = r.status_code
    print(statusCode)

    try:
        assert statusCode == 200, "返回状态码错误,接口请求失败"

        logger.info("statusCode返回正确-----> %s", statusCode)
    except Exception:
        logger.error("statusCode返回错误-----》 %s", statusCode)
        raise