Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 30 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,51 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2]
symfony: [2.8, 3.4, 4.4, 5.2, 6.0, 7.0]
php: [7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5]
symfony: [2.8, 3.4, 4.4, 5.4, 6.4, 7.4, 8.0]
exclude:
# Symfony 5 requires PHP >= 7.2
- php: 7.1
symfony: 5.2
symfony: 5.4
# Symfony 6 requires PHP >= 8.0
- php: 7.1
symfony: 6.0
symfony: 6.4
- php: 7.2
symfony: 6.0
symfony: 6.4
- php: 7.3
symfony: 6.0
symfony: 6.4
- php: 7.4
symfony: 6.0
symfony: 6.4
# Symfony 7 requires PHP >= 8.2
- php: 7.1
symfony: 7.0
symfony: 7.4
- php: 7.2
symfony: 7.0
symfony: 7.4
- php: 7.3
symfony: 7.0
symfony: 7.4
- php: 7.4
symfony: 7.0
symfony: 7.4
- php: 8.0
symfony: 7.0
symfony: 7.4
- php: 8.1
symfony: 7.0
symfony: 7.4
# Symfony 8 requires PHP >= 8.4
- php: 7.1
symfony: 8.0
- php: 7.2
symfony: 8.0
- php: 7.3
symfony: 8.0
- php: 7.4
symfony: 8.0
- php: 8.0
symfony: 8.0
- php: 8.1
symfony: 8.0
- php: 8.2
symfony: 8.0
- php: 8.3
symfony: 8.0
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
"require": {
"php": "^7.1 || ^8.0",
"google/recaptcha": "^1.1",
"symfony/form": "^2.8 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0",
"symfony/framework-bundle": "^2.8 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0",
"symfony/security-bundle": "^2.8 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0",
"symfony/validator": "^2.8 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0",
"symfony/yaml": "^2.8 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0",
"symfony/form": "^2.8 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0",
"symfony/framework-bundle": "^2.8 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0",
"symfony/security-bundle": "^2.8 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0",
"symfony/validator": "^2.8 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0",
"symfony/yaml": "^2.8 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0",
"twig/twig": "^1.40 || ^2.9 || ^3.0"
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion src/Validator/Constraints/IsTrueValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function validate($value, Constraint $constraint): void

$remoteip = $request->getClientIp();
// define variable for recaptcha check answer
$answer = $request->get('g-recaptcha-response');
$answer = $request->request->get('g-recaptcha-response');

// Verify user response with Google
$response = $this->recaptcha->verify($answer, $remoteip);
Expand Down
21 changes: 5 additions & 16 deletions tests/Validator/Constraints/IsTrueValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use PHPUnit\Framework\TestCase;
use ReCaptcha\ReCaptcha;
use ReCaptcha\Response;
use Symfony\Component\HttpFoundation\InputBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
Expand Down Expand Up @@ -89,10 +90,7 @@ public function testResponseNotSuccess(): void
$request->expects(self::once())
->method('getClientIp')
->willReturn($clientIp);
$request->expects(self::once())
->method('get')
->with('g-recaptcha-response')
->willReturn($recaptchaAnswer);
$request->request = new InputBag(['g-recaptcha-response' => $recaptchaAnswer]);

if (\is_callable([$requestStack, 'getMainRequest'])) {
$requestStack->expects(self::once())
Expand Down Expand Up @@ -145,10 +143,7 @@ public function testInvalidHostWithVerifyHost(): void
$request->expects(self::once())
->method('getClientIp')
->willReturn($clientIp);
$request->expects(self::once())
->method('get')
->with('g-recaptcha-response')
->willReturn($recaptchaAnswer);
$request->request = new InputBag(['g-recaptcha-response' => $recaptchaAnswer]);
$request->expects(self::once())
->method('getHost')
->willReturn('host1');
Expand Down Expand Up @@ -207,10 +202,7 @@ public function testInvalidHostWithoutVerifyHost(): void
$request->expects(self::once())
->method('getClientIp')
->willReturn($clientIp);
$request->expects(self::once())
->method('get')
->with('g-recaptcha-response')
->willReturn($recaptchaAnswer);
$request->request = new InputBag(['g-recaptcha-response' => $recaptchaAnswer]);
$request->expects(self::never())
->method('getHost');

Expand Down Expand Up @@ -269,10 +261,7 @@ public function testValidWithVerifyHost(): void
$request->expects(self::once())
->method('getClientIp')
->willReturn($clientIp);
$request->expects(self::once())
->method('get')
->with('g-recaptcha-response')
->willReturn($recaptchaAnswer);
$request->request = new InputBag(['g-recaptcha-response' => $recaptchaAnswer]);
$request->expects(self::once())
->method('getHost')
->willReturn($host);
Expand Down