def test_15_modifyPwdByOld_right(self):
        '''
        修改密码:通过密码来重置密码_原密码错误
        :return:
        '''
        contents = {
            "user_id": "{}".format(user_id),
            "old_password": "******",
            "new_password": "******"
        }
        data = {
            "app_id": 'b1044830052f359d',
            "timestamp": '2019-9-25 2:35:56',
            "version": '1.0',
            "client": 'android',
            "client_version": '4.0.1',
            "device_id": '123123',
            "method": 'user.reset_password_by_password',
            "access_token": '{}'.format(token),
            "biz_content": '{}'.format(contents),
        }
        datas = dict(sorted(data.items(), key=lambda x: x[0], reverse=False))
        sign = new_hmac_md5(self.SigSecret, datas)
        datas.update({"sign": sign})

        res = requests.post(url=self.app_host,
                            data=datas,
                            headers=self.headers).json()
        self.assertTrue(res['code'] == 0, msg="校验code错误")
        miaoshu(url=self.app_host,
                method='post',
                data=datas,
                check={"code and message"},
                respons=res)
    def test2_register_errorMsgCode(self):
        '''
        注册:注册用户_错误验证码
        :return:
        '''
        contents = {
            "phone": "{}".format(self.phone),
            "verification_code": "000000",
            "area_code": "3301"
        }
        data = {
            "app_id": 'b1044830052f359d',
            "timestamp": '2019-9-25 2:35:56',
            "version": '1.0',
            "client": 'android',
            "client_version": '4.0.1',
            "device_id": '123123',
            "method": 'user.register',
            "biz_content": '{}'.format(contents),
        }
        datas = dict(sorted(data.items(), key=lambda x: x[0], reverse=False))
        sign = new_hmac_md5(self.SigSecret, datas)
        datas.update({"sign": sign})

        res = requests.post(url=self.app_host,
                            data=datas,
                            headers=self.headers).json()
        self.assertTrue(res['code'] == 110001, msg="校验code错误")
        miaoshu(url=self.app_host,
                method='post',
                data=datas,
                check={"code and message"},
                respons=res)
    def test_17_modifyPhone_sendMsg_NoRegister(self):
        """
        修改手机号:发送验证码_修改后手机号未注册
        :return:
        """

        contents = {"phone": "{}".format(self.new_phone), "type": 5}
        data = {
            "app_id": 'b1044830052f359d',
            "timestamp": '2019-9-25 2:35:56',
            "version": '1.0',
            "client": 'android',
            "client_version": '4.0.1',
            "device_id": '123123',
            "method": 'user.send_verification_code',
            "access_token": '{}'.format(token),
            "biz_content": '{}'.format(contents),
        }
        datas = dict(sorted(data.items(), key=lambda x: x[0], reverse=False))
        sign = new_hmac_md5(self.SigSecret, datas)
        datas.update({"sign": sign})
        res = requests.post(url=self.app_host,
                            data=datas,
                            headers=self.headers).json()
        self.assertTrue(res['code'] == 0, msg="校验code错误")
        miaoshu(url=self.app_host,
                method='post',
                data=datas,
                check={"code and message"},
                respons=res)
 def test_11_modifyPwdCheckCode_error(self):
     '''
     修改密码:校验验证码(验证码错误)
     :return:
     '''
     contents = {
         "phone": "{}".format(self.phone),
         "type": 3,
         "verification_code": "000000"
     }
     data = {
         "app_id": 'b1044830052f359d',
         "timestamp": '2019-9-25 2:35:56',
         "version": '1.0',
         "client": 'android',
         "client_version": '4.0.1',
         "device_id": '123123',
         "method": 'user.check_verification_code',
         "access_token": '{}'.format(token),
         "biz_content": '{}'.format(contents),
     }
     datas = dict(sorted(data.items(), key=lambda x: x[0], reverse=False))
     sign = new_hmac_md5(self.SigSecret, datas)
     datas.update({"sign": sign})
     res = requests.post(url=self.app_host,
                         data=datas,
                         headers=self.headers).json()
     self.assertTrue(res['code'] == 110001, msg="校验code错误")
     miaoshu(url=self.app_host,
             method='post',
             data=datas,
             check={"code and message"},
             respons=res)
 def test8_ForgetCheckMsgCode_right(self):
     '''
     忘记密码:校验验证码(验证码正确)
     :return:
     '''
     MsgCode = get_cluster_value("forget_password_{}".format(self.phone),
                                 nodes=self.nodes)
     print(MsgCode)
     contents = {
         "phone": "{}".format(self.phone),
         "type": 3,
         "verification_code": "{}".format(MsgCode)
     }
     data = {
         "app_id": 'b1044830052f359d',
         "timestamp": '2019-9-25 2:35:56',
         "version": '1.0',
         "client": 'android',
         "client_version": '4.0.1',
         "device_id": '123123',
         "method": 'user.check_verification_code',
         "biz_content": '{}'.format(contents),
     }
     datas = dict(sorted(data.items(), key=lambda x: x[0], reverse=False))
     sign = new_hmac_md5(self.SigSecret, datas)
     datas.update({"sign": sign})
     res = requests.post(url=self.app_host,
                         data=datas,
                         headers=self.headers).json()
     self.assertTrue(res['code'] == 0, msg="校验code错误")
     miaoshu(url=self.app_host,
             method='post',
             data=datas,
             check={"code and message"},
             respons=res)
 def test5_SendMsg_right(self):
     """
     注册:发送验证码_用户已注册
     :return:
     """
     contents = {"phone": "15715814052", "type": 2}
     data = {
         "app_id": 'b1044830052f359d',
         "timestamp": '2019-9-25 2:35:56',
         "version": '1.0',
         "client": 'android',
         "client_version": '4.0.1',
         "device_id": '123123',
         "method": 'user.send_verification_code',
         "biz_content": '{}'.format(contents),
     }
     datas = dict(sorted(data.items(), key=lambda x: x[0], reverse=False))
     sign = new_hmac_md5(self.SigSecret, datas)
     datas.update({"sign": sign})
     res = requests.post(url=self.app_host,
                         data=datas,
                         headers=self.headers).json()
     self.assertTrue(res['code'] == 110002, msg="校验code错误")
     miaoshu(url=self.app_host,
             method='post',
             data=datas,
             check={"code and message"},
             respons=res)
    def test4_register_setPwd(self):
        '''
        注册:设置密码注册
        :return:
        '''

        contents = {"user_id": "{}".format(user_id), "password": "******"}
        data = {
            "app_id": 'b1044830052f359d',
            "timestamp": '2019-9-25 2:35:56',
            "version": '1.0',
            "client": 'android',
            "client_version": '4.0.1',
            "device_id": '123123',
            "method": 'user.update_user',
            "access_token": '{}'.format(token),
            "biz_content": '{}'.format(contents),
        }
        datas = dict(sorted(data.items(), key=lambda x: x[0], reverse=False))
        sign = new_hmac_md5(self.SigSecret, datas)
        datas.update({"sign": sign})

        res = requests.post(url=self.app_host,
                            data=datas,
                            headers=self.headers).json()
        self.assertTrue(res['code'] == 0, msg="校验code错误")
        miaoshu(url=self.app_host,
                method='post',
                data=datas,
                check={"code and message"},
                respons=res)
 def test3_register_right(self):
     '''
     注册:注册用户_正确验证码
     :return:
     '''
     global token, user_id
     MsgCode = get_cluster_value("register_{}".format(self.phone),
                                 nodes=self.nodes)
     print(MsgCode)
     contents = {
         "phone": "{}".format(self.phone),
         "verification_code": "{}".format(MsgCode)
     }
     data = {
         "app_id": 'b1044830052f359d',
         "timestamp": '2019-9-25 2:35:56',
         "version": '1.0',
         "client": 'android',
         "client_version": '4.0.1',
         "device_id": '123123',
         "method": 'user.register',
         "biz_content": '{}'.format(contents),
     }
     datas = dict(sorted(data.items(), key=lambda x: x[0], reverse=False))
     sign = new_hmac_md5(self.SigSecret, datas)
     datas.update({"sign": sign})
     res = requests.post(url=self.app_host,
                         data=datas,
                         headers=self.headers).json()
     self.assertTrue(res['code'] == 0, msg="校验code错误")
     miaoshu(url=self.app_host,
             method='post',
             data=datas,
             check={"code and message"},
             respons=res)
     # print(res['data']['token'])
     token = res['data']['token']
     user_id = res['data']['user_id']
     return token, user_id
 def test_18_modifyPhone_newphone(self):
     '''
     修改手机号:修改用户登录手机号
     :return:
     '''
     MsgCode = get_cluster_value("modify_phone_{}".format(self.new_phone),
                                 nodes=self.nodes)
     print(MsgCode)
     contents = {
         "new_phone": "{}".format(self.new_phone),
         "user_id": "{}".format(user_id),
         "verification_code": "{}".format(MsgCode)
     }
     data = {
         "app_id": 'b1044830052f359d',
         "timestamp": '2019-9-25 2:35:56',
         "version": '1.0',
         "client": 'android',
         "client_version": '4.0.1',
         "device_id": '123123',
         "method": 'user.modify_phone',
         "access_token": '{}'.format(token),
         "biz_content": '{}'.format(contents),
     }
     datas = dict(sorted(data.items(), key=lambda x: x[0], reverse=False))
     sign = new_hmac_md5(self.SigSecret, datas)
     datas.update({"sign": sign})
     res = requests.post(url=self.app_host,
                         data=datas,
                         headers=self.headers).json()
     self.assertTrue(res['code'] == 0, msg="校验code错误")
     miaoshu(url=self.app_host,
             method='post',
             data=datas,
             check={"code and message"},
             respons=res)