Ejemplo n.º 1
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部分发生异常"
Ejemplo n.º 2
0
 def test_incorrect_password_login(self, platform):
     faker = Faker()
     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)
     api_exception = manager.api_exception
     try:
         manager.login(account=email,
                       password=faker.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借口异常"
Ejemplo n.º 3
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)
Ejemplo n.º 4
0
 def test_interweave_sign(self, platform_1, platform_2, platform_3):
     manager_1 = PlatformManager(platform_1)
     manager_2 = PlatformManager(platform_2)
     manager_3 = PlatformManager(platform_3)
     user = random_user()
     email = user.get("email")
     password = user.get("password")
     country = user.get("country_abbreviation")
     manager_1.register(email=email,
                        password=password,
                        nationality_code=country,
                        challenge=self.challenge,
                        sec_code=self.sec_code,
                        validate=self.validate)
     token = manager_2.login(account=email,
                             password=password,
                             challenge=self.challenge,
                             sec_code=self.sec_code,
                             validate=self.validate)
     assert token
     assert isinstance(token, str)
     manager_3.logout(token, list())
     api_exception = manager_1.api_exception
     try:
         manager_1.logout(token, list())
     except api_exception as e:
         assert e.status == 403
     else:
         assert False, "重复注销java部分发生异常"
Ejemplo n.º 5
0
 def test_repeated_register(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,
                      verification_code="666666",
                      nationality_code=country,
                      challenge=self.challenge,
                      sec_code=self.sec_code,
                      validate=self.validate)
     api_exception = manager.api_exception
     try:
         manager.register(email=email,
                          password=password,
                          verification_code="666666",
                          nationality_code=country,
                          challenge=self.challenge,
                          sec_code=self.sec_code,
                          validate=self.validate)
     except api_exception as e:
         assert e.status == 400
     else:
         assert False, "重复注册java部分发生异常"
Ejemplo n.º 6
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部分发生异常"
Ejemplo n.º 7
0
 def test_fill_promotion_sign(self, platform):
     manager = PlatformManager(platform)
     user = random_user()
     email = user.get("email")
     password = user.get("password")
     country = user.get("country_abbreviation")
     try:
         manager.register(email=email,
                          password=password,
                          promotion_code="2NbYYJiEb4npQ",
                          verification_code="666666",
                          nationality_code=country,
                          challenge=self.challenge,
                          sec_code=self.sec_code,
                          validate=self.validate)
     except manager.api_exception as e:
         assert e.status == 400
     else:
         assert False, "填入不存在的验证码时, java接口异常"
Ejemplo n.º 8
0
 def test_token_isvalid(self):
     manager = PlatformManager("main")
     account_api = manager.account_api
     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(account_api, token)
     account_api.accounts_verify_is_valid_post()
