コード例 #1
0
    def test_fail_aiorecaptcha_v3_proxyless_context(self):
        with ReCaptchaV3TaskProxyless.aioReCaptchaV3TaskProxyless(
                anticaptcha_key=self.anticaptcha_key_fail) as recaptcha:
            # check response type
            assert (type(recaptcha) is
                    ReCaptchaV3TaskProxyless.aioReCaptchaV3TaskProxyless)

            response = yield recaptcha.captcha_handler(
                websiteURL="https://www.google.com/recaptcha/api2/demo",
                websiteKey="6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-",
                minScore=0.3,
                pageAction="login_test",
            )
        # check response type
        assert type(response) is dict
        # check all dict keys
        assert ["errorId", "errorCode",
                "errorDescription"] == list(response.keys())
        # check error code
        assert response["errorId"] == 1

        with ReCaptchaV3TaskProxyless.aioReCaptchaV3TaskProxyless(
                anticaptcha_key=self.anticaptcha_key_fail) as recaptcha:
            with pytest.raises(ValueError):
                assert recaptcha.captcha_handler(
                    websiteURL="https://www.google.com/recaptcha/api2/demo",
                    websiteKey="6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-",
                    minScore=0.1,
                    pageAction="login_test",
                )
コード例 #2
0
 async def test_fail_aiorecaptcha3_value_context(self):
     with ReCaptchaV3TaskProxyless.aioReCaptchaV3TaskProxyless(
             anticaptcha_key=self.anticaptcha_key_fail) as recaptcha:
         with pytest.raises(ValueError):
             assert await recaptcha.captcha_handler(
                 websiteURL="https://www.google.com/recaptcha/api2/demo",
                 websiteKey="6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-",
                 minScore=0.1,
                 pageAction="login_test",
             )
コード例 #3
0
    async def test_response_aiorecaptcha3(self):
        recaptcha = ReCaptchaV3TaskProxyless.aioReCaptchaV3TaskProxyless(
            anticaptcha_key=self.anticaptcha_key_fail)
        # check response type
        assert isinstance(recaptcha,
                          ReCaptchaV3TaskProxyless.aioReCaptchaV3TaskProxyless)

        response = await recaptcha.captcha_handler(
            websiteURL="https://www.google.com/recaptcha/api2/demo",
            websiteKey="6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-",
            minScore=ReCaptchaV3TaskProxyless.MIN_SCORES[0],
            pageAction="login_test",
        )
        # check response type
        assert isinstance(response, dict)
        # check all dict keys
        assert ["errorId", "errorCode",
                "errorDescription"] == list(response.keys())