Skip to content

Commit a785704

Browse files
Merge branch '2.4.7-beta1-develop' into cia-2.4.7-beta1-develop-bugfixes-05032023
2 parents f4c3cdc + 3c857e1 commit a785704

File tree

20 files changed

+438
-10
lines changed

20 files changed

+438
-10
lines changed

app/code/Magento/Captcha/Test/Mftf/Test/StorefrontCaptchaOnOnepageCheckoutPyamentTest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<group value="storefront_captcha_enabled"/>
2222
</annotations>
2323
<before>
24+
<magentoCLI command="config:set checkout/options/enable_guest_checkout_login 1" stepKey="EnablingGuestCheckoutLogin"/>
2425
<!-- Create Simple Product -->
2526
<createData entity="SimpleProduct2" stepKey="createSimpleProduct">
2627
<field key="price">20</field>
@@ -62,6 +63,7 @@
6263

6364
<!-- Delete customer -->
6465
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
66+
<magentoCLI command="config:set checkout/options/enable_guest_checkout_login 0" stepKey="DisablingGuestCheckoutLogin"/>
6567
</after>
6668

6769
<!-- Reindex and flush cache -->

app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CAdminTest.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@
1818
<testCaseId value="MAGETWO-87014"/>
1919
<group value="pr_exclude"/>
2020
</annotations>
21+
<before>
22+
<magentoCLI command="config:set checkout/options/enable_guest_checkout_login 1" stepKey="EnablingGuestCheckoutLogin"/>
23+
</before>
2124
<after>
2225
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutOfAdmin"/>
26+
<magentoCLI command="config:set checkout/options/enable_guest_checkout_login 0" stepKey="DisablingGuestCheckoutLogin"/>
2327
</after>
2428

2529
<!--Login to Admin Area-->
2630
<actionGroup ref="AdminLoginActionGroup" stepKey="loginToAdminArea"/>
27-
2831
<!--Admin creates product-->
2932
<!--Create Simple Product-->
3033
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="visitAdminProductPageSimple"/>

app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingDefaultAddressTest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
<group value="mtf_migrated"/>
2121
</annotations>
2222
<before>
23+
<magentoCLI command="config:set checkout/options/enable_guest_checkout_login 1" stepKey="EnablingGuestCheckoutLogin"/>
2324
<!-- Create Simple Product -->
2425
<createData entity="SimpleProduct2" stepKey="createSimpleProduct">
2526
<field key="price">560</field>
2627
</createData>
27-
2828
<!-- Create customer -->
2929
<createData entity="Simple_US_Customer_Multiple_Addresses" stepKey="createCustomer"/>
3030
</before>
@@ -40,6 +40,7 @@
4040

4141
<!-- Delete customer -->
4242
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
43+
<magentoCLI command="config:set checkout/options/enable_guest_checkout_login 0" stepKey="DisablingGuestCheckoutLogin"/>
4344
</after>
4445

4546
<!-- Add Simple Product to cart -->

app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonDefaultAddressTest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<group value="mtf_migrated"/>
2121
</annotations>
2222
<before>
23+
<magentoCLI command="config:set checkout/options/enable_guest_checkout_login 1" stepKey="EnablingGuestCheckoutLogin"/>
2324
<!-- Create Simple Product -->
2425
<createData entity="SimpleProduct2" stepKey="createSimpleProduct">
2526
<field key="price">560</field>
@@ -40,6 +41,7 @@
4041

4142
<!-- Delete customer -->
4243
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
44+
<magentoCLI command="config:set checkout/options/enable_guest_checkout_login 0" stepKey="DisablingGuestCheckoutLogin"/>
4345
</after>
4446

4547
<!-- Add Simple Product to cart -->

app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithSpecialPriceProductsTest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
</annotations>
1919

2020
<before>
21+
<magentoCLI command="config:set checkout/options/enable_guest_checkout_login 1" stepKey="EnablingGuestCheckoutLogin"/>
2122
<actionGroup ref="AdminLoginActionGroup" stepKey="loginToAdminPanel"/>
2223
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
2324
<createData entity="defaultSimpleProduct" stepKey="simpleProduct">
@@ -105,6 +106,7 @@
105106

106107
<!-- Reindex invalidated indices after product attribute has been created/deleted -->
107108
<magentoCron groups="index" stepKey="reindexInvalidatedIndices"/>
109+
<magentoCLI command="config:set checkout/options/enable_guest_checkout_login 0" stepKey="DisablingGuestCheckoutLogin"/>
108110
</after>
109111

110112
<!--Open Product page in StoreFront and assert product and price range -->

app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerLoginDuringCheckoutTest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<group value="OnePageCheckout"/>
2020
</annotations>
2121
<before>
22+
<magentoCLI command="config:set checkout/options/enable_guest_checkout_login 1" stepKey="EnablingGuestCheckoutLogin"/>
2223
<!-- Create simple product -->
2324
<createData entity="SimpleProduct2" stepKey="createProduct"/>
2425

