Example #1
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接口异常"
Example #2
0
    def test_normal_set_auth(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.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
        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)

        # 修改电话
        changed_phone = faker.phone_number()
        verify = verify_info(manager, email, "alter_phone")
        manager.alter_phone(changed_phone,
                            DEFAULT_VERIFY_CODE,
                            "+86",
                            token=verify.token)

        # 绑定谷歌验证器
        verify = verify_info(manager, email, "bind_google")
        manager.bind_google(DEFAULT_VERIFY_CODE, verify.token)

        verify = verify_info(manager, email, "alter_google")
        # 修改谷歌验证器
        manager.alter_google(DEFAULT_VERIFY_CODE, verify.token)

        # 查看验证开关
        res = account_api.accounts_get_bind_status_get()
        assert res.google_authenticator == TURN_ON
        assert res.phone_authenticator == TURN_ON
        assert res.email_authenticator == TURN_ON

        # 开启谷歌验证
        manager.open_google(DEFAULT_VERIFY_CODE)

        res = account_api.accounts_get_bind_status_get()
        assert res.google_authenticator == TURN_ON
        assert res.phone_authenticator == TURN_ON
        assert res.email_authenticator == TURN_ON

        # 开启电话验证
        manager.open_phone(DEFAULT_VERIFY_CODE)
        res = account_api.accounts_get_bind_status_get()
        assert res.google_authenticator == TURN_ON
        assert res.phone_authenticator == TURN_ON
        assert res.email_authenticator == TURN_ON

        # 关闭谷歌验证
        manager.close_google(email, DEFAULT_VERIFY_CODE, DEFAULT_VERIFY_CODE)
        res = account_api.accounts_get_bind_status_get()
        assert res.google_authenticator == TURN_OFF
        assert res.phone_authenticator == TURN_ON
        assert res.email_authenticator == TURN_ON

        # 关闭电话验证
        manager.close_phone(email, DEFAULT_VERIFY_CODE, DEFAULT_VERIFY_CODE)
        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