示例#1
0
 def test_bind_device(self, device_type):
     manager = PlatformManager("main")
     device_api = DeviceManagerApi()
     user = random_user()
     email = user.get("email")
     password = user.get("password")
     country = user.get("country_abbreviation")
     manager.register(email=email,
                      password=password,
                      promotion_code=None,
                      verification_code="666666",
                      nationality_code=country,
                      challenge=self.challenge,
                      sec_code=self.sec_code,
                      validate=self.validate)
     token = manager.login(account=email,
                           password=password,
                           challenge=self.challenge,
                           sec_code=self.sec_code,
                           validate=self.validate)
     set_login_status(device_api, token)
     device_id = uuid.uuid4().hex
     device_type = device_type
     device_api.device_bind_post(device_id=device_id,
                                 device_type=device_type)
     device_api.device_unbind_post(device_id=device_id,
                                   device_type=device_type)
示例#2
0
    def test_incorrect_field_google(self, with_login, platform):
        manager = PlatformManager(platform)
        account_api = manager.account_api
        verify_api = manager.verify_api
        user = register_with_login(platform, with_login,
                                   [account_api, verify_api])
        email = user["email"]
        # 绑定谷歌验证器
        verify = verify_info(manager, email, "bind_google")
        try:
            account_api.accounts_bind_google_authenticator_post(
                word={
                    "googleCode": 123456,
                    "token": verify.token
                })
        except manager.api_exception as e:
            assert e.status == 400
        else:
            assert False, "绑定谷歌时填写错误类型的验证码,java接口异常"

        # 修改谷歌验证器
        verify = verify_info(manager, email, "alter_google")
        try:
            manager.alter_google("666666", verify.token)
        except manager.api_exception as e:
            assert e.status == 400
        else:
            assert False, "未绑定谷歌验证时调用修改谷歌验证,java接口异常"
示例#3
0
 def test_system_management(self):
     """1.前台新建市场成功——(后台)获取分区列表——交易币对配置列表
     ——修改交易币对配置——交易币对配置列表"""
     # 获取分区列表
     sys_api = SystemManagementApi()
     manager = PlatformManager('tenant')
     token = manager.login(sponsor_account, sponsor_pwd)
     sys_api.api_client.set_default_header("Authentication-Token", token)
     b_coin = TestProject.data['b_coin']
     s_coin = TestProject.data['s_coin']
     req = {'name': s_coin.name, 'partitionId': b_coin.id, 'page': 1}
     rv = sys_api.system_trading_pair_get(**req)
     assert len(rv.recharge_record) == 1
     record = rv.charge_record
     _id = record[0].id  # 交易对配置id
     price = record.price
     min_trading_price = record.min_trading_price
     max_trading_price = record.max_trading_price
     req = PutSystemTradingPairListResponse()
     req.min_trading_price = min_trading_price * 2
     req.max_trading_price = max_trading_price * 2
     req.price = price * 2
     # 修改交易对配置
     """2.前台新建市场成功——(后台)获取分区列表——交易币对配置列表
     ——批量修改交易币对单价——交易币对配置列表"""
     # 合并测试用例
     sys_api.system_trading_pair_id_put(_id, req)
     rv = sys_api.system_trading_pair_get(**req)
     record_1 = rv.charge_record
     assert record_1.min_trading_price == min_trading_price * 2
     assert record_1.max_trading_price == max_trading_price * 2
     assert record_1.price == price * 2
def company_verify(platform: str,
                   social_number: str,
                   token,
                   verify_status: str = "ACCEPTED",
                   reject_type: str = str()):
    """
    申请公司实名审核以及通过通过指定社会统一编号下的所有待审核的认证(供其他人调用)
    :param reject_type: 失败类型 [ INDIVIDUAL_ID,
                                 INDIVIDUAL_PASSPORT, ENTERPRISE_LOGO,
                                 ENTERPRISE_LICENSE, INDIVIDUAL_ABNORMAL,
                                 ENTERPRISE_ABNORMAL, USER_REPORT_ABNORMAL ]
    :param verify_status: 验证状态ACCEPTED(通过)、REJECTED(未通过)
    :param platform:平台类型 Enum("main", "sponsor", "staff",
                                    "tenant", "venture")
    :param social_number: 社会统一编号
    :param token: 用户登录token
    """
    manager = PlatformManager(platform)
    manager.apply_company_verify(social_number, token)
    admin_token = get_admin_token()
    audit_api = AuditApi()
    audit_api.api_client.set_default_header("Authorization",
                                            "Bearer " + admin_token)
    rv = audit_api.accounts_company_audits_tasks_audit_num_get()
    assert rv.pending_num >= 1
    apply_list = get_company_apply_list(audit_api, social_number)
    for apply_id in apply_list:
        handle_company_apply(audit_api, apply_id, verify_status, reject_type)
