Add code to display the invisible ReCaptcha in the frontend

This commit adds the required code to display the invisible ReCaptcha in
the frontend when a form is rendered and this type of captcha is
selected in the admin.

[MAILPOET-4145]
This commit is contained in:
Rodrigo Primo
2022-04-18 14:51:47 -03:00
committed by Veljko V
parent 84e22b82bd
commit c1bd52b964
6 changed files with 152 additions and 83 deletions

View File

@@ -697,6 +697,18 @@ class SubscribersTest extends \MailPoetTest {
$this->settings->set('captcha', []);
}
public function testItCannotSubscribeWithoutInvisibleReCaptchaWhenEnabled() {
$this->settings->set('captcha', ['type' => Captcha::TYPE_RECAPTCHA_INVISIBLE]);
$response = $this->endpoint->subscribe([
$this->obfuscatedEmail => 'toto@mailpoet.com',
'form_id' => $this->form->getId(),
$this->obfuscatedSegments => [$this->segment1->getId(), $this->segment2->getId()],
]);
expect($response->status)->equals(APIResponse::STATUS_BAD_REQUEST);
expect($response->errors[0]['message'])->equals('Please check the CAPTCHA.');
$this->settings->set('captcha', []);
}
public function testItCannotSubscribeWithoutBuiltInCaptchaWhenEnabled() {
$this->settings->set('captcha', ['type' => Captcha::TYPE_BUILTIN]);
$email = 'toto@mailpoet.com';