diff --git a/app/code/Magento/Captcha/Observer/CheckGuestCheckoutObserver.php b/app/code/Magento/Captcha/Observer/CheckGuestCheckoutObserver.php
deleted file mode 100644
index 7ccaa76b6c7c8..0000000000000
--- a/app/code/Magento/Captcha/Observer/CheckGuestCheckoutObserver.php
+++ /dev/null
@@ -1,82 +0,0 @@
-_helper = $helper;
- $this->_actionFlag = $actionFlag;
- $this->captchaStringResolver = $captchaStringResolver;
- $this->_typeOnepage = $typeOnepage;
- $this->jsonHelper = $jsonHelper;
- }
-
- /**
- * Check Captcha On Checkout as Guest Page
- *
- * @param \Magento\Framework\Event\Observer $observer
- * @return $this
- */
- public function execute(\Magento\Framework\Event\Observer $observer)
- {
- $formId = 'guest_checkout';
- $captchaModel = $this->_helper->getCaptcha($formId);
- $checkoutMethod = $this->_typeOnepage->getQuote()->getCheckoutMethod();
- if ($checkoutMethod == \Magento\Checkout\Model\Type\Onepage::METHOD_GUEST
- && $captchaModel->isRequired()
- ) {
- $controller = $observer->getControllerAction();
- if (!$captchaModel->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), $formId))) {
- $this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
- $result = ['error' => 1, 'message' => __('Incorrect CAPTCHA')];
- $controller->getResponse()->representJson($this->jsonHelper->jsonEncode($result));
- }
- }
-
- return $this;
- }
-}
diff --git a/app/code/Magento/Captcha/Observer/CheckRegisterCheckoutObserver.php b/app/code/Magento/Captcha/Observer/CheckRegisterCheckoutObserver.php
deleted file mode 100644
index 8e110a9f4653d..0000000000000
--- a/app/code/Magento/Captcha/Observer/CheckRegisterCheckoutObserver.php
+++ /dev/null
@@ -1,82 +0,0 @@
-_helper = $helper;
- $this->_actionFlag = $actionFlag;
- $this->captchaStringResolver = $captchaStringResolver;
- $this->_typeOnepage = $typeOnepage;
- $this->jsonHelper = $jsonHelper;
- }
-
- /**
- * Check Captcha On Checkout Register Page
- *
- * @param \Magento\Framework\Event\Observer $observer
- * @return $this
- */
- public function execute(\Magento\Framework\Event\Observer $observer)
- {
- $formId = 'register_during_checkout';
- $captchaModel = $this->_helper->getCaptcha($formId);
- $checkoutMethod = $this->_typeOnepage->getQuote()->getCheckoutMethod();
- if ($checkoutMethod == \Magento\Checkout\Model\Type\Onepage::METHOD_REGISTER
- && $captchaModel->isRequired()
- ) {
- $controller = $observer->getControllerAction();
- if (!$captchaModel->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), $formId))) {
- $this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
- $result = ['error' => 1, 'message' => __('Incorrect CAPTCHA')];
- $controller->getResponse()->representJson($this->jsonHelper->jsonEncode($result));
- }
- }
-
- return $this;
- }
-}
diff --git a/app/code/Magento/Captcha/Test/Mftf/ActionGroup/CaptchaFormsDisplayingActionGroup.xml b/app/code/Magento/Captcha/Test/Mftf/ActionGroup/CaptchaFormsDisplayingActionGroup.xml
new file mode 100644
index 0000000000000..71a876bbbcdbf
--- /dev/null
+++ b/app/code/Magento/Captcha/Test/Mftf/ActionGroup/CaptchaFormsDisplayingActionGroup.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Captcha/Test/Mftf/Data/CaptchaFormsDisplayingData.xml b/app/code/Magento/Captcha/Test/Mftf/Data/CaptchaFormsDisplayingData.xml
new file mode 100644
index 0000000000000..9db8110c0f64b
--- /dev/null
+++ b/app/code/Magento/Captcha/Test/Mftf/Data/CaptchaFormsDisplayingData.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+ Create user
+ Login
+ Forgot password
+ Contact Us
+ Change password
+ Register during Checkout
+ Check Out as Guest
+
+
diff --git a/app/code/Magento/Captcha/Test/Mftf/Section/CaptchaFormsDisplayingSection.xml b/app/code/Magento/Captcha/Test/Mftf/Section/CaptchaFormsDisplayingSection.xml
new file mode 100644
index 0000000000000..4c974e6fced05
--- /dev/null
+++ b/app/code/Magento/Captcha/Test/Mftf/Section/CaptchaFormsDisplayingSection.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Captcha/Test/Mftf/Test/CaptchaFormsDisplayingTest.xml b/app/code/Magento/Captcha/Test/Mftf/Test/CaptchaFormsDisplayingTest.xml
new file mode 100644
index 0000000000000..8f764899706ac
--- /dev/null
+++ b/app/code/Magento/Captcha/Test/Mftf/Test/CaptchaFormsDisplayingTest.xml
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{CaptchaData.checkoutAsGuest}}
+ $formItems
+
+
+ {{CaptchaData.register}}
+ $formItems
+
+
+
+
+ {{CaptchaData.createUser}}
+ $createUser
+
+
+
+ {{CaptchaData.login}}
+ login
+
+
+
+ {{CaptchaData.passwd}}
+ $forgotpassword
+
+
+
+ {{CaptchaData.contactUs}}
+ $contactUs
+
+
+
+ {{CaptchaData.changePasswd}}
+ $userEdit
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Captcha/Test/Unit/Model/DefaultTest.php b/app/code/Magento/Captcha/Test/Unit/Model/DefaultTest.php
index 0500b29f787c2..1edbcc029e4ce 100644
--- a/app/code/Magento/Captcha/Test/Unit/Model/DefaultTest.php
+++ b/app/code/Magento/Captcha/Test/Unit/Model/DefaultTest.php
@@ -24,7 +24,7 @@ class DefaultTest extends \PHPUnit\Framework\TestCase
'enable' => '1',
'font' => 'linlibertine',
'mode' => 'after_fail',
- 'forms' => 'user_forgotpassword,user_create,guest_checkout,register_during_checkout',
+ 'forms' => 'user_forgotpassword,user_create',
'failed_attempts_login' => '3',
'failed_attempts_ip' => '1000',
'timeout' => '7',
@@ -35,8 +35,6 @@ class DefaultTest extends \PHPUnit\Framework\TestCase
'always_for' => [
'user_create',
'user_forgotpassword',
- 'guest_checkout',
- 'register_during_checkout',
'contact_us',
],
];
@@ -362,8 +360,7 @@ public function isShownToLoggedInUserDataProvider()
return [
[true, 'contact_us'],
[false, 'user_create'],
- [false, 'user_forgotpassword'],
- [false, 'guest_checkout']
+ [false, 'user_forgotpassword']
];
}
}
diff --git a/app/code/Magento/Captcha/Test/Unit/Observer/CheckGuestCheckoutObserverTest.php b/app/code/Magento/Captcha/Test/Unit/Observer/CheckGuestCheckoutObserverTest.php
deleted file mode 100644
index d3f29fae8a592..0000000000000
--- a/app/code/Magento/Captcha/Test/Unit/Observer/CheckGuestCheckoutObserverTest.php
+++ /dev/null
@@ -1,211 +0,0 @@
-createMock(Onepage::class);
- $captchaHelperMock = $this->createMock(CaptchaDataHelper::class);
- $this->objectManager = new ObjectManager($this);
- $this->actionFlagMock = $this->createMock(ActionFlag::class);
- $this->captchaStringResolverMock = $this->createMock(CaptchaStringResolver::class);
- $this->captchaModelMock = $this->createMock(CaptchaModel::class);
- $this->quoteModelMock = $this->createMock(Quote::class);
- $this->controllerMock = $this->createMock(Action::class);
- $this->requestMock = $this->createMock(Http::class);
- $this->responseMock = $this->createMock(HttpResponse::class);
- $this->observer = new Observer(['controller_action' => $this->controllerMock]);
- $this->jsonHelperMock = $this->createMock(JsonHelper::class);
-
- $this->checkGuestCheckoutObserver = $this->objectManager->getObject(
- CheckGuestCheckoutObserver::class,
- [
- 'helper' => $captchaHelperMock,
- 'actionFlag' => $this->actionFlagMock,
- 'captchaStringResolver' => $this->captchaStringResolverMock,
- 'typeOnepage' => $onepageModelTypeMock,
- 'jsonHelper' => $this->jsonHelperMock
- ]
- );
-
- $captchaHelperMock->expects($this->once())
- ->method('getCaptcha')
- ->with(self::FORM_ID)
- ->willReturn($this->captchaModelMock);
- $onepageModelTypeMock->expects($this->once())
- ->method('getQuote')
- ->willReturn($this->quoteModelMock);
- }
-
- public function testCheckGuestCheckoutForRegister()
- {
- $this->quoteModelMock->expects($this->once())
- ->method('getCheckoutMethod')
- ->willReturn(Onepage::METHOD_REGISTER);
- $this->captchaModelMock->expects($this->never())
- ->method('isRequired');
-
- $this->checkGuestCheckoutObserver->execute($this->observer);
- }
-
- public function testCheckGuestCheckoutWithNoCaptchaRequired()
- {
- $this->quoteModelMock->expects($this->once())
- ->method('getCheckoutMethod')
- ->willReturn(Onepage::METHOD_GUEST);
- $this->captchaModelMock->expects($this->once())
- ->method('isRequired')
- ->willReturn(false);
- $this->captchaModelMock->expects($this->never())
- ->method('isCorrect');
-
- $this->checkGuestCheckoutObserver->execute($this->observer);
- }
-
- public function testCheckGuestCheckoutWithIncorrectCaptcha()
- {
- $captchaValue = 'some_word';
- $encodedJsonValue = '{}';
-
- $this->quoteModelMock->expects($this->once())
- ->method('getCheckoutMethod')
- ->willReturn(Onepage::METHOD_GUEST);
- $this->captchaModelMock->expects($this->once())
- ->method('isRequired')
- ->willReturn(true);
- $this->controllerMock->expects($this->once())
- ->method('getRequest')
- ->willReturn($this->requestMock);
- $this->controllerMock->expects($this->once())
- ->method('getResponse')
- ->willReturn($this->responseMock);
- $this->controllerMock->expects($this->once())
- ->method('getResponse')
- ->willReturn($this->responseMock);
- $this->captchaStringResolverMock->expects($this->once())
- ->method('resolve')
- ->with($this->requestMock, self::FORM_ID)
- ->willReturn($captchaValue);
- $this->captchaModelMock->expects($this->once())
- ->method('isCorrect')
- ->with($captchaValue)
- ->willReturn(false);
- $this->actionFlagMock->expects($this->once())
- ->method('set')
- ->with('', Action::FLAG_NO_DISPATCH, true);
- $this->jsonHelperMock->expects($this->once())
- ->method('jsonEncode')
- ->willReturn($encodedJsonValue);
- $this->responseMock->expects($this->once())
- ->method('representJson')
- ->with($encodedJsonValue);
-
- $this->checkGuestCheckoutObserver->execute($this->observer);
- }
-
- public function testCheckGuestCheckoutWithCorrectCaptcha()
- {
- $this->quoteModelMock->expects($this->once())
- ->method('getCheckoutMethod')
- ->willReturn(Onepage::METHOD_GUEST);
- $this->captchaModelMock->expects($this->once())
- ->method('isRequired')
- ->willReturn(true);
- $this->controllerMock->expects($this->once())
- ->method('getRequest')
- ->willReturn($this->requestMock);
- $this->captchaStringResolverMock->expects($this->once())
- ->method('resolve')
- ->with($this->requestMock, self::FORM_ID)
- ->willReturn('some_word');
- $this->captchaModelMock->expects($this->once())
- ->method('isCorrect')
- ->with('some_word')
- ->willReturn(true);
- $this->actionFlagMock->expects($this->never())
- ->method('set');
-
- $this->checkGuestCheckoutObserver->execute($this->observer);
- }
-}
diff --git a/app/code/Magento/Captcha/Test/Unit/Observer/CheckRegisterCheckoutObserverTest.php b/app/code/Magento/Captcha/Test/Unit/Observer/CheckRegisterCheckoutObserverTest.php
deleted file mode 100644
index 89012ef653838..0000000000000
--- a/app/code/Magento/Captcha/Test/Unit/Observer/CheckRegisterCheckoutObserverTest.php
+++ /dev/null
@@ -1,211 +0,0 @@
-createMock(Onepage::class);
- $captchaHelperMock = $this->createMock(CaptchaDataHelper::class);
- $this->objectManager = new ObjectManager($this);
- $this->actionFlagMock = $this->createMock(ActionFlag::class);
- $this->captchaStringResolverMock = $this->createMock(CaptchaStringResolver::class);
- $this->captchaModelMock = $this->createMock(CaptchaModel::class);
- $this->quoteModelMock = $this->createMock(Quote::class);
- $this->controllerMock = $this->createMock(Action::class);
- $this->requestMock = $this->createMock(Http::class);
- $this->responseMock = $this->createMock(HttpResponse::class);
- $this->observer = new Observer(['controller_action' => $this->controllerMock]);
- $this->jsonHelperMock = $this->createMock(JsonHelper::class);
-
- $this->checkRegisterCheckoutObserver = $this->objectManager->getObject(
- CheckRegisterCheckoutObserver::class,
- [
- 'helper' => $captchaHelperMock,
- 'actionFlag' => $this->actionFlagMock,
- 'captchaStringResolver' => $this->captchaStringResolverMock,
- 'typeOnepage' => $onepageModelTypeMock,
- 'jsonHelper' => $this->jsonHelperMock
- ]
- );
-
- $captchaHelperMock->expects($this->once())
- ->method('getCaptcha')
- ->with(self::FORM_ID)
- ->willReturn($this->captchaModelMock);
- $onepageModelTypeMock->expects($this->once())
- ->method('getQuote')
- ->willReturn($this->quoteModelMock);
- }
-
- public function testCheckRegisterCheckoutForGuest()
- {
- $this->quoteModelMock->expects($this->once())
- ->method('getCheckoutMethod')
- ->willReturn(Onepage::METHOD_GUEST);
- $this->captchaModelMock->expects($this->never())
- ->method('isRequired');
-
- $this->checkRegisterCheckoutObserver->execute($this->observer);
- }
-
- public function testCheckRegisterCheckoutWithNoCaptchaRequired()
- {
- $this->quoteModelMock->expects($this->once())
- ->method('getCheckoutMethod')
- ->willReturn(Onepage::METHOD_REGISTER);
- $this->captchaModelMock->expects($this->once())
- ->method('isRequired')
- ->willReturn(false);
- $this->captchaModelMock->expects($this->never())
- ->method('isCorrect');
-
- $this->checkRegisterCheckoutObserver->execute($this->observer);
- }
-
- public function testCheckRegisterCheckoutWithIncorrectCaptcha()
- {
- $captchaValue = 'some_word';
- $encodedJsonValue = '{}';
-
- $this->quoteModelMock->expects($this->once())
- ->method('getCheckoutMethod')
- ->willReturn(Onepage::METHOD_REGISTER);
- $this->captchaModelMock->expects($this->once())
- ->method('isRequired')
- ->willReturn(true);
- $this->controllerMock->expects($this->once())
- ->method('getRequest')
- ->willReturn($this->requestMock);
- $this->controllerMock->expects($this->once())
- ->method('getResponse')
- ->willReturn($this->responseMock);
- $this->controllerMock->expects($this->once())
- ->method('getResponse')
- ->willReturn($this->responseMock);
- $this->captchaStringResolverMock->expects($this->once())
- ->method('resolve')
- ->with($this->requestMock, self::FORM_ID)
- ->willReturn($captchaValue);
- $this->captchaModelMock->expects($this->once())
- ->method('isCorrect')
- ->with($captchaValue)
- ->willReturn(false);
- $this->actionFlagMock->expects($this->once())
- ->method('set')
- ->with('', Action::FLAG_NO_DISPATCH, true);
- $this->jsonHelperMock->expects($this->once())
- ->method('jsonEncode')
- ->willReturn($encodedJsonValue);
- $this->responseMock->expects($this->once())
- ->method('representJson')
- ->with($encodedJsonValue);
-
- $this->checkRegisterCheckoutObserver->execute($this->observer);
- }
-
- public function testCheckRegisterCheckoutWithCorrectCaptcha()
- {
- $this->quoteModelMock->expects($this->once())
- ->method('getCheckoutMethod')
- ->willReturn(Onepage::METHOD_REGISTER);
- $this->captchaModelMock->expects($this->once())
- ->method('isRequired')
- ->willReturn(true);
- $this->controllerMock->expects($this->once())
- ->method('getRequest')
- ->willReturn($this->requestMock);
- $this->captchaStringResolverMock->expects($this->once())
- ->method('resolve')
- ->with($this->requestMock, self::FORM_ID)
- ->willReturn('some_word');
- $this->captchaModelMock->expects($this->once())
- ->method('isCorrect')
- ->with('some_word')
- ->willReturn(true);
- $this->actionFlagMock->expects($this->never())
- ->method('set');
-
- $this->checkRegisterCheckoutObserver->execute($this->observer);
- }
-}
diff --git a/app/code/Magento/Captcha/etc/config.xml b/app/code/Magento/Captcha/etc/config.xml
index 71c474de90ff4..dd748dd05ccda 100644
--- a/app/code/Magento/Captcha/etc/config.xml
+++ b/app/code/Magento/Captcha/etc/config.xml
@@ -53,8 +53,6 @@
1
1
- 1
- 1
1
@@ -77,12 +75,6 @@
-
-
-
-
-
-
diff --git a/app/code/Magento/Captcha/etc/di.xml b/app/code/Magento/Captcha/etc/di.xml
index 955896eb12744..3a929f5e6cc00 100644
--- a/app/code/Magento/Captcha/etc/di.xml
+++ b/app/code/Magento/Captcha/etc/di.xml
@@ -33,7 +33,6 @@
- user_login
- - guest_checkout
diff --git a/app/code/Magento/Captcha/etc/events.xml b/app/code/Magento/Captcha/etc/events.xml
index e3ddd19de2d12..970c0d077260c 100644
--- a/app/code/Magento/Captcha/etc/events.xml
+++ b/app/code/Magento/Captcha/etc/events.xml
@@ -18,10 +18,6 @@
-
-
-
-
diff --git a/app/code/Magento/Captcha/etc/frontend/di.xml b/app/code/Magento/Captcha/etc/frontend/di.xml
index 225e62c8e8203..0c4ab0cda0735 100644
--- a/app/code/Magento/Captcha/etc/frontend/di.xml
+++ b/app/code/Magento/Captcha/etc/frontend/di.xml
@@ -17,7 +17,6 @@
- user_login
- - guest_checkout
diff --git a/app/code/Magento/Captcha/view/frontend/layout/checkout_index_index.xml b/app/code/Magento/Captcha/view/frontend/layout/checkout_index_index.xml
index 4ed56fd56cc3a..7180372f004e5 100644
--- a/app/code/Magento/Captcha/view/frontend/layout/checkout_index_index.xml
+++ b/app/code/Magento/Captcha/view/frontend/layout/checkout_index_index.xml
@@ -36,29 +36,7 @@
-
- Magento_Captcha/js/view/checkout/loginCaptcha
- additional-login-form-fields
- - guest_checkout
- - checkoutConfig
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Magento_Captcha/js/view/checkout/loginCaptcha
- - additional-login-form-fields
- - guest_checkout
+ - user_login
- checkoutConfig
diff --git a/app/code/Magento/Captcha/view/frontend/web/onepage.js b/app/code/Magento/Captcha/view/frontend/web/onepage.js
deleted file mode 100644
index 7f5f11d20572b..0000000000000
--- a/app/code/Magento/Captcha/view/frontend/web/onepage.js
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
-
-/**
- * @deprecated since version 2.2.0
- */
-define(['jquery'], function ($) {
- 'use strict';
-
- $(document).on('login', function () {
- var type;
-
- $('[data-captcha="guest_checkout"], [data-captcha="register_during_checkout"]').hide();
- $('[role="guest_checkout"], [role="register_during_checkout"]').hide();
- type = $('#login\\:guest').is(':checked') ? 'guest_checkout' : 'register_during_checkout';
- $('[role="' + type + '"], [data-captcha="' + type + '"]').show();
- }).on('billingSave', function () {
- $('.captcha-reload:visible').trigger('click');
- });
-});