示例#5
0
    def test_failure_reasons(self):
        """12.新增审核失败原因——获取审核失败原因"""
        sys_api = SystemManagementApi()
        manager = PlatformManager('audit')
        token = manager.login(sponsor_account, sponsor_pwd)
        sys_api.api_client.set_default_header("Authentication-Token", token)
        sys_api.system_failure_reasons_get()
        # 新增审核失败原因
        new_failure_reason = 'for testing'
        sys_api.system_failure_reasons_post({
            'failureReason': new_failure_reason,
            'type': 'PERSONAL_AUTHENTICATE'
        })
        rv = sys_api.system_failure_reasons_get(type='PERSONAL_AUTHENTICATE')
        flag = False
        failure_reason_id = None
        for each in rv.items:
            if each.failure_reason == new_failure_reason:
                flag = True
                failure_reason_id = each.id
                break
        assert flag
        """13.新增审核失败原因——获取审核失败原因——弃用审核失败原因——获取审核失败原因"""
        # 弃用审核失败原因
        sys_api.system_failure_reasons_delete([failure_reason_id])

        # 获取审核失败原因
        rv = sys_api.system_failure_reasons_get(type='PERSONAL_AUTHENTICATE')
        for each in rv.items:
            if each.id == failure_reason_id:
                assert False
示例#6
0
def get_project():
    manager = PlatformManager('venture')
    token = manager.login(user, password)
    api = VentureApi()
    api.api_client.set_default_header("Authentication-Token", token)
    while True:
        project_name = "test_project_" + str(random.randint(1, 10000))
        rv = api.applications_check_project_name_post(
            project_name=project_name)
        if not rv.result:
            break
    return dict(project_name=project_name,
                description="hell of a project",
                official_website="http://showmethemoney.com",
                white_paper="http://showmethemoney.com/whitepaper",
                area_code="1333",
                project_poster="http://showmethemoney.com/poster",
                cellphone="86-123812391",
                telephone="12434234",
                email="*****@*****.**",
                full_name="hellboy",
                short_name="HB",
                issue_price="100 dollors",
                issued_volume="15",
                circulation_volume="13",
                issued_at=datetime.now(),
                coin_logo="http://showmethemoney.com/coin_logo",
                blockchain_type="public_chain",
                data_link="link me baby",
                block_browser="browser what")
示例#7
0
 def test_invite_success(self, platform, with_login):
     # 验证主平台,后台登录状态
     staff_token = get_admin_token()
     set_login_status(staff_acmanager_api, staff_token)
     register_with_login(platform, with_login,
                         [main_ac_api, main_invite_api])
     # 绑定登录user1与api
     # 获取主平台登录账户account_id,邀请码
     user1_acinfo_res = main_ac_api.accounts_account_info_get()
     user1_account_id = user1_acinfo_res.account_info.account_id
     print('user1账户id:', user1_account_id)
     # user2用user1的邀请码注册账号,登录成功
     manager = PlatformManager(platform)
     user2_ran_email = rand_email()
     print('user2邮箱:', user2_ran_email)
     ran_password = rand_password()
     ran_country = random_get_country_ob()["k"]
     try:
         manager.register(email=user2_ran_email,
                          password=ran_password,
                          promotion_code='321564',
                          nationality_code=ran_country,
                          nick_name=faker.name())
     except ApiException as e:
         assert e.status == 400
 def sign_out():
     nonlocal token
     nonlocal api_record
     nonlocal platform_type
     manager = PlatformManager(platform_type)
     if token and api_record:
         manager.logout(token, api_record)
