Skip to content

Commit

Permalink
Merge branch '2.4-develop-mainline' into ref-QuickSearch
Browse files Browse the repository at this point in the history
# Conflicts:
#	app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductTieredPriceTest.xml
#	app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockNotVisibleIndividuallyTest.xml
#	app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockVisibleInCatalogAndSearchTest.xml
#	app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockVisibleInCatalogOnlyTest.xml
#	app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockVisibleInSearchOnlyTest.xml
#	app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceOutOfStockTest.xml
  • Loading branch information
engcom-Foxtrot committed Dec 22, 2020
2 parents 631dc30 + 661c15c commit a675e9f
Show file tree
Hide file tree
Showing 758 changed files with 22,717 additions and 5,316 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,46 @@

<waitForPageLoad stepKey="waitForPageReloaded"/>
<seeInPageSource html="var adminAnalyticsMetadata =" stepKey="seeInPageSource"/>
<grabPageSource stepKey="pageSource"/>
<assertRegExp message="adminAnalyticsMetadata object is invalid" stepKey="validateadminAnalyticsMetadata">
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?("[\w_]+":\s+"[^"]*?"\s+)};#s</expectedResult>
<actualResult type="variable">$pageSource</actualResult>
</assertRegExp>
<assertRegExp message="adminAnalyticsMetadata object contains incorrect user ID" stepKey="validateUserId">
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?"user":\s+"[\w\d]{64}"#s</expectedResult>
<actualResult type="variable">$pageSource</actualResult>
</assertRegExp>
<assertRegExp message="adminAnalyticsMetadata object contains incorrect secure base URL" stepKey="validateSecureBaseURL">
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?"secure_base_url":\s+"http(s)?\\\\u003A\\\\u002F\\\\u002F.+?\\\\u002F"#s</expectedResult>
<actualResult type="variable">$pageSource</actualResult>
</assertRegExp>
<assertRegExp message="adminAnalyticsMetadata object contains incorrect product version" stepKey="validateProductVersion">
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?"version":\s+"[^\s]+"#s</expectedResult>
<actualResult type="variable">$pageSource</actualResult>
</assertRegExp>
<assertRegExp message="adminAnalyticsMetadata object contains incorrect product edition" stepKey="validateProductEdition">
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?"product_edition":\s+"(Community|Enterprise|B2B)"#s</expectedResult>
<actualResult type="variable">$pageSource</actualResult>
</assertRegExp>
<assertRegExp message="adminAnalyticsMetadata object contains incorrect application mode" stepKey="validateApplicationMode">
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?"mode":\s+"default|developer|production"#s</expectedResult>
<actualResult type="variable">$pageSource</actualResult>
</assertRegExp>
<assertRegExp message="adminAnalyticsMetadata object contains incorrect store name" stepKey="validateStoreName">
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?"store_name_default":\s+".*?"#s</expectedResult>
<actualResult type="variable">$pageSource</actualResult>
</assertRegExp>
<assertRegExp message="adminAnalyticsMetadata object contains incorrect admin user created date" stepKey="validateAdminUserCreatedDate">
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?"admin_user_created":\s+".+?"#s</expectedResult>
<actualResult type="variable">$pageSource</actualResult>
</assertRegExp>
<assertRegExp message="adminAnalyticsMetadata object contains incorrect admin user log date" stepKey="validateAdminUserLogDate">
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?"admin_user_logdate":\s+".+?"#s</expectedResult>
<actualResult type="variable">$pageSource</actualResult>
</assertRegExp>
<assertRegExp message="adminAnalyticsMetadata object contains incorrect admin user role name" stepKey="validateAdminUserRoleName">
<expectedResult type="string">#var\s+adminAnalyticsMetadata\s+=\s+{\s+("[\w_]+":\s+"[^"]*?",\s+)*?"admin_user_role_name":\s+".+?"#s</expectedResult>
<actualResult type="variable">$pageSource</actualResult>
</assertRegExp>
</test>
</tests>
87 changes: 85 additions & 2 deletions app/code/Magento/AdminAnalytics/ViewModel/Metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Magento\AdminAnalytics\ViewModel;

use Magento\Config\Model\Config\Backend\Admin\Custom;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\ProductMetadataInterface;
use Magento\Backend\Model\Auth\Session;
use Magento\Framework\App\State;
use Magento\Framework\View\Element\Block\ArgumentInterface;
use Magento\Store\Model\Information;

/**
* Gets user version and mode
Expand All @@ -30,19 +36,27 @@ class Metadata implements ArgumentInterface
*/
private $productMetadata;

/**
* @var ScopeConfigInterface
*/
private $config;