@@ -39,9 +40,9 @@
3940
<actionGroup ref="AdminDeleteCustomerActionGroup" stepKey="deleteCustomer">
4041
<argument name="customerEmail" value="CustomerEntityOne.email"/>
4142
</actionGroup>
42-
4343
<!-- Logout admin -->
4444
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
45+
<magentoCLI command="config:set checkout/options/enable_guest_checkout_login 0" stepKey="DisablingGuestCheckoutLogin"/>
4546
</after>
4647
<!-- Go to Storefront as Guest and create new account -->
4748
<actionGroup ref="StorefrontOpenCustomerAccountCreatePageActionGroup" stepKey="openCreateAccountPage"/>

app/code/Magento/Customer/Test/Mftf/Test/EndToEndB2CLoggedInUserTest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
</skip>
2424
</annotations>
2525
<before>
26+
<magentoCLI command="config:set checkout/options/enable_guest_checkout_login 1" stepKey="EnablingGuestCheckoutLogin"/>
2627
<resetCookie userInput="PHPSESSID" stepKey="resetCookieForCart"/>
2728
<actionGroup ref="AdminLoginActionGroup" after="resetCookieForCart" stepKey="loginAsAdmin"/>
2829
</before>
@@ -32,6 +33,7 @@
3233
<actionGroup ref="DeleteCustomerFromAdminActionGroup" stepKey="deleteCustomerFromAdmin"/>
3334
<actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="clearProductsGridFilters"/>
3435
<actionGroup ref="AdminLogoutActionGroup" stepKey="adminLogout"/>
36+
<magentoCLI command="config:set checkout/options/enable_guest_checkout_login 0" stepKey="DisablingGuestCheckoutLogin"/>
3537
</after>
3638
<!-- Step 0: User signs up an account -->
3739
<comment userInput="Start of signing up user account" stepKey="startOfSigningUpUserAccount" />
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Fedex\Model\Config\Backend;
10+
11+
use Magento\Framework\App\Cache\TypeListInterface;
12+
use Magento\Framework\App\Config\ScopeConfigInterface;
13+
use Magento\Framework\App\Config\Value;
14+
use Magento\Framework\Data\Collection\AbstractDb;
15+
use Magento\Framework\Exception\ValidatorException;
16+
use Magento\Framework\Model\AbstractModel;
17+
use Magento\Framework\Model\Context;
18+
use Magento\Framework\Model\ResourceModel\AbstractResource;
19+
use Magento\Framework\Registry;
20+
use Magento\Framework\Validator\Url;
21+
22+
/**
23+
* Represents a config URL that may point to a Fedex endpoint
24+
*/
25+
class FedexUrl extends Value
26+
{
27+
/**
28+
* @var Url
29+
*/
30+
private Url $url;
31+
/**
32+
* @param Context $context
33+
* @param Registry $registry
34+
* @param ScopeConfigInterface $config
35+
* @param TypeListInterface $cacheTypeList
36+
* @param AbstractResource|null $resource
37+
* @param AbstractDb|null $resourceCollection
38+
* @param Url $url
39+
* @param array $data
40+
*/
41+
public function __construct(
42+
Context $context,
43+
Registry $registry,
44+
ScopeConfigInterface $config,
45+
TypeListInterface $cacheTypeList,
46+
AbstractResource $resource = null,
47+
AbstractDb $resourceCollection = null,
48+
Url $url,
49+
array $data = []
50+
) {
51+
parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
52+
$this->url = $url;
53+
}
54+
55+
/**
56+
* @inheritDoc
57+
*
58+
* @return AbstractModel
59+
* @throws ValidatorException
60+
*/
61+
public function beforeSave(): AbstractModel
62+
{
63+
$isValid = $this->url->isValid($this->getValue(), ['http', 'https']);
64+
65+
if ($isValid) {
66+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
67+
$host = parse_url((string)$this->getValue(), \PHP_URL_HOST);
68+
69+
if (!empty($host) && !preg_match('/(?:.+\.|^)fedex\.com$/i', $host)) {
70+
throw new ValidatorException(__('Fedex API endpoint URL\'s must use fedex.com'));
71+
}
72+
}
73+
74+
return parent::beforeSave();
75+
}
76+
}
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Fedex\Test\Unit\Model\Config\Backend;
10+
11+
use Magento\Fedex\Model\Config\Backend\FedexUrl;
12+
use Magento\Framework\App\Cache\TypeListInterface;
13+
use Magento\Framework\App\Config\ScopeConfigInterface;
14+
use Magento\Framework\Data\Collection\AbstractDb;
15+
use Magento\Framework\Event\ManagerInterface;
16+
use Magento\Framework\Exception\ValidatorException;
17+
use Magento\Framework\Model\Context;
18+
use Magento\Framework\Registry;
19+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
20+
use Magento\Framework\Validator\Url;
21+
use Magento\Rule\Model\ResourceModel\AbstractResource;
22+
use PHPUnit\Framework\MockObject\MockObject;
23+
use PHPUnit\Framework\TestCase;
24+
25+
/**
26+
* Verify behavior of FedexUrl backend type
27+
*/
28+
class FedexUrlTest extends TestCase
29+
{
30+
31+
/**
32+
* @var FedexUrl
33+
*/
34+
private $urlConfig;
35+
36+
/**
37+
* @var Url
38+
*/
39+
private $url;
40+
41+
/**
42+
* @var Context|MockObject
43+
*/
44+
private $contextMock;
45+
46+
protected function setUp(): void
47+
{
48+
$objectManager = new ObjectManager($this);
49+
$this->contextMock = $this->createMock(Context::class);
50+
$registry = $this->createMock(Registry::class);
51+
$config = $this->createMock(ScopeConfigInterface::class);
52+
$cacheTypeList = $this->createMock(TypeListInterface::class);
53+
$this->url = $this->createMock(Url::class);
54+
$resource = $this->createMock(AbstractResource::class);
55+
$resourceCollection = $this->createMock(AbstractDb::class);
56+
$eventManagerMock = $this->getMockForAbstractClass(ManagerInterface::class);
57+
$eventManagerMock->expects($this->any())->method('dispatch');
58+
$this->contextMock->expects($this->any())->method('getEventDispatcher')->willReturn($eventManagerMock);
59+
60+
$this->urlConfig = $objectManager->getObject(
61+
FedexUrl::class,
62+
[
63+
'url' => $this->url,
64+
'context' => $this->contextMock,
65+
'registry' => $registry,
66+
'config' => $config,
67+
'cacheTypeList' => $cacheTypeList,
68+
'resource' => $resource,
69+
'resourceCollection' => $resourceCollection,
70+
]
71+
);
72+
}
73+
74+
/**
75+
* @dataProvider validDataProvider
76+
* @param string|null $data The valid data
77+
* @throws ValidatorException
78+
*/
79+
public function testBeforeSave(string $data = null): void
80+
{
81+
$this->url->expects($this->any())->method('isValid')->willReturn(true);
82+
$this->urlConfig->setValue($data);
83+
$this->urlConfig->beforeSave();
84+
$this->assertTrue($this->url->isValid($data));
85+
}
86+
87+
/**
88+
* @dataProvider invalidDataProvider
89+
* @param string $data The invalid data
90+
*/
91+
public function testBeforeSaveErrors(string $data): void
92+
{
93+
$this->url->expects($this->any())->method('isValid')->willReturn(true);
94+
$this->expectException('Magento\Framework\Exception\ValidatorException');
95+
$this->expectExceptionMessage('Fedex API endpoint URL\'s must use fedex.com');
96+
$this->urlConfig->setValue($data);
97+
$this->urlConfig->beforeSave();
98+
}
99+
100+
/**
101+
* Validator Data Provider
102+
*
103+
* @return array
104+
*/
105+
public function validDataProvider(): array
106+
{
107+
return [
108+
[],
109+
[null],
110+
[''],
111+
['http://fedex.com'],
112+
['https://foo.fedex.com'],
113+
['http://foo.fedex.com/foo/bar?baz=bash&fizz=buzz'],
114+
];
115+
}
116+
117+
/**
118+
* @return \string[][]
119+
*/
120+
public function invalidDataProvider(): array
121+
{
122+
return [
123+
['http://fedexfoo.com'],
124+
['https://foofedex.com'],
125+
['https://fedex.com.fake.com'],
126+
['https://fedex.info'],
127+
['http://fedex.com.foo.com/foo/bar?baz=bash&fizz=buzz'],
128+
['http://foofedex.com/foo/bar?baz=bash&fizz=buzz'],
129+
];
130+
}
131+
}

app/code/Magento/Fedex/etc/adminhtml/system.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@
4040
</field>
4141
<field id="production_webservices_url" translate="label" type="text" sortOrder="90" showInDefault="1" showInWebsite="1" canRestore="1">
4242
<label>Web-Services URL (Production)</label>
43+
<backend_model>Magento\Fedex\Model\Config\Backend\FedexUrl</backend_model>
4344
<depends>
4445
<field id="sandbox_mode">0</field>
4546
</depends>
4647
</field>
4748
<field id="sandbox_webservices_url" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" canRestore="1">
4849
<label>Web-Services URL (Sandbox)</label>
50+
<backend_model>Magento\Fedex\Model\Config\Backend\FedexUrl</backend_model>
4951
<depends>
5052
<field id="sandbox_mode">1</field>
5153
</depends>

0 commit comments

Comments
 (0)