def individual_verify(platform: str,
                      id_number: str,
                      token,
                      verify_status: str = "ACCEPTED",
                      reject_type: str = str()):
    """
    申请个人实名审核以及通过通过指定证件id下的所有待审核的认证(供其他人调用)
    :param reject_type: 失败类型 [ INDIVIDUAL_ID,
                                 INDIVIDUAL_PASSPORT, ENTERPRISE_LOGO,
                                 ENTERPRISE_LICENSE, INDIVIDUAL_ABNORMAL,
                                 ENTERPRISE_ABNORMAL, USER_REPORT_ABNORMAL ]
    :param verify_status: 验证状态approved(通过)、disapproved(未通过)
    :param token: 用户登录token
    :param platform: 平台类型 Enum("main", "sponsor", "staff",
                                    "tenant", "venture")
    :param id_number: 证件号码
    """
    manager = PlatformManager(platform)
    manager.apply_individual_verify(id_number, token)
    admin_token = get_admin_token()
    audit_api = AuditApi()
    audit_api.api_client.set_default_header("Authorization",
                                            "Bearer " + admin_token)
    apply_list = get_individual_apply_list(audit_api, id_number)
    for apply_id in apply_list:
        handle_individual_apply(audit_api, apply_id, verify_status,
                                reject_type)
示例#10
0
    def test_open_no_auth(self, with_login, platform):
        manager = PlatformManager(platform)
        account_api = manager.account_api
        user = register_with_login(platform, with_login, [account_api])
        email = user.get("email")
        res = account_api.accounts_get_bind_status_get()
        assert res.google_authenticator == TURN_OFF
        assert res.phone_authenticator == TURN_OFF
        assert res.email_authenticator == TURN_ON

        # 开启谷歌验证
        try:
            manager.open_google(DEFAULT_VERIFY_CODE)
        except manager.api_exception as e:
            assert e.status == 400
        else:
            assert False, "未绑定google,开启google验证,java接口异常"
        res = account_api.accounts_get_bind_status_get()
        assert res.google_authenticator == TURN_OFF
        assert res.phone_authenticator == TURN_OFF
        assert res.email_authenticator == TURN_ON

        # 开启电话验证
        try:
            manager.open_phone(DEFAULT_VERIFY_CODE)
        except manager.api_exception as e:
            assert e.status == 400
        else:
            assert False, "未绑定电话, 开启电话验证, java接口异常"
        res = account_api.accounts_get_bind_status_get()
        assert res.google_authenticator == TURN_OFF
        assert res.phone_authenticator == TURN_OFF
        assert res.email_authenticator == TURN_ON

        # 关闭谷歌验证
        try:
            manager.close_google(email, DEFAULT_VERIFY_CODE,
                                 DEFAULT_VERIFY_CODE)
        except manager.api_exception as e:
            assert e.status == 400
        else:
            assert False, "未绑定谷歌验证, 关闭谷歌验证, java接口异常"
        res = account_api.accounts_get_bind_status_get()
        assert res.google_authenticator == TURN_OFF
        assert res.phone_authenticator == TURN_OFF
        assert res.email_authenticator == TURN_ON

        # 关闭电话验证
        try:
            manager.close_phone(email, DEFAULT_VERIFY_CODE,
                                DEFAULT_VERIFY_CODE)
        except manager.api_exception as e:
            assert e.status == 400
        else:
            assert False, "未绑定电话验证, 关闭电话验证, java接口异常"
        res = account_api.accounts_get_bind_status_get()
        assert res.google_authenticator == TURN_OFF
        assert res.phone_authenticator == TURN_OFF
        assert res.email_authenticator == TURN_ON
    def test_investors(self, with_login):
        """3.未开通交易所——获取投资人列表列表———投资人详情(exchange id is None)"""
        manager = PlatformManager('tenant')
        account_api = AccountApi()
        api = manager.account_api
        verify_api = manager.verify_api
        user = register_with_login('tenant', with_login,
                                   [api, verify_api, account_api])
        # 绑定电话
        email = user.get('email')
        faker = Faker('zh_CN')
        phone = faker.phone_number()
        verify = verify_info(manager, email, "bind_phone")
        manager.bind_phone(phone, DEFAULT_VERIFY_CODE,
                           area_code="+86", token=verify.token)

        account_info = account_api.accounts_account_info_get()
        account_id = account_info.account_info.account_id

        exchange_api = ExchangeManagementApi()
        email, password = user['email'], user['password']
        token = with_login('tenant', [exchange_api], email, password)
        id_number = get_random_id_number()
        individual_verify('tenant', id_number, token)
        e = Exchange(exchange_api, token)
        exchange = e.get_exchange()
        exchange_api.exchange_post(exchange)
        rv = exchange_api.exchange_exchange_status_get()
        assert rv.status == 'pending'
        audit_api = AuditApi()
        admin_token = get_admin_token()
        set_login_status(audit_api, admin_token)
        rv = audit_api.tenant_audits_get(uid=account_id,
                                         exchange_name=exchange.name,
                                         type='audit')
        task = rv.items[0]
        task_id = task.id
        res = PostTenantAuditRequest(id=task_id, is_data_received=True,
                                     status='approved')
        audit_api.tenant_audits_audit_post(res)
        # 复审不通过
        res = PostTenantReAuditRequest(id=task_id,
                                       status='disapproved',
                                       failure_type='ENTERPRISE_LICENSE')
        audit_api.tenant_audits_re_audit_post(res)

        api = AccountManagementApi()
        admin_token = get_admin_token()
        set_login_status(api, admin_token)
        a_api = AccountApi()
        token = with_login('tenant', [a_api], email, password)
        account_info = a_api.accounts_account_info_get()
        account_id = account_info.account_info.account_id
        rv = api.accounts_investors_get(account_id=account_id)
        investors = rv.items
        assert len(investors) > 0
        rv = api.accounts_accounts_id_get(id=account_id)
        assert rv.basic_info.exchange_id is None
 def test_no_login_apply_company(self, platform):
     manager = PlatformManager(platform)
     id_number = get_random_id_number()
     try:
         manager.apply_company_verify(id_number)
     except manager.api_exception as e:
         assert e.status == 403
     else:
         assert False, "未登录申请公司实名认证时java接口异常"
 def test_no_login_verify_password(self, platform):
     manager = PlatformManager(platform)
     faker = Faker()
     try:
         manager.verify_password(faker.password())
     except manager.api_exception as e:
         assert e.status == 403
     else:
         assert False, "未登录进行密码验证, java接口异常"
