Skip to content

Commit 973a710

Browse files
committed
security-package/issues/105: Cover ReCaptchaContact module with integration test
1 parent 23d3cae commit 973a710

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

ReCaptchaContact/Test/Integration/ContactFormTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ protected function setUp()
6161
* @magentoConfigFixture base_website customer/captcha/enable 0
6262
* @magentoConfigFixture base_website recaptcha_frontend/type_invisible/public_key test_public_key
6363
* @magentoConfigFixture base_website recaptcha_frontend/type_invisible/private_key test_private_key
64+
*
65+
* @magentoConfigFixture default_store recaptcha_frontend/type_for/contact invisible Needed for ifconfig in layout
6466
*/
6567
public function testGetRequestIfReCaptchaIsDisabled()
6668
{
@@ -72,6 +74,8 @@ public function testGetRequestIfReCaptchaIsDisabled()
7274
/**
7375
* @magentoConfigFixture base_website customer/captcha/enable 0
7476
* @magentoConfigFixture base_website recaptcha_frontend/type_for/contact invisible
77+
*
78+
* @magentoConfigFixture default_store recaptcha_frontend/type_for/contact invisible Needed for ifconfig in layout
7579
*/
7680
public function testGetRequestIfReCaptchaKeysAreNotConfigured()
7781
{
@@ -85,6 +89,8 @@ public function testGetRequestIfReCaptchaKeysAreNotConfigured()
8589
* @magentoConfigFixture base_website recaptcha_frontend/type_invisible/public_key test_public_key
8690
* @magentoConfigFixture base_website recaptcha_frontend/type_invisible/private_key test_private_key
8791
* @magentoConfigFixture base_website recaptcha_frontend/type_for/contact invisible
92+
*
93+
* @magentoConfigFixture default_store recaptcha_frontend/type_for/contact invisible Needed for ifconfig in layout
8894
*/
8995
public function testGetRequestIfReCaptchaIsEnabled()
9096
{

ReCaptchaFrontendUi/view/frontend/requirejs-config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
'use strict';
77

8-
// eslint-disable-next-line no-unused-vars
98
var config = {
109
config: {
1110
mixins: {

ReCaptchaUser/Test/Integration/ForgotPasswordFormTest.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\ReCaptchaUser\Test\Integration;
99

1010
use Magento\Backend\Model\UrlInterface;
11+
use Magento\Framework\App\Request\Http;
1112
use Magento\Framework\Data\Form\FormKey;
1213
use Magento\Framework\Message\MessageInterface;
1314
use Magento\Framework\Validation\ValidationResult;
@@ -140,7 +141,7 @@ public function testPostRequestWithSuccessfulReCaptchaValidation()
140141
public function testPostRequestIfReCaptchaParameterIsMissed()
141142
{
142143
$this->getRequest()
143-
->setMethod(HttpRequest::METHOD_POST)
144+
->setMethod(Http::METHOD_POST)
144145
->setPostValue(
145146
[
146147
'form_key' => $this->formKey->getFormKey(),
@@ -163,7 +164,7 @@ public function testPostRequestWithFailedReCaptchaValidation()
163164
$this->captchaValidationResultMock->expects($this->once())->method('isValid')->willReturn(false);
164165

165166
$this->getRequest()
166-
->setMethod(HttpRequest::METHOD_POST)
167+
->setMethod(Http::METHOD_POST)
167168
->setPostValue(
168169
[
169170
'form_key' => $this->formKey->getFormKey(),
@@ -202,13 +203,15 @@ private function checkSuccessfulGetResponse($shouldContainReCaptcha = false)
202203
*/
203204
private function checkSuccessfulPostResponse(array $postValues = [])
204205
{
205-
$this->getRequest()->setPostValue(array_replace_recursive(
206-
[
207-
'form_key' => $this->formKey->getFormKey(),
208-
'email' => '[email protected]',
209-
],
210-
$postValues
211-
));
206+
$this->getRequest()
207+
->setMethod(Http::METHOD_POST)
208+
->setPostValue(array_replace_recursive(
209+
[
210+
'form_key' => $this->formKey->getFormKey(),
211+
'email' => '[email protected]',
212+
],
213+
$postValues
214+
));
212215
$this->dispatch('backend/admin/auth/forgotpassword');
213216

214217
$this->assertRedirect(self::equalTo($this->backendUrl->getRouteUrl('adminhtml')));

ReCaptchaUser/Test/Integration/LoginFormTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Magento\Backend\Model\Auth;
1111
use Magento\Backend\Model\UrlInterface;
12+
use Magento\Framework\App\Request\Http;
1213
use Magento\Framework\Data\Form\FormKey;
1314
use Magento\Framework\Message\MessageInterface;
1415
use Magento\Framework\Validation\ValidationResult;
@@ -147,7 +148,7 @@ public function testPostRequestWithSuccessfulReCaptchaValidation()
147148
public function testPostRequestIfReCaptchaParameterIsMissed()
148149
{
149150
$this->getRequest()
150-
->setMethod(HttpRequest::METHOD_POST)
151+
->setMethod(Http::METHOD_POST)
151152
->setPostValue(
152153
[
153154
'form_key' => $this->formKey->getFormKey(),
@@ -180,7 +181,7 @@ public function testPostRequestWithFailedReCaptchaValidation()
180181
$this->captchaValidationResultMock->expects($this->once())->method('isValid')->willReturn(false);
181182

182183
$this->getRequest()
183-
->setMethod(HttpRequest::METHOD_POST)
184+
->setMethod(Http::METHOD_POST)
184185
->setPostValue(
185186
[
186187
'form_key' => $this->formKey->getFormKey(),
@@ -227,7 +228,7 @@ private function checkSuccessfulGetResponse($shouldContainReCaptcha = false): vo
227228
private function checkSuccessfulPostResponse(array $postValues = []): void
228229
{
229230
$this->getRequest()
230-
->setMethod(HttpRequest::METHOD_POST)
231+
->setMethod(Http::METHOD_POST)
231232
->setPostValue(array_replace_recursive(
232233
[
233234
'form_key' => $this->formKey->getFormKey(),

0 commit comments

Comments
 (0)