Skip to content

Commit

Permalink
Merge pull request #10 from crawly/anticaptcha-enterprise
Browse files Browse the repository at this point in the history
Added support for enterprise reCAPTCHA v3 in AntiCaptcha
  • Loading branch information
Tagliatti authored Feb 15, 2024
2 parents debc045 + 0f0b7e5 commit 13d9392
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
24 changes: 14 additions & 10 deletions src/Provider/AntiCaptcha/ReCaptchaV3.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ReCaptchaV3 extends AntiCaptcha implements ProviderInterface
private $websiteURL;
private $websiteKey;
private $pageAction;
private $isEnterprise;
private $minScore;

public function __construct(
Expand All @@ -23,13 +24,15 @@ public function __construct(
string $websiteKey,
string $pageAction,
float $minScore,
bool $isEnterprise = false,
LoggerInterface $logger = null
) {
$this->clientKey = $clientKey;
$this->websiteURL = $websiteURL;
$this->websiteKey = $websiteKey;
$this->pageAction = $pageAction;
$this->minScore = $minScore;
$this->clientKey = $clientKey;
$this->websiteURL = $websiteURL;
$this->websiteKey = $websiteKey;
$this->pageAction = $pageAction;
$this->minScore = $minScore;
$this->isEnterprise = $isEnterprise;

$this->logger = $logger;

Expand All @@ -39,11 +42,12 @@ public function __construct(
protected function getPostData()
{
return [
'type' => 'RecaptchaV3TaskProxyless',
'websiteURL' => $this->websiteURL,
'websiteKey' => $this->websiteKey,
'minScore' => $this->minScore,
'pageAction' => $this->pageAction,
'type' => 'RecaptchaV3TaskProxyless',
'websiteURL' => $this->websiteURL,
'websiteKey' => $this->websiteKey,
'minScore' => $this->minScore,
'pageAction' => $this->pageAction,
'isEnterprise' => $this->isEnterprise,
];
}

Expand Down
5 changes: 3 additions & 2 deletions tests/AntiCaptcha/ReCaptchaV3Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ReCaptchaV3Test extends TestCase
{
public function testGetPostData()
{
$noCaptcha = $this->getMockBuilder(ReCaptchaV3::class)->setConstructorArgs(['123', 'url', 'key', 'action', ReCaptchaV3::MIN_SCORE_0_3])->getMock();
$noCaptcha = $this->getMockBuilder(ReCaptchaV3::class)->setConstructorArgs(['123', 'url', 'key', 'action', ReCaptchaV3::MIN_SCORE_0_3, true])->getMock();

$stub = $this->getNoCaptchaReflection();

Expand All @@ -25,6 +25,7 @@ public function testGetPostData()
$this->assertEquals('key', $postData['websiteKey']);
$this->assertEquals('action', $postData['pageAction']);
$this->assertEquals(ReCaptchaV3::MIN_SCORE_0_3, $postData['minScore']);
$this->assertEquals('isEnterprise', $postData['isEnterprise']);
}

protected function getNoCaptchaReflection(): ReflectionClass
Expand All @@ -39,4 +40,4 @@ protected function getPostDataMethod(ReflectionClass $stub): \ReflectionMethod

return $getPostData;
}
}
}

0 comments on commit 13d9392

Please sign in to comment.