示例#14
0
 def test_coin_market(self, with_login):
     manager = PlatformManager('tenant')
     m_api = MarketManagementApi()
     e_api = ExchangeManagementApi()
     api = manager.account_api
     verify_api = manager.verify_api
     account_api = AccountApi()
     user = register_with_login(
         'tenant', with_login, [api, verify_api, m_api, e_api, account_api])
     self.data['user'] = user
     token = user['token']
     email = user.get('email')
     # 绑定电话
     faker = Faker('zh_CN')
     phone = faker.phone_number()
     verify = verify_info(manager, email, "bind_phone")
     manager.bind_phone(phone,
                        DEFAULT_VERIFY_CODE,
                        area_code="+86",
                        token=verify.token)
     id_number = get_random_id_number()
     individual_verify('tenant', id_number, token)
     exchange_api = ExchangeManagementApi()
     e = Exchange(exchange_api, token)
     exchange = e.get_exchange()
     e_api.exchange_post(exchange)
     # 获取交易对市场列表
     try:
         m_api.markets_get()
     except ApiException as e:
         # 交易所不存在
         assert e.status == 400
     else:
         assert False, '市场应当不存在'
     # 初审复审
     rv = account_api.accounts_account_info_get()
     account_id = rv.account_info.account_id
     self.data['account_id'] = account_id
     audit_api = AuditApi()
     admin_token = get_admin_token()
     set_login_status(audit_api, admin_token)
     rv = audit_api.tenant_audits_get(uid=account_id,
                                      exchange_name=exchange.name,
                                      type='audit')
     task = rv.items[0]
     task_id = task.id
     res = PostTenantAuditRequest(id=task_id,
                                  is_data_received=True,
                                  status='approved')
     audit_api.tenant_audits_audit_post(res)
     # 复审
     res = PostTenantReAuditRequest(id=task_id, status='approved')
     audit_api.tenant_audits_re_audit_post(res)
     rv = e_api.exchange_exchange_id_get()
     exchange_id = rv.id
     self.data['exchange_id'] = exchange_id
