Beispiel #1
0
 def get_value_type(self, section):
     """
     :param section: sql yaml中的section
     :return: 表字段名及内容,为带字典的列表
     """
     sql = readfiles.read_yaml(self.sqlpath, section)
     valuedict = self.dbconn.quey_db(sql)
     return valuedict
Beispiel #2
0
 def get_col_type(self, section='coltype'):
     """
     :param section: 一般为coltype
     :return: 返回表类型及字段名
     """
     sql = readfiles.read_yaml(self.sqlpath, section)
     typedict = self.dbconn.quey_db(sql)
     return typedict
Beispiel #3
0
def send2session():
    s = requests.Session()
    log = logger.Log()
    loginfo = readfiles.read_yaml('interinfo/login.yaml', 'login')
    host = readfiles.read_yaml('interinfo/basic.yaml', 'mainhost').host
    password = encryptpwd.pwd_encryptwd(loginfo.data['j_password'])
    loginfo.data['j_password'] = password
    vcode = getvcode.GetVcode().baiduOCR()
    url = 'https://' + host + loginfo.url
    #TODO 这个循环逻辑好像有点问题,完成后尝试优化
    while True:
        while vcode is None or len(vcode) < 4:
            vcode = getvcode.GetVcode().baiduOCR()
        else:
            loginfo.data['verCode'] = vcode
            response = s.post(url=url,
                              data=loginfo.data,
                              headers=loginfo.headers,
                              verify=False)
            log.info(loginfo.data)
            if response.status_code == 200:
                print(response.status_code)
                return s
                break
Beispiel #4
0
def pwd_encryptwd(password='******'):
    #TODO 解决路径在linux和mac上的处理
    #忽略异常
    warnings.filterwarnings('ignore')
    hostinfo = readfiles.read_yaml('interinfo/basic.yaml', 'mainhost')
    host = hostinfo.host
    url = 'https://' + host + '/capaa/js/encrypt/encrypt.json'
    r = requests.get(url=url, verify=False)  # 获取公钥接口
    publickey = json.loads(r.text)['publicKey']
    publickey = b'-----BEGIN PUBLIC KEY-----\n' + bytes(
        publickey, 'utf8') + b'\n' + b'-----END PUBLIC KEY-----'
    raskey = RSA.importKey(publickey)
    cipher = PKCS1_v1_5.new(raskey)
    # cipher_text = base64.b64encode(cipher.encrypt(password))
    cipher_text = base64.b64encode(cipher.encrypt(bytes(password, 'utf8')))
    pravitekey = str(cipher_text, encoding='utf8').replace('+', '%2B')
    return pravitekey
Beispiel #5
0
 def setup_class(self):
     # 获取数据库连接对象
     self.conninfo = readfiles.read_yaml('dbopration\config.yaml', 'mysql')
     self.dbconn = mysqlconn.DBOperate(self.conninfo)
     self.sqlpath = 'sqlfiles\mysqlsql\mask_all_types.yaml'
     self.asserts = asserts.Pro_Result(self.sqlpath, self.dbconn)
Beispiel #6
0
                    with allure.step("数字类型错误字段"):
                        allure.attach("脱敏错误数据类型为", str(k))
                        allure.attach("值为", str(v))
            #判断是否为日期类型
            elif type(v) == datetime.date or type(v) == datetime.datetime:
                if '1970-01-01' in str(v):
                    result = True
                else:
                    result = False
                    #加入allure false内容输入出
                    with allure.step("日期类型错误字段"):
                        allure.attach("脱敏错误数据类型娄", str(k))
                        allure.attach("值为", str(v))
            resultlist.append(result)
        return resultlist


if __name__ == '__main__':
    # 获取数据库连接对象
    conninfo = readfiles.read_yaml('dbopration\config.yaml', 'mysql')
    dbconn = mysqlconn.DBOperate(conninfo)
    sqlpath = 'sqlfiles\mysqlsql\other_select.yaml'
    # sqlpath = 'sqlfiles\mysqlsql\other_select.yaml'
    proresult = Pro_Result(sqlpath, dbconn)
    result = proresult.get_col_value('POWER')[0]
    print(result)
    for k, v in result.items():
        print(k, type(v))
    result2 = proresult.assert_general('MAX')
    print(result2)