/**
* @param ProductMetadataInterface $productMetadata
* @param Session $authSession
* @param State $appState
* @param ScopeConfigInterface $config
*/
public function __construct(
ProductMetadataInterface $productMetadata,
Session $authSession,
State $appState
State $appState,
ScopeConfigInterface $config
) {
$this->productMetadata = $productMetadata;
$this->authSession = $authSession;
$this->appState = $appState;
$this->config = $config;
}

/**
Expand All @@ -55,15 +69,26 @@ public function getMagentoVersion() :string
return $this->productMetadata->getVersion();
}

/**
* Get product edition
*
* @return string
*/
public function getProductEdition(): string
{
return $this->productMetadata->getEdition();
}

/**
* Get current user id (hash generated from email)
*
* @return string
*/
public function getCurrentUser() :string
{
return hash('sha512', 'ADMIN_USER' . $this->authSession->getUser()->getEmail());
return hash('sha256', 'ADMIN_USER' . $this->authSession->getUser()->getEmail());
}

/**
* Get Magento mode that the user is using
*
Expand All @@ -73,4 +98,62 @@ public function getMode() :string
{
return $this->appState->getMode();
}

/**
* Get created date for current user
*
* @return string
*/
public function getCurrentUserCreatedDate(): string
{
return $this->authSession->getUser()->getCreated();
}

/**
* Get log date for current user
*
* @return string|null
*/
public function getCurrentUserLogDate(): ?string
{
return $this->authSession->getUser()->getLogdate();
}

/**
* Get secure base URL
*
* @param string $scope
* @param string|null $scopeCode
* @return string|null
*/
public function getSecureBaseUrlForScope(
string $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
?string $scopeCode = null
): ?string {
return $this->config->getValue(Custom::XML_PATH_SECURE_BASE_URL, $scope, $scopeCode);
}

/**
* Get store name
*
* @param string $scope
* @param string|null $scopeCode
* @return string|null
*/
public function getStoreNameForScope(
string $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
?string $scopeCode = null
): ?string {
return $this->config->getValue(Information::XML_PATH_STORE_INFO_NAME, $scope, $scopeCode);
}

/**
* Get current user role name
*
* @return string
*/
public function getCurrentUserRoleName(): string
{
return $this->authSession->getUser()->getRole()->getRoleName();
}
}
1 change: 1 addition & 0 deletions app/code/Magento/AdminAnalytics/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"magento/framework": "*",
"magento/module-backend": "*",
"magento/module-config": "*",
"magento/module-store": "*",
"magento/module-ui": "*",
"magento/module-release-notification": "*"
},
Expand Down
39 changes: 39 additions & 0 deletions app/code/Magento/AdminAnalytics/etc/adminhtml/csp_whitelist.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<csp_whitelist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Csp:etc/csp_whitelist.xsd">
<policies>
<policy id="script-src">
<values>
<value id="aptrinsic" type="host">*.aptrinsic.com</value>
</values>
</policy>
<policy id="style-src">
<values>
<value id="aptrinsic" type="host">*.aptrinsic.com</value>
<value id="fonts_googleapis" type="host">fonts.googleapis.com</value>
</values>
</policy>
<policy id="img-src">
<values>
<value id="aptrinsic" type="host">*.aptrinsic.com</value>
<value id="storage_googleapis" type="host">storage.googleapis.com</value>
</values>
</policy>
<policy id="connect-src">
<values>
<value id="aptrinsic" type="host">*.aptrinsic.com</value>
</values>
</policy>
<policy id="font-src">
<values>
<value id="fonts_gstatic" type="host">fonts.gstatic.com</value>
</values>
</policy>
</policies>
</csp_whitelist>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<referenceContainer name="header">
<block name="tracking" as="tracking" template="Magento_AdminAnalytics::tracking.phtml" ifconfig="admin/usage/enabled">
<arguments>
<argument name="tracking_url" xsi:type="string">//assets.adobedtm.com/launch-EN30eb7ffa064444f1b8b0368ef38fd3a9.min.js</argument>
<argument name="tracking_url" xsi:type="string">//assets.adobedtm.com/a7d65461e54e/37baabec1b6e/launch-177bc126c8e6.min.js</argument>
<argument name="metadata" xsi:type="object">Magento\AdminAnalytics\ViewModel\Metadata</argument>
</arguments>
</block>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,20 @@
false
) ?>