示例#15
0
 def test_system_coins(self):
     """5.项目申请审核成功——币种配置列表——币种配置详情"""
     # 获取币种配置列表
     sys_api = SystemManagementApi()
     manager = PlatformManager('audit')
     token = manager.login(sponsor_account, sponsor_pwd)
     sys_api.api_client.set_default_header("Authentication-Token", token)
     project = TestProject.data['project']
     coin_name = project['short_name']
     pager = Pager(sys_api.system_coins_get, coinName=coin_name)
     coin_config_id = None
     for item in pager:
         coin_info = item.coinInfo
         for each in coin_info:
             if each.coin_name == coin_name:
                 coin_config_id = each.id
                 break
         if coin_config_id is not None:
             break
     assert coin_config_id is not None
     sys_api.system_coins_id_get(id=coin_config_id)
     """6.项目申请审核成功——修改币种配置——进行充提币操作——修改币种配置——进行充提币操作"""
     # 修改币种配置列表
     req = PutSystemCoinsRequest()
     req.min_recharge = '1'
     req.min_withdraw = '100'
     req.max_withdraw = '1222'
     sys_api.system_coins_id_put(req)
     rv = sys_api.system_coins_id_get(id=coin_config_id)
     assert rv.min_withdraw == '100'
     assert rv.max_withdraw == '1222'
     assert rv.min_recharge == '1'
     # todo 进行冲提币
     """
     7.项目申请审核成功——是否可充币(是)——前台进行充币操作 
     8.项目申请审核成功——是否可提币(是)——前台进行提币操作
     9.项目申请审核成功——是否可充币(否)——前台进行充币操作 
     10.项目申请审核成功——是否可提币(否)——前台进行提币操作
     """
     # 是否可冲提币
     sys_api.system_coins_id_recharge_put(id=coin_config_id,
                                          rechargeable=False)
     sys_api.system_coins_id_recharge_put(id=coin_config_id,
                                          rechargeable=True)
     sys_api.system_coins_id_withdraw_put(id=coin_config_id,
                                          withdrawable=False)
     sys_api.system_coins_id_withdraw_put(id=coin_config_id,
                                          withdrawable=True)
     # todo 冲提币操作
     """11.项目申请审核成功——币种配置列表——获取提示信息——编辑提示——获取提示信息"""
     sys_api.system_coins_id_prompt_get(id=coin_config_id)
     # 编辑提示
     req = {'defaultInfo': True, 'prompt': 'for test'}
     sys_api.system_coins_id_prompt_put(coin_config_id, req)
     rv = sys_api.system_coins_id_prompt_get(id=coin_config_id)
     assert rv.prompt == 'for test'
示例#16
0
 def test_normal_init_google(self, platform, with_login):
     manager = PlatformManager(platform)
     verify_api = manager.verify_api
     register_with_login(platform, with_login, api_list=[verify_api])
     res = manager.init_google()
     assert isinstance(res.uri, str)
     assert isinstance(res.key, str)
     res = manager.init_google()
     assert isinstance(res.uri, str)
     assert isinstance(res.key, str)
