Skip to content

Commit

Permalink
Merge branch '2.4-develop' into mftf-CliIndexerReindexActionGroup-usa…
Browse files Browse the repository at this point in the history
…ge-improvements
  • Loading branch information
engcom-Hotel authored Dec 8, 2020
2 parents 00fa246 + 500a9e5 commit ffa36a2
Show file tree
Hide file tree
Showing 294 changed files with 8,222 additions and 1,101 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
23 changes: 23 additions & 0 deletions app/code/Magento/Bundle/Test/Mftf/Test/AdminAddBundleItemsTest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@
</actionGroup>
<checkOption selector="{{AdminAddProductsToOptionPanel.firstCheckbox}}" stepKey="selectFirstGridRow2"/>
<click selector="{{AdminAddProductsToOptionPanel.addSelectedProducts}}" stepKey="clickAddSelectedBundleProducts"/>
<!-- Check that Bundle Options initialized with default quantity -->
<grabValueFrom selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '0')}}" stepKey="grabbedFirstBundleOptionQuantity"/>
<assertEquals stepKey="assertFirstBundleOptionDefaultQuantity">
<expectedResult type="string">1</expectedResult>
<actualResult type="string">$grabbedFirstBundleOptionQuantity</actualResult>
</assertEquals>
<grabValueFrom selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '1')}}" stepKey="grabbedSecondBundleOptionQuantity"/>
<assertEquals stepKey="assertSecondBundleOptionDefaultQuantity">
<expectedResult type="string">1</expectedResult>
<actualResult type="string">$grabbedSecondBundleOptionQuantity</actualResult>
</assertEquals>

<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '0')}}" userInput="{{BundleProduct.defaultQuantity}}" stepKey="fillProductDefaultQty1"/>
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '1')}}" userInput="{{BundleProduct.defaultQuantity}}" stepKey="fillProductDefaultQty2"/>

Expand Down Expand Up @@ -108,6 +120,17 @@
</actionGroup>
<checkOption selector="{{AdminProductFormBundleSection.firstProductOption}}" stepKey="selectNewFirstGridRow2"/>
<click selector="{{AdminAddProductsToOptionPanel.addSelectedProducts}}" stepKey="clickAddNewSelectedBundleProducts"/>
<!-- Check that existing Bundle Options do not loose user input quantity values -->
<grabValueFrom selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '0')}}" stepKey="grabbedFirstBundleOptionQuantityAfterUserInput"/>
<assertEquals stepKey="assertFirstBundleOptionDefaultQuantityAfterUserInput">
<expectedResult type="string">{{BundleProduct.defaultQuantity}}</expectedResult>
<actualResult type="string">$grabbedFirstBundleOptionQuantityAfterUserInput</actualResult>
</assertEquals>
<grabValueFrom selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '1')}}" stepKey="grabbedSecondBundleOptionQuantityAfterUserInput"/>
<assertEquals stepKey="assertSecondBundleOptionDefaultQuantityAfterUserInput">
<expectedResult type="string">{{BundleProduct.defaultQuantity}}</expectedResult>
<actualResult type="string">$grabbedSecondBundleOptionQuantityAfterUserInput</actualResult>
</assertEquals>
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '2')}}" userInput="{{BundleProduct.defaultQuantity}}" stepKey="fillNewProductDefaultQty1"/>
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity('0', '3')}}" userInput="{{BundleProduct.defaultQuantity}}" stepKey="fillNewProductDefaultQty2"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,26 @@ define([
}
},

/**
* @inheritdoc
*/
setInitialValue: function () {
this.initialValue = this.getInitialValue();

if (this.initialValue === undefined || this.initialValue === '') {
this.initialValue = 1;
}

if (this.value.peek() !== this.initialValue) {
this.value(this.initialValue);
}

this.on('value', this.onUpdate.bind(this));
this.isUseDefault(this.disabled());

return this;
},

/**
* @inheritdoc
*/
Expand All @@ -33,6 +53,5 @@ define([

return !this.visible() ? false : notEqual;
}

});
});
Loading

0 comments on commit ffa36a2

Please sign in to comment.