<?php $scriptString = '
<?php
/** @var \Magento\AdminAnalytics\ViewModel\Metadata $metadata */
$metadata = $block->getMetadata();
$scriptString = '
var adminAnalyticsMetadata = {
"version": "' . $block->escapeJs($block->getMetadata()->getMagentoVersion()) . '",
"user": "' . $block->escapeJs($block->getMetadata()->getCurrentUser()) . '",
"mode": "' . $block->escapeJs($block->getMetadata()->getMode()) . '"
"secure_base_url": "' . $block->escapeJs($metadata->getSecureBaseUrlForScope()) . '",
"version": "' . $block->escapeJs($metadata->getMagentoVersion()) . '",
"product_edition": "' . $block->escapeJs($metadata->getProductEdition()) . '",
"user": "' . $block->escapeJs($metadata->getCurrentUser()) . '",
"mode": "' . $block->escapeJs($metadata->getMode()) . '",
"store_name_default": "' . $block->escapeJs($metadata->getStoreNameForScope()) . '",
"admin_user_created": "' . $block->escapeJs($metadata->getCurrentUserCreatedDate()) . '",
"admin_user_logdate": "' . $block->escapeJs($metadata->getCurrentUserLogDate()) . '",
"admin_user_role_name": "' . $block->escapeJs($metadata->getCurrentUserRoleName()) . '"
};
';
?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,8 @@ private function fetchTierPrices(array $productIds): array
)
->where(
'ap.' . $productEntityLinkField . ' IN (?)',
$productIds
$productIds,
\Zend_Db::INT_TYPE
);

if ($priceFromFilter !== null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AwsS3StorefrontCaptchaOnCustomerLoginTest" extends="StorefrontCaptchaOnCustomerLoginTest">
<annotations>
<features value="Captcha"/>
<stories value="Login with Customer Account + Captcha"/>
<title value="AWS S3 Captcha customer login page test"/>
<description value="Check CAPTCHA on Storefront Login Page."/>
<severity value="MAJOR"/>
<testCaseId value="MC-39491" />
<group value="remote_storage_aws_s3"/>
</annotations>
<before>
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.enable_options}}" stepKey="enableRemoteStorage"/>
</before>
<after>
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.disable_options}}" stepKey="disableRemoteStorage"/>
</after>
</test>
</tests>
2 changes: 1 addition & 1 deletion app/code/Magento/AwsS3/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "magento/module-aws-s-3",
"name": "magento/module-aws-s3",
"description": "N/A",
"config": {
"sort-packages": true
Expand Down
8 changes: 7 additions & 1 deletion app/code/Magento/Backend/App/Area/FrontNameResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,13 @@ public function isHostBackend()
if ($this->scopeConfig->getValue(self::XML_PATH_USE_CUSTOM_ADMIN_URL, ScopeInterface::SCOPE_STORE)) {
$backendUrl = $this->scopeConfig->getValue(self::XML_PATH_CUSTOM_ADMIN_URL, ScopeInterface::SCOPE_STORE);
} else {
$backendUrl = $this->scopeConfig->getValue(Store::XML_PATH_UNSECURE_BASE_URL, ScopeInterface::SCOPE_STORE);
$backendUrl = $this->config->getValue(Store::XML_PATH_UNSECURE_BASE_URL);
if ($backendUrl === null) {
$backendUrl = $this->scopeConfig->getValue(
Store::XML_PATH_UNSECURE_BASE_URL,
ScopeInterface::SCOPE_STORE
);
}
}
$host = $this->request->getServer('HTTP_HOST', '');
return stripos($this->getHostWithPort($backendUrl), (string) $host) !== false;
Expand Down
5 changes: 4 additions & 1 deletion app/code/Magento/Backend/Block/Widget/Button.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
*/
namespace Magento\Backend\Block\Widget;

use Magento\Backend\Block\Template\Context;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Math\Random;
use Magento\Backend\Block\Template\Context;
use Magento\Framework\View\Helper\SecureHtmlRenderer;

/**
Expand Down Expand Up @@ -125,6 +125,9 @@ protected function _prepareAttributes($title, $classes, $disabled)
'value' => $this->getValue(),
'disabled' => $disabled,
];
if ($this->hasData('onclick_attribute')) {
$attributes['onclick'] = $this->getData('onclick_attribute');
}
if ($this->hasData('backend_button_widget_hook_id')) {
$attributes['backend-button-widget-hook-id'] = $this->getData('backend_button_widget_hook_id');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?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="AssertLinkActionGroup">
<annotations>
<description>Assert text and url of the links.</description>
</annotations>
<arguments>
<argument name="text" type="string"/>
<argument name="url" type="string"/>
</arguments>

<seeLink userInput="{{text}}" url="{{url}}" stepKey="assertLinks"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<after>
<!-- 6. Restore default configuration settings. -->
<magentoCLI command="config:set {{DefaultWebCookieLifetimeConfigData.path}} {{DefaultWebCookieLifetimeConfigData.value}}" stepKey="setDefaultCookieLifetime"/>
<!-- Customer Log Out -->
<actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="customerLogout"/>
<!-- Delete data -->
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
Expand Down
Loading

0 comments on commit a675e9f

Please sign in to comment.