示例#17
0
 def test_normal_sign(self, platform):
     manager = PlatformManager(platform)
     user = random_user()
     email = user.get("email")
     password = user.get("password")
     country = user.get("country_abbreviation")
     manager.register(email=email,
                      password=password,
                      promotion_code=None,
                      verification_code="666666",
                      nationality_code=country,
                      challenge=self.challenge,
                      sec_code=self.sec_code,
                      validate=self.validate)
     token = manager.login(account=email,
                           password=password,
                           challenge=self.challenge,
                           sec_code=self.sec_code,
                           validate=self.validate)
     assert token
     assert isinstance(token, str)
     manager.logout(token, list())
     api_exception = manager.api_exception
     try:
         manager.logout(token, list())
     except api_exception as e:
         assert e.status == 403
     else:
         assert False, "重复注销java部分发生异常"
 def test_normal_reset_password(self, platform, with_login):
     manager = PlatformManager(platform)
     account_api = manager.account_api
     verify_api = manager.verify_api
     user = register_with_login(platform, with_login,
                                [account_api, verify_api])
     faker = Faker('zh_CN')
     new_password = faker.password()
     manager.reset_password(user.get("email"), new_password)
     token = manager.login(user.get("email"), new_password)
     assert isinstance(token, str)
 def test_favorite_project_case10(self):
     faker = Faker()
     manager = PlatformManager("main")
     email = random_email()
     password = faker.password()
     country = random_get_country_ob()
     manager.register(email=email,
                      password=password,
                      promotion_code=None,
                      verification_code="666666",
                      nationality_code=country.get("k"))
     token = manager.login(account=email, password=password)
     # 个人实名认证
     individual_verify(platform="main",
                       id_number=get_random_id_number(),
                       token=token)
     # 交易所排行列表
     exchange_api = ExchangeApi()
     set_login_status(exchange_api, token)
     res = exchange_api.exchanges_exchanges_get()
     exchange_id = ''
     for item in res.items:
         exchange_id = item.id
     # 获取交易对市场列表
     market_api = MarketApi()
     set_login_status(market_api, token)
     res = market_api.markets_get(exchange_id=exchange_id, page=1)
     market_id = ''
     for item in res.items:
         market_id = item.id
     # 收藏列表
     favorite_api = FavoriteMarketApi()
     set_login_status(favorite_api, token)
     res = favorite_api.favorites_market_get(page=1,
                                             exchange_id=exchange_id)
     assert res.meta.total_count == 0
     # 收藏
     payload = {'marketId': market_id}
     favorite_api.favorites_market_post(body=payload)
     # 收藏列表
     res = favorite_api.favorites_market_get(page=1,
                                             exchange_id=exchange_id)
     favorite_id = ''
     assert res.meta.total_count == 1
     for item in res.items:
         assert item.market_id == market_id
         assert item.id
         favorite_id = item.id
     # 取消收藏
     favorite_api.favorites_market_delete(id=favorite_id)
     # 收藏列表
     res = favorite_api.favorites_market_get(page=1,
                                             exchange_id=exchange_id)
     assert res.meta.total_count == 0
 def test_no_login_change(self, platform, with_login):
     manager = PlatformManager(platform)
     user = register_with_login(platform, with_login, list())
     faker = Faker('zh_CN')
     new_password = faker.password()
     try:
         manager.change_password(user.get("email"), user.get("password"),
                                 new_password)
     except manager.api_exception as e:
         assert e.status == 403
     else:
         assert False, "未登录的用户进行修改密码,java接口异常"
示例#21
0
    def test_bind_incorrect_field_phone(self, platform, with_login):
        manager = PlatformManager(platform)
        account_api = manager.account_api
        verify_api = manager.verify_api
        user = register_with_login(platform, with_login,
                                   [account_api, verify_api])
        res = account_api.accounts_get_bind_status_get()
        assert res.google_authenticator == TURN_OFF
        assert res.phone_authenticator == TURN_OFF
        assert res.email_authenticator == TURN_ON
        # 绑定电话
        verify = verify_info(manager, user["email"], "bind_phone")
        try:
            account_api.accounts_bind_phone_post(
                body={
                    "phoneNumber": 12345678,
                    "verificationCode": "666666",
                    "areaCode": "+86",
                    "token": verify.token
                })
        except manager.api_exception as e:
            assert e.status == 400
        else:
            assert False, "绑定电话时填写错误类型的电话java接口异常"

        # 绑定电话
        try:
            account_api.accounts_bind_phone_post(
                body={
                    "phoneNumber": "()??.,.@@@@",
                    "verificationCode": "666666",
                    "areaCode": "+86",
                    "token": verify.token
                })
        except manager.api_exception as e:
            assert e.status == 400
        else:
            assert False, "绑定电话时填写特殊字符的电话java接口异常"

        faker = Faker('zh_CN')
        changed_phone = faker.phone_number()
        # 修改电话
        verify = verify_info(manager, user["email"], "alter_phone")
        try:
            manager.alter_phone(changed_phone, DEFAULT_VERIFY_CODE, "+86",
                                verify.token)
        except manager.api_exception as e:
            assert e.status == 400
        else:
            assert False, "未绑定电话后调用修改电话接口,java接口异常"
 def test_no_account_reset_password(self, platform):
     manager = PlatformManager(platform)
     faker = Faker('zh_CN')
     email = faker.email()
     reset_password = manager.reset_password_request_model(uri=email,
                                                           challenge="",
                                                           seccode="",
                                                           validate="")
     try:
         manager.account_api.accounts_reset_password_post(reset_password)
     except manager.api_exception as e:
         assert e.status == 400
     else:
         assert False, "不存在的账户充值密码时, java接口异常"
