Skip to content

Commit

Permalink
Merge branch '2.4-develop' into 30936-cms-perfomance
Browse files Browse the repository at this point in the history
  • Loading branch information
engcom-Charlie committed Dec 11, 2020
2 parents cdecd30 + b941603 commit 17316ae
Show file tree
Hide file tree
Showing 287 changed files with 12,124 additions and 3,657 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
@@ -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
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

use Magento\Bundle\Helper\Catalog\Product\Configuration;
use Magento\Catalog\Model\Product;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\GraphQl\Query\Uid;
use Magento\Quote\Model\Quote\Item;
use Magento\Framework\Pricing\Helper\Data;
use Magento\Framework\Serialize\SerializerInterface;
Expand All @@ -18,6 +20,11 @@
*/
class BundleOptionDataProvider
{
/**
* Option type name
*/
private const OPTION_TYPE = 'bundle';

/**
* @var Data
*/
Expand All @@ -33,19 +40,26 @@ class BundleOptionDataProvider
*/
private $configuration;

/** @var Uid */
private $uidEncoder;

/**
* @param Data $pricingHelper
* @param SerializerInterface $serializer
* @param Configuration $configuration
* @param Uid|null $uidEncoder
*/
public function __construct(
Data $pricingHelper,
SerializerInterface $serializer,
Configuration $configuration
Configuration $configuration,
Uid $uidEncoder = null
) {
$this->pricingHelper = $pricingHelper;
$this->serializer = $serializer;
$this->configuration = $configuration;
$this->uidEncoder = $uidEncoder ?: ObjectManager::getInstance()
->get(Uid::class);
}

/**
Expand Down Expand Up @@ -103,6 +117,7 @@ private function buildBundleOptions(array $bundleOptions, Item $item): array

$options[] = [
'id' => $bundleOption->getId(),
'uid' => $this->uidEncoder->encode(self::OPTION_TYPE . '/' . $bundleOption->getId()),
'label' => $bundleOption->getTitle(),
'type' => $bundleOption->getType(),
'values' => $this->buildBundleOptionValues($bundleOption->getSelections(), $item),
Expand Down Expand Up @@ -131,9 +146,15 @@ private function buildBundleOptionValues(array $selections, Item $item): array
}

$selectionPrice = $this->configuration->getSelectionFinalPrice($item, $selection);

$optionDetails = [
self::OPTION_TYPE,
$selection->getData('option_id'),
$selection->getData('selection_id'),
(int) $selection->getData('selection_qty')
];
$values[] = [
'id' => $selection->getSelectionId(),
'uid' => $this->uidEncoder->encode(implode('/', $optionDetails)),
'label' => $selection->getName(),
'quantity' => $qty,
'price' => $this->pricingHelper->currency($selectionPrice, false, false),
Expand Down
Loading

0 comments on commit 17316ae

Please sign in to comment.