Skip to content

Commit

Permalink
Merge branch '2.4-develop' of https://github.com/mage-os/mirror-magento2
Browse files Browse the repository at this point in the history
 into 2.4-develop
  • Loading branch information
mage-os-ci committed May 17, 2024
2 parents 387070c + c6bc830 commit 4b280b2
Show file tree
Hide file tree
Showing 66 changed files with 1,442 additions and 242 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln(
'<info>Status: maintenance mode is ' .
($this->maintenanceMode->isOn() ? 'active' : 'not active') . '</info>'
($this->maintenanceMode->isOn() ? 'enabled' : 'disabled') . '</info>'
);
$addressInfo = $this->maintenanceMode->getAddressInfo();
$addresses = implode(' ', $addressInfo);
Expand Down
24 changes: 21 additions & 3 deletions app/code/Magento/Backend/Model/Validator/IpValidator.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<?php

/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Backend\Model\Validator;

use Magento\Framework\App\Utility\IPAddress;

/**
* Class to validate list of IPs for maintenance commands
*/
Expand All @@ -25,12 +29,22 @@ class IpValidator
*/
private $invalidIps;

/**
* @param IPAddress $ipAddress
*/
public function __construct(
private readonly IPAddress $ipAddress,
) {
}

/**
* Validates list of ips
*
* @param string[] $ips
* @param bool $noneAllowed
*
* @return string[]
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function validateIps(array $ips, $noneAllowed)
Expand All @@ -55,22 +69,26 @@ public function validateIps(array $ips, $noneAllowed)
$messages[] = "Invalid IP $invalidIp";
}
}

return $messages;
}

/**
* Filter ips into 'none', valid and invalid ips
*
* @param string[] $ips
*
* @return void
*/
private function filterIps(array $ips)
{
foreach ($ips as $ip) {
if (filter_var($ip, FILTER_VALIDATE_IP)) {
$this->validIps[] = $ip;
} elseif ($ip == 'none') {
if ($ip === 'none') {
$this->none[] = $ip;
} elseif ($this->ipAddress->isValidAddress($ip)) {
$this->validIps[] = $ip;
} elseif ($this->ipAddress->isValidRange($ip)) {
$this->validIps[] = $ip;
} else {
$this->invalidIps[] = $ip;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,20 @@ public function executeDataProvider()
return [
[
[true, ['127.0.0.1', '127.0.0.2']],
'Status: maintenance mode is active' . PHP_EOL .
'Status: maintenance mode is enabled' . PHP_EOL .
'List of exempt IP-addresses: 127.0.0.1 127.0.0.2' . PHP_EOL
],
[
[true, []],
'Status: maintenance mode is active' . PHP_EOL . 'List of exempt IP-addresses: none' . PHP_EOL
'Status: maintenance mode is enabled' . PHP_EOL . 'List of exempt IP-addresses: none' . PHP_EOL
],
[
[false, []],
'Status: maintenance mode is not active' . PHP_EOL . 'List of exempt IP-addresses: none' . PHP_EOL
'Status: maintenance mode is disabled' . PHP_EOL . 'List of exempt IP-addresses: none' . PHP_EOL
],
[
[false, ['127.0.0.1', '127.0.0.2']],
'Status: maintenance mode is not active' . PHP_EOL .
'Status: maintenance mode is disabled' . PHP_EOL .
'List of exempt IP-addresses: 127.0.0.1 127.0.0.2' . PHP_EOL
],
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Magento\Backend\Test\Unit\Model\Validator;

use Magento\Backend\Model\Validator\IpValidator;
use Magento\Framework\App\Utility\IPAddress;
use PHPUnit\Framework\TestCase;

/**
Expand All @@ -25,7 +26,9 @@ class IpValidatorTest extends TestCase
*/
protected function setUp(): void
{
$this->ipValidator = new IpValidator();
$this->ipValidator = new IpValidator(
new IPAddress()
);
}

/**
Expand All @@ -45,6 +48,7 @@ public function validateIpsNoneAllowedDataProvider(): array
{
return [
[['127.0.0.1', '127.0.0.2'], []],
[['127.0.0.0/24'], []],
[['none'], []],
[['none', '127.0.0.1'], ["Multiple values are not allowed when 'none' is used"]],
[['127.0.0.1', 'none'], ["Multiple values are not allowed when 'none' is used"]],
Expand Down Expand Up @@ -72,6 +76,7 @@ public function validateIpsNoneNotAllowedDataProvider()
{
return [
[['127.0.0.1', '127.0.0.2'], []],
[['127.0.0.0/24'], []],
[['none'], ["'none' is not allowed"]],
[['none', '127.0.0.1'], ["'none' is not allowed"]],
[['127.0.0.1', 'none'], ["'none' is not allowed"]],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AdminClickAddOptionForBundleItemsActionGroup">
<annotations>
<description>Click 'Add Option' button for bundle items.</description>
</annotations>

<click selector="{{AdminProductFormBundleSection.addOption}}" stepKey="clickAddOption"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
<actionGroup ref="FilterProductGridByNameActionGroup" stepKey="filterBundleProductOptionsDownToName">
<argument name="product" value="BundleProduct"/>
</actionGroup>

<actionGroup ref="OpenProductForEditByClickingRowXColumnYInProductGridActionGroup" stepKey="clickOnBundleProductToEdit"/>
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="conditionallyOpenSectionBundleItemsToEdit"/>
<actionGroup ref="AdminClickAddOptionOnBundleProductEditPageActionGroup" stepKey="clickAddOption"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<conditionalClick selector="{{AdminProductFormBundleSection.bundleItemsToggle}}" dependentSelector="{{AdminProductFormBundleSection.bundleItemsToggle}}" visible="false" stepKey="conditionallyOpenSectionBundleItems"/>
<!-- scrollTo before click to fix flaky failure -->
<scrollTo selector="{{AdminProductFormBundleSection.addOption}}" stepKey="scrollToAddOption"/>
<click selector="{{AdminProductFormBundleSection.addOption}}" stepKey="clickAddOption3"/>
<actionGroup ref="AdminClickAddOptionForBundleItemsActionGroup" stepKey="clickAddOption3"/>
<waitForElementVisible selector="{{AdminProductFormBundleSection.bundleOptionXTitle('0')}}" stepKey="waitForBundleOptions"/>
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXTitle('0')}}" userInput="{{BundleProduct.optionTitle1}}" stepKey="fillOptionTitle"/>
<selectOption selector="{{AdminProductFormBundleSection.bundleOptionXInputType('0')}}" userInput="{{BundleProduct.optionInputType1}}" stepKey="selectInputType"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForBundleProductCreationPage"/>
<conditionalClick selector="{{AdminProductFormBundleSection.bundleItemsToggle}}" dependentSelector="{{AdminProductFormBundleSection.bundleItemsToggle}}" visible="false" stepKey="conditionallyOpenSectionBundleItems"/>
<click selector="{{AdminProductFormBundleSection.addOption}}" stepKey="clickAddOption3"/>
<actionGroup ref="AdminClickAddOptionForBundleItemsActionGroup" stepKey="clickAddOption3"/>
<waitForElementVisible selector="{{AdminProductFormBundleSection.bundleOptionXTitle('0')}}" stepKey="waitForBundleOptions"/>
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXTitle('0')}}" userInput="{{BundleProduct.optionTitle1}}" stepKey="fillOptionTitle"/>
<selectOption selector="{{AdminProductFormBundleSection.bundleOptionXInputType('0')}}" userInput="{{BundleProduct.optionInputType1}}" stepKey="selectInputType"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForBundleProductCreationPage"/>
<conditionalClick selector="{{AdminProductFormBundleSection.bundleItemsToggle}}" dependentSelector="{{AdminProductFormBundleSection.bundleItemsToggle}}" visible="false" stepKey="conditionallyOpenSectionBundleItems"/>
<click selector="{{AdminProductFormBundleSection.addOption}}" stepKey="clickAddOption3"/>
<actionGroup ref="AdminClickAddOptionForBundleItemsActionGroup" stepKey="clickAddOption3"/>
<waitForElementVisible selector="{{AdminProductFormBundleSection.bundleOptionXTitle('0')}}" stepKey="waitForBundleOptions"/>
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXTitle('0')}}" userInput="{{BundleProduct.optionTitle1}}" stepKey="fillOptionTitle"/>
<selectOption selector="{{AdminProductFormBundleSection.bundleOptionXInputType('0')}}" userInput="{{BundleProduct.optionInputType1}}" stepKey="selectInputType"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForBundleProductCreatePageToLoad"/>

<!--Create bundle product-->

<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="conditionallyOpenSectionBundleItems"/>
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="clickAddOption3"/>
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForBundleOptions"/>
Expand Down Expand Up @@ -88,6 +89,7 @@
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForBundleProductCreatePageToLoad2"/>

<!--Create bundle product 2-->

<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="conditionallyOpenSectionBundleItems2"/>
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="clickAddOption32"/>
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForBundleOptions2"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<conditionalClick selector="{{AdminProductFormBundleSection.bundleItemsToggle}}" dependentSelector="{{AdminProductFormBundleSection.bundleItemsToggle}}" visible="false" stepKey="conditionallyOpenSectionBundleItems"/>
<!-- scrollTo before click to fix flaky failure -->
<scrollTo selector="{{AdminProductFormBundleSection.addOption}}" stepKey="scrollToAddOption"/>
<click selector="{{AdminProductFormBundleSection.addOption}}" stepKey="clickAddOption3"/>
<actionGroup ref="AdminClickAddOptionForBundleItemsActionGroup" stepKey="clickAddOption3"/>
<waitForElementVisible selector="{{AdminProductFormBundleSection.bundleOptionXTitle('0')}}" stepKey="waitForBundleOptions"/>
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXTitle('0')}}" userInput="{{BundleProduct.optionTitle1}}" stepKey="fillOptionTitle"/>
<selectOption selector="{{AdminProductFormBundleSection.bundleOptionXInputType('0')}}" userInput="{{BundleProduct.optionInputType1}}" stepKey="selectInputType"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

<!-- Add two bundle items -->
<conditionalClick selector="{{AdminProductFormBundleSection.bundleItemsToggle}}" dependentSelector="{{AdminProductFormBundleSection.bundleItemsToggle}}" visible="false" stepKey="conditionallyOpenSectionBundleItems"/>
<click selector="{{AdminProductFormBundleSection.addOption}}" stepKey="clickAddOption3"/>
<actionGroup ref="AdminClickAddOptionForBundleItemsActionGroup" stepKey="clickAddOption3"/>
<waitForElementVisible selector="{{AdminProductFormBundleSection.bundleOptionXTitle('0')}}" stepKey="waitForBundleOptions"/>
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXTitle('0')}}" userInput="{{BundleProduct.optionTitle1}}" stepKey="fillOptionTitle"/>
<selectOption selector="{{AdminProductFormBundleSection.bundleOptionXInputType('0')}}" userInput="{{BundleProduct.optionInputType1}}" stepKey="selectInputType"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForBundleProductCreatePageToLoad"/>

<!-- Add two bundle items -->

<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="conditionallyOpenSectionBundleItems"/>
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="clickAddOption3"/>
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForBundleOptions"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<fillField selector="{{AdminProductFormSection.productSku}}" userInput="{{BundleProduct.sku}}" stepKey="fillBundleName" after="goToCreateBundleProduct"/>
<fillField selector="{{AdminProductFormSection.productName}}" userInput="{{BundleProduct.name}}" stepKey="fillBundleSku" after="fillBundleName"/>
<click selector="{{AdminProductFormBundleSection.addOption}}" stepKey="clickAddOption3" after="fillBundleSku"/>
<actionGroup ref="AdminClickAddOptionForBundleItemsActionGroup" stepKey="clickAddOption3" after="fillBundleSku"/>
<waitForElementVisible selector="{{AdminProductFormBundleSection.firstOptionTitle}}" stepKey="waitForBundleOptions" after="clickAddOption3"/>
<fillField selector="{{AdminProductFormBundleSection.firstOptionTitle}}" userInput="{{BundleProduct.optionTitle1}}" stepKey="fillOptionTitle" after="waitForBundleOptions"/>
<selectOption selector="{{AdminProductFormBundleSection.firstInputType}}" userInput="{{BundleProduct.optionInputType1}}" stepKey="selectInputType" after="fillOptionTitle"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

<!--Create bundle product-->
<conditionalClick selector="{{AdminProductFormBundleSection.bundleItemsToggle}}" dependentSelector="{{AdminProductFormBundleSection.bundleItemsToggle}}" visible="false" stepKey="conditionallyOpenSectionBundleItems"/>
<click selector="{{AdminProductFormBundleSection.addOption}}" stepKey="clickAddOption3"/>
<actionGroup ref="AdminClickAddOptionForBundleItemsActionGroup" stepKey="clickAddOption3"/>
<waitForElementVisible selector="{{AdminProductFormBundleSection.bundleOptionXTitle('0')}}" stepKey="waitForBundleOptions"/>
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXTitle('0')}}" userInput="{{BundleProduct.optionTitle1}}" stepKey="fillOptionTitle"/>
<selectOption selector="{{AdminProductFormBundleSection.bundleOptionXInputType('0')}}" userInput="{{BundleProduct.optionInputType1}}" stepKey="selectInputType"/>
Expand Down Expand Up @@ -89,7 +89,7 @@

<!--Create bundle product 2-->
<conditionalClick selector="{{AdminProductFormBundleSection.bundleItemsToggle}}" dependentSelector="{{AdminProductFormBundleSection.bundleItemsToggle}}" visible="false" stepKey="conditionallyOpenSectionBundleItems2"/>
<click selector="{{AdminProductFormBundleSection.addOption}}" stepKey="clickAddOption32"/>
<actionGroup ref="AdminClickAddOptionForBundleItemsActionGroup" stepKey="clickAddOption32"/>
<waitForElementVisible selector="{{AdminProductFormBundleSection.bundleOptionXTitle('0')}}" stepKey="waitForBundleOptions2"/>
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXTitle('0')}}" userInput="{{BundleProduct.optionTitle1}}" stepKey="fillOptionTitle2"/>
<selectOption selector="{{AdminProductFormBundleSection.bundleOptionXInputType('0')}}" userInput="{{BundleProduct.optionInputType1}}" stepKey="selectInputType2"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<!-- and then configure bundled items for this product -->

<scrollTo selector="{{AdminProductFormBundleSection.addOption}}" stepKey="scrollToAddOptionButton"/>
<click selector="{{AdminProductFormBundleSection.addOption}}" stepKey="clickAddOption"/>
<actionGroup ref="AdminClickAddOptionForBundleItemsActionGroup" stepKey="clickAddOption"/>
<waitForPageLoad stepKey="waitForOptions"/>
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXTitle('0')}}" userInput="MFTF Test Bundle 1" stepKey="fillOptionTitle"/>
<selectOption selector="{{AdminProductFormBundleSection.bundleOptionXInputType('0')}}" userInput="checkbox" stepKey="selectInputType"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<!-- Add two bundle items -->
<conditionalClick selector="{{AdminProductFormBundleSection.bundleItemsToggle}}" dependentSelector="{{AdminProductFormBundleSection.bundleItemsToggle}}" visible="false" stepKey="conditionallyOpenSectionBundleItems"/>
<scrollTo stepKey="scrollToBundleItems" selector="{{AdminProductFormBundleSection.bundledItems}}"/>
<click selector="{{AdminProductFormBundleSection.addOption}}" stepKey="clickAddOption3"/>
<actionGroup ref="AdminClickAddOptionForBundleItemsActionGroup" stepKey="clickAddOption3"/>
<waitForElementVisible selector="{{AdminProductFormBundleSection.bundleOptionXTitle('0')}}" stepKey="waitForBundleOptions"/>
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXTitle('0')}}" userInput="{{BundleProduct.optionTitle1}}" stepKey="fillOptionTitle"/>
<selectOption selector="{{AdminProductFormBundleSection.bundleOptionXInputType('0')}}" userInput="{{BundleProduct.optionInputType1}}" stepKey="selectInputType"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

<!-- Add options -->
<conditionalClick selector="{{AdminProductFormBundleSection.bundleItemsToggle}}" dependentSelector="{{AdminProductFormBundleSection.bundleItemsToggle}}" visible="false" stepKey="conditionallyOpenSectionBundleItems"/>
<click selector="{{AdminProductFormBundleSection.addOption}}" stepKey="clickAddOption"/>
<actionGroup ref="AdminClickAddOptionForBundleItemsActionGroup" stepKey="clickAddOption"/>
<waitForElementVisible selector="{{AdminProductFormBundleSection.bundleOptionXTitle('0')}}" stepKey="waitForBundleOptions"/>
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXTitle('0')}}" userInput="{{BundleProduct.optionTitle1}}" stepKey="fillOptionTitle"/>
<selectOption selector="{{AdminProductFormBundleSection.bundleOptionXInputType('0')}}" userInput="{{BundleProduct.optionInputType1}}" stepKey="selectInputType"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

<!--Create bundle product-->
<conditionalClick selector="{{AdminProductFormBundleSection.bundleItemsToggle}}" dependentSelector="{{AdminProductFormBundleSection.bundleItemsToggle}}" visible="false" stepKey="conditionallyOpenSectionBundleItems"/>
<click selector="{{AdminProductFormBundleSection.addOption}}" stepKey="clickAddOption3"/>
<actionGroup ref="AdminClickAddOptionForBundleItemsActionGroup" stepKey="clickAddOption3"/>
<waitForElementVisible selector="{{AdminProductFormBundleSection.bundleOptionXTitle('0')}}" stepKey="waitForBundleOptions"/>
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXTitle('0')}}" userInput="{{BundleProduct.optionTitle1}}" stepKey="fillOptionTitle"/>
<selectOption selector="{{AdminProductFormBundleSection.bundleOptionXInputType('0')}}" userInput="{{BundleProduct.optionInputType1}}" stepKey="selectInputType"/>
Expand Down
Loading

0 comments on commit 4b280b2

Please sign in to comment.