示例#23
0
    def test_register(self, with_login):
        manager = PlatformManager('tenant')
        api = manager.account_api
        verify_api = manager.verify_api
        user = register_with_login('tenant', with_login, [api, verify_api])
        self.data['user'] = user

        # 绑定电话
        email = user.get('email')
        faker = Faker('zh_CN')
        phone = faker.phone_number()
        verify = verify_info(manager, email, "bind_phone")
        manager.bind_phone(phone, DEFAULT_VERIFY_CODE,
                           area_code="+86", token=verify.token)
示例#24
0
    def test_normal_change_asset_password(self, platform, with_login):
        manager = PlatformManager(platform)
        asset_api = manager.asset_api
        verify_api = manager.verify_api
        faker = Faker()
        asset_password = faker.password()
        user = register_with_login(platform, with_login,
                                   [asset_api, verify_api])
        res = asset_api.asset_mgmt_asset_password_get()
        assert not res.is_set

        # 添加资金密码后修改密码
        res = manager.verify({
            "challenge": "fjdks",
            "seccode": "jfkdlfd",
            "validate": "kfld;s",
            "account": "mailto:" + user.get("email"),
            "code": DEFAULT_VERIFY_CODE,
            "secondCode": "fdsaff",
            "type": "edit_asset_pwd"
        })
        base_token = res.token
        asset_api.asset_mgmt_asset_password_put(
            body={
                "password": user.get("password"),
                "traPassword": asset_password,
                "baseToken": base_token
            })
        res = asset_api.asset_mgmt_asset_password_get()
        assert res.is_set
        res = manager.verify({
            "challenge": "fjdks",
            "seccode": "jfkdlfd",
            "validate": "kfld;s",
            "account": "mailto:" + user.get("email"),
            "code": DEFAULT_VERIFY_CODE,
            "secondCode": "fdsaff",
            "type": "edit_asset_pwd"
        })
        base_token = res.token
        change_password = faker.password()
        asset_api.asset_mgmt_asset_password_put({
            "password":
            user.get("password"),
            "traPassword":
            change_password,
            "baseToken":
            base_token
        })
 def test_error_password_change(self, platform, with_login):
     manager = PlatformManager(platform)
     account_api = manager.account_api
     verify_api = manager.verify_api
     user = register_with_login(platform, with_login,
                                [account_api, verify_api])
     faker = Faker('zh_CN')
     new_password = faker.password()
     try:
         manager.change_password(user.get("email"), "12345678",
                                 new_password)
     except manager.api_exception as e:
         assert e.status == 400
     else:
         assert False, "输入错误密码后修改密码,java接口异常"
