开发者

How to Enter Captcha data with phpunit test

开发者 https://www.devze.com 2023-03-04 09:08 出处:网络
Is it possible to enter the captcha information with phpunit tests? something like $this->type(\"recaptcha_reponse_field\", \"information inside\");

Is it possible to enter the captcha information with phpunit tests?

something like

$this->type("recaptcha_reponse_field", "information inside");

I understand that captcha were 开发者_运维技巧created to prevent this kind of things, but i'm sure some1 out there once had to test a system automatically which needs captcha information before submiting the form.

Thanks D~~~


You can't do that, unless you OCR the captcha image. But then that is no longer a test :)

Usually some kind of bypass is implemented on server side. In pseudocode it would look like:

if ($config->bypass_captcha) {
   if ($recaptcha_response_field == 'correct') {
       // do what normally happens after submit
   } else { 
       // do what normally happens on incorrect captcha
   }
} else {
  // call recaptcha API to perform the real check
}

Then you need to ensure that "bypass_captcha" is never enabled on any on your public servers.

Of course, there are other ways too - like disabling captcha check for a given IP address (that belongs to the host from which you run the test from)

0

精彩评论

暂无评论...
验证码 换一张
取 消