Ejemplo n.º 9
0
    def create_limit_account(api_list, fail_type, platform='otc'):
        faker = Faker('zh_CN')
        user = random_user()
        user_res_info = dict()
        user_res_info['asset_password'] = ''
        manager = PlatformManager(platform)
        account_api = manager.account_api
        asset_api = manager.asset_api
        verify_api = manager.verify_api
        manager.register(
            email=user["email"],
            password=user["password"],
            nationality_code=user["country_abbreviation"],
            nick_name=faker.name()
        )

        token = with_login(
            'otc',
            api_list + [account_api, otc_balance_api, verify_api, asset_api, otc_buss_api],
            account=user["email"],
            password=user["password"])
        email = user.get("email")
        account_info = account_api.accounts_account_info_get()
        account_id = account_info.account_info.account_id
        user_res_info['account_id'] = account_id

        def bind_phone():
            phone = faker.phone_number()
            verify = verify_info(manager, email, "bind_phone")
            manager.bind_phone(
                phone, DEFAULT_VERIFY_CODE, area_code="+86", token=verify.token)

        def individual():
            id_number = get_random_id_number()
            individual_verify(platform, id_number, token)

        def assertr_pwd():
            # 设置资金密码
            asset_password = faker.password()
            res = verify_info(manager, email, '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
            user_res_info["asset_password"] = asset_password

        def biz_apply():
            # 后台登录
            admin_token = get_admin_token()
            user_res_info["admin_token"] = admin_token
            set_login_status(staff_buss_api, admin_token)

            # 前端申请
            # 后端通过
            otc_buss_api.biz_apply_post()
            admin_biz_rec = staff_buss_api.admin_biz_find_page_get(user_id=user_res_info['account_id'])
            order_num = admin_biz_rec.items[0].id

            staff_buss_api.admin_biz_info_get(id=order_num)

            success_reaason = "您的信良好"
            payload = AuditRequest(id=order_num, status=2, reason=success_reaason, file_recved=1)
            staff_buss_api.admin_biz_audit_post(payload)

        def deposit():
            otc_coin_list = otc_balance_api.balance_otc_coin_list_get()
            seller_coins = []
            for i in otc_coin_list.items:
                i = i.to_dict()
                if i['short_name'] == 'USDT':
                    usdt_coin_id = i['coin_id']
                else:
                    seller_coins.append(i['coin_id'])
            coin_id = random.choice(seller_coins or [usdt_coin_id + 1])  # random_coin.coin_id
            # 充币金手指
            headers = {"Authorization": "Bearer {}".format(token)}
            host = configuration.host
            user_res_info['buyer_coin_id'] = usdt_coin_id
            user_res_info['seller_coin_id'] = coin_id
            user_res_info['user_token'] = user.get('token')

            res = requests.post(
                f'{host}/asset-test/asset-initialize/{account_id}/{coin_id}',
                headers=headers)
            print(res)
            res = requests.post(
                f'{host}/asset-test/asset-initialize/{account_id}/{usdt_coin_id}',
                headers=headers)
            print(res)

            admin_token = get_admin_token()
            user_res_info["admin_token"] = admin_token
            set_login_status(staff_bal_api, user_res_info['admin_token'])
            # bb_res1 = asset_api.asset_mgmt_assets_coin_id_get(coin_id=usdt_coin_id)
            # print(bb_res1)
            transload = TransferFromRequest(currency_id=usdt_coin_id, amount=100_000)
            otc_balance_api.balance_transfer_from_post(transload)
            # bb_res2 = asset_api.asset_mgmt_assets_coin_id_get(coin_id=coin_id)
            # print(bb_res2)
            transload = TransferFromRequest(currency_id=coin_id, amount=100_000)
            otc_balance_api.balance_transfer_from_post(transload)
        bind_phone()
        individual()
        assertr_pwd()
        deposit()
        if fail_type != 'not_biz':
            biz_apply()

        return user_res_info
def create_venture():
    faker = Faker()
    manager = PlatformManager("venture")
    user = random_user()
    manager.register(email=user.get("email"),
                     password=user.get("password"),
                     promotion_code=None,
                     verification_code="666666",
                     nationality_code=user.get("country_abbreviation"))
    token = manager.login(account=user.get("email"),
                          password=user.get("password"))
    # 个人实名认证
    individual_verify(platform="venture",
                      id_number=get_random_id_number(),
                      token=token)
    # 申请项目
    project_api = ProjectApi()
    set_login_status(project_api, token)
    project_name = get_random_name(2, 16)
    full_name = get_random_name(2, 12)
    short_name = get_random_name(2, 6)
    # project_name = "USDT"
    # short_name = "USDT"
    res = project_api.applications_post(
        body={
            "projectName": project_name,
            "description": "{}-project-description".format(project_name),
            "officialWebsite": "www.{}.com".format(project_name),
            "whitePaperKey": "{}-whitePaper".format(project_name),
            "areaCode": "+86",
            "projectPosterKey": faker.uri_page(),
            # "projectPosterUrl": faker.url(),
            "cellphone": "123456789",
            "telephone": "12345678910",
            "email": faker.email(),
            "fullName": "{}的全部名".format(full_name),
            "shortName": short_name,
            "issuePrice": "2.24545",
            "issuedVolume": "1000000",
            "circulationVolume": "1000000",
            "issuedDate": "2018-08-08",
            "coinLogoKey": faker.uri_page(),
            # "coinLogoUrl": faker.url(),
            "blockchainType": "public_chain",
            "dataLink": "{}-data-link".format(project_name),
            "blockBrowser": "{}-block-Browser".format(project_name)
        })
    project_apply_id = res.id

    # 创建保健方账号
    staff_api = SponsorsManagermentApi()
    staff_token = get_admin_token()
    set_login_status(staff_api, staff_token)
    sponsor = {
        "account": get_random_name(8, 20),
        "password": faker.password(),
        "name": get_random_name(2, 20),
        "email": faker.email(),
        "phone": faker.phone_number()
    }
    staff_api.staff_sponsors_post(post_sponsor=sponsor)

    # 项目方获取保健列表
    venture_api = SMApi()
    set_login_status(venture_api, token)
    res = venture_api.sponsors_get(page=1, name=sponsor.get("name"))
    item = res.items.pop()
    sponsor_id = item.id

    # 项目方设置保健方
    project_api.applications_id_set_sponsor_put(
        id=project_apply_id, sponsor_request={"sponsorId": sponsor_id})

    # 保健方登录
    # 保健项目
    sponsor_api = SponsorsProjectApi()
    get_sponsor_token(account=sponsor.get("account"),
                      password=sponsor.get("password"),
                      email=sponsor.get("email"),
                      api_list=[sponsor_api])
    sponsor_api.projects_sponsor_put(put_project_sponsor_request={
        "id": project_apply_id,
        "status": 1,
        "remark": "remark"
    })

    # 获取币种列表
    asset_api = AssetManagementApi()
    set_login_status(asset_api, staff_token)
    res = asset_api.asset_mgmt_coins_get(coin_name=short_name)
    coin = res.items.pop()
    coin_id = coin.id

    # 项目初始化
    # staff_project_api = StaffProjectApi()
    # set_login_status(staff_project_api, staff_token)

    # staff_project_api.projects_coin_id_init_put(coin_id=coin_id,
    #                                             body={
    #                                                   "initFee": 111
    #                                                 })
    rc_confirmed_times = 2
    wc_confirmed_times = 2
    asset_api.asset_mgmt_coins_id_init_put(id=coin_id,
                                           body={
                                               "usdtPrice": "1",
                                               "rcTimes": rc_confirmed_times,
                                               "wcTimes": wc_confirmed_times,
                                               "withdrawRate": "0.003",
                                               "minWithdrawFee": "0.1",
                                               "minWithdraw": "20",
                                               "maxWithdraw": "1000",
                                               "dayWithdrawTotal": "30000",
                                               "minRecharge": "0.1",
                                               "addressTagSwitch": True,
                                               "addressType": short_name,
                                               "addressUrl": "addressUrl",
                                               "txidUrl": "fdfsfdstxidUrl"
                                           })

    # # 修改币种配置
    # asset_api.asset_mgmt_coins_id_put(
    #     id=coin.id, body={
    #               "rcTimes": 2,
    #               "wcTimes": 2,
    #               "withdrawRate": "0.003",
    #               "minWithdrawFee": "0.1",
    #               "minWithdraw": "20",
    #               "maxWithdraw": "1000",
    #               "dayWithdrawTotal": "30000",
    #               "minRecharge": "0.1",
    #               "addressTagSwitch": True,
    #               "addressType": short_name,
    #               "addressUrl": "addressUrl",
    #               "txidUrl": "fdfsfdstxidUrl"
    #             })
    register_wallet(short_name)
    return coin.id, coin.coin_id, short_name, rc_confirmed_times, wc_confirmed_times