示例#26
0
    def test_withdraw_address(self, platform, with_login):
        manager = PlatformManager(platform)
        asset_api = manager.asset_api
        # 未登录获取提币地址
        try:
            asset_api.asset_mgmt_withdraw_addresses_get(coin_id="1")
        except manager.api_exception as e:
            assert e.status == 403
        else:
            assert False, "未登录获取提币地址, java接口异常"

        # 未添加获取提币地址
        register_with_login(platform, with_login, [asset_api])
        res = asset_api.asset_mgmt_withdraw_addresses_get(coin_id="1")
        assert not res

        # 添加提币地址后获取提币地址
        asset_api.asset_mgmt_withdraw_addresses_post(
            body={
                "coinId": "1",
                "remark": "remark",
                "address": "new_withdraw_address"
            })
        res = asset_api.asset_mgmt_withdraw_addresses_get(coin_id="1")
        withdraw_address = res.pop()
        assert withdraw_address["coinId"] == "1"
        assert withdraw_address["remark"] == "remark"
        assert withdraw_address["address"] == "new_withdraw_address"
        address_id = withdraw_address["id"]
        asset_api.asset_mgmt_withdraw_addresses_id_put(id=address_id)
        res = asset_api.asset_mgmt_withdraw_addresses_get(coin_id="1")
        assert not res
 def test_sample_get_account_info(self, platform, with_login):
     manager = PlatformManager(platform)
     account_api = manager.account_api
     user = register_with_login(platform, with_login, [account_api])
     email = user.get("email")
     country = user.get("country_abbreviation")
     password = user.get("password")
     res = account_api.accounts_account_info_get()
     print(res)
     assert isinstance(res.account_info.account_id, str)
     assert res.account_info.email == email
     assert res.account_info.nationality_code == country
     # assert isinstance(res.account_info.venture_id, str)
     # assert isinstance(res.account_info.tenant_id, str)
     # assert isinstance(res.account_info.investor_id, str)
     assert not res.account_info.phone_number
     assert isinstance(res.account_info.created_at, datetime)
     # assert res.security_verification.login_password == password
     # assert res.security_verification.tra_password == "false"
     assert not res.account_info.google_authenticator
     assert res.certification_audit.certification_status == "none"
     assert not res.certification_audit.certification_type
     assert not res.certification_audit.rejected_type
     assert not res.certification_audit.rejected_reason
     assert not res.certification_audit.application_date
     assert not res.certification_audit.certificat_name
示例#28
0
 def test_incorrect_field_register(self, platform):
     manager = PlatformManager(platform)
     api_exception = manager.api_exception
     account_api = manager.account_api
     try:
         # manager.register(email=123, password=123,
         #                  promotion_code=123, verification_code=123,
         #                  country=123, challenge=self.challenge,
         #                  sec_code=self.sec_code,
         #                  validate=self.validate)
         account_api.create_user(
             body={
                 "email": 123,
                 "password": 123,
                 "promotionCode": 123,
                 "verificationCode": 123,
                 "country": 123,
                 "challenge": 123,
                 "seccode": 123,
                 "validate": 123
             })
     except api_exception as e:
         assert e.status == 400
     else:
         assert False, "传参类型不对java借口调用异常"
示例#29
0
 def test_no_account_login(self, platform):
     manager = PlatformManager(platform)
     user = random_user()
     email = user.get("email")
     password = user.get("password")
     api_exception = manager.api_exception
     try:
         manager.login(account=email,
                       password=password,
                       challenge=self.challenge,
                       sec_code=self.sec_code,
                       validate=self.validate)
     except api_exception as e:
         assert e.status == 400
     else:
         assert False, "不存在的账户登录时java部分发生异常"
示例#30
0
    def test_exchange(self, with_login):
        manager = PlatformManager('tenant')
        account_api = AccountApi()
        api = manager.account_api
        verify_api = manager.verify_api
        user = register_with_login('tenant', with_login,
                                   [api, verify_api, account_api])
        # 绑定电话
        email = user.get('email')
        faker = Faker('zh_CN')
        phone = faker.phone_number()
        verify = verify_info(manager, email, "bind_phone")
        manager.bind_phone(phone, DEFAULT_VERIFY_CODE,
                           area_code="+86", token=verify.token)

        account_info = account_api.accounts_account_info_get()
        account_id = account_info.account_info.account_id
        id_number = get_random_id_number()
        individual_verify('tenant', id_number, user['token'])

        e_api = StaffExchangeManagementApi()
        a_api = AccountManagementApi()
        admin_token = get_admin_token()
        audit_api = AuditApi()
        set_login_status(audit_api, admin_token)
        set_login_status(e_api, admin_token)
        set_login_status(a_api, admin_token)
        # 用户列表
        rv = a_api.accounts_investors_get(account_id=account_id)
        assert rv.items

        # 后台开通交易所
        req = {
            "accountId": account_id,
            "area": "+86",
            "email": str(int(time.time())) + "@qq.com",
            "logo": "",
            "name": str(int(time.time())),
            "phone": "15548494655",
            "tags": ""
        }
        e_api.exchange_post(req)
        # 交易所审核列表
        rv = audit_api.tenant_audits_get(uid=account_id)
        item = rv.items[0]
        assert item.status == 'approved'