Skip to content

Commit c0c7bed

Browse files
Indrani SonawaneIndrani Sonawane
Indrani Sonawane
authored and
Indrani Sonawane
committed
Merged latest codebase
2 parents 4e3a399 + 91cb4d4 commit c0c7bed

File tree

2,714 files changed

+31581
-12967
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,714 files changed

+31581
-12967
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ trim_trailing_whitespace = false
1414
[*.{yml,yaml,json}]
1515
indent_size = 2
1616

17-
[{composer, auth}.json]
17+
[{composer,auth}.json]
1818
indent_size = 4
1919

2020
[db_schema_whitelist.json]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CloseAllDialogBoxes
2+
SelectAdminUsageSetting

app/code/Magento/AdminAnalytics/ViewModel/Metadata.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
namespace Magento\AdminAnalytics\ViewModel;
1010

1111
use Magento\Config\Model\Config\Backend\Admin\Custom;
12+
use Magento\Csp\Helper\CspNonceProvider;
1213
use Magento\Framework\App\Config\ScopeConfigInterface;
14+
use Magento\Framework\App\ObjectManager;
1315
use Magento\Framework\App\ProductMetadataInterface;
1416
use Magento\Backend\Model\Auth\Session;
1517
use Magento\Framework\App\State;
@@ -21,6 +23,11 @@
2123
*/
2224
class Metadata implements ArgumentInterface
2325
{
26+
/**
27+
* @var string
28+
*/
29+
private $nonce;
30+
2431
/**
2532
* @var State
2633
*/
@@ -41,22 +48,33 @@ class Metadata implements ArgumentInterface
4148
*/
4249
private $config;
4350

51+
/**
52+
* @var CspNonceProvider
53+
*/
54+
private $nonceProvider;
55+
4456
/**
4557
* @param ProductMetadataInterface $productMetadata
4658
* @param Session $authSession
4759
* @param State $appState
4860
* @param ScopeConfigInterface $config
61+
* @param CspNonceProvider|null $nonceProvider
4962
*/
5063
public function __construct(
5164
ProductMetadataInterface $productMetadata,
5265
Session $authSession,
5366
State $appState,
54-
ScopeConfigInterface $config
67+
ScopeConfigInterface $config,
68+
CspNonceProvider $nonceProvider = null
5569
) {
5670
$this->productMetadata = $productMetadata;
5771
$this->authSession = $authSession;
5872
$this->appState = $appState;
5973
$this->config = $config;
74+
75+
$this->nonceProvider = $nonceProvider ?: ObjectManager::getInstance()->get(CspNonceProvider::class);
76+
77+
$this->nonce = $this->nonceProvider->generateNonce();
6078
}
6179

6280
/**
@@ -156,4 +174,14 @@ public function getCurrentUserRoleName(): string
156174
{
157175
return $this->authSession->getUser()->getRole()->getRoleName();
158176
}
177+
178+
/**
179+
* Get a random nonce for each request.
180+
*
181+
* @return string
182+
*/
183+
public function getNonce(): string
184+
{
185+
return $this->nonce;
186+
}
159187
}

app/code/Magento/AdminAnalytics/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"magento/module-config": "*",
1212
"magento/module-store": "*",
1313
"magento/module-ui": "*",
14-
"magento/module-release-notification": "*"
14+
"magento/module-release-notification": "*",
15+
"magento/module-csp": "*"
1516
},
1617
"type": "magento2-module",
1718
"license": [

app/code/Magento/AdminAnalytics/view/adminhtml/templates/tracking.phtml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
/**
88
* @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer
9+
* @var \Magento\Framework\Escaper $escaper
910
*/
1011
?>
1112

@@ -22,18 +23,25 @@
2223
<?php
2324
/** @var \Magento\AdminAnalytics\ViewModel\Metadata $metadata */
2425
$metadata = $block->getMetadata();
26+
$nonce = $escaper->escapeJs($metadata->getNonce());
2527
$scriptString = '
2628
var adminAnalyticsMetadata = {
27-
"secure_base_url": "' . $block->escapeJs($metadata->getSecureBaseUrlForScope()) . '",
28-
"version": "' . $block->escapeJs($metadata->getMagentoVersion()) . '",
29-
"product_edition": "' . $block->escapeJs($metadata->getProductEdition()) . '",
30-
"user": "' . $block->escapeJs($metadata->getCurrentUser()) . '",
31-
"mode": "' . $block->escapeJs($metadata->getMode()) . '",
32-
"store_name_default": "' . $block->escapeJs($metadata->getStoreNameForScope()) . '",
33-
"admin_user_created": "' . $block->escapeJs($metadata->getCurrentUserCreatedDate()) . '",
34-
"admin_user_logdate": "' . $block->escapeJs($metadata->getCurrentUserLogDate()) . '",
35-
"admin_user_role_name": "' . $block->escapeJs($metadata->getCurrentUserRoleName()) . '"
29+
"secure_base_url": "' . $escaper->escapeJs($metadata->getSecureBaseUrlForScope()) . '",
30+
"version": "' . $escaper->escapeJs($metadata->getMagentoVersion()) . '",
31+
"product_edition": "' . $escaper->escapeJs($metadata->getProductEdition()) . '",
32+
"user": "' . $escaper->escapeJs($metadata->getCurrentUser()) . '",
33+
"mode": "' . $escaper->escapeJs($metadata->getMode()) . '",
34+
"store_name_default": "' . $escaper->escapeJs($metadata->getStoreNameForScope()) . '",
35+
"admin_user_created": "' . $escaper->escapeJs($metadata->getCurrentUserCreatedDate()) . '",
36+
"admin_user_logdate": "' . $escaper->escapeJs($metadata->getCurrentUserLogDate()) . '",
37+
"admin_user_role_name": "' . $escaper->escapeJs($metadata->getCurrentUserRoleName()) . '"
3638
};
39+
40+
var digitalData = {
41+
"nonce": "' . $nonce . '"
42+
};
43+
44+
var cspNonce = "' . $nonce . '";
3745
';
3846
?>
3947
<?= /* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false); ?>

app/code/Magento/AdminNotification/Test/Unit/Observer/PredispatchAdminActionControllerObserverTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,17 @@ protected function setUp(): void
6868

6969
$this->backendAuthSessionMock = $this->getMockBuilder(Session::class)
7070
->disableOriginalConstructor()
71-
->setMethods(['isLoggedIn'])
71+
->onlyMethods(['isLoggedIn'])
7272
->getMock();
7373

7474
$this->feedMock = $this->getMockBuilder(Feed::class)
7575
->disableOriginalConstructor()
76-
->setMethods(['checkUpdate'])
76+
->onlyMethods(['checkUpdate'])
7777
->getMock();
7878

7979
$this->feedFactoryMock = $this->getMockBuilder(FeedFactory::class)
8080
->disableOriginalConstructor()
81-
->setMethods(['create'])
81+
->onlyMethods(['create'])
8282
->getMock();
8383

8484
$this->observer = $this->objectManager->getObject(

app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected function setUp(): void
5454
{
5555
$this->groupRepository = $this->getMockBuilder(GroupRepositoryInterface::class)
5656
->disableOriginalConstructor()
57-
->setMethods(['getList'])
57+
->onlyMethods(['getList'])
5858
->getMockForAbstractClass();
5959

6060
$this->searchCriteriaBuilder = $this->createMock(SearchCriteriaBuilder::class);
@@ -65,7 +65,7 @@ protected function setUp(): void
6565
$this->tierPrice = $this->getMockBuilder(
6666
TierPrice::class
6767
)
68-
->setMethods(['isValidValueAndLength', 'hasEmptyColumns', '_addMessages'])
68+
->onlyMethods(['isValidValueAndLength', 'hasEmptyColumns', '_addMessages'])
6969
->setConstructorArgs([$this->groupRepository, $this->searchCriteriaBuilder, $this->storeResolver])
7070
->getMock();
7171
}
@@ -87,7 +87,7 @@ public function testInitInternalCalls()
8787

8888
$groupTest = $this->getMockBuilder(GroupInterface::class)
8989
->disableOriginalConstructor()
90-
->setMethods(['getCode', 'getId'])
90+
->onlyMethods(['getCode', 'getId'])
9191
->getMockForAbstractClass();
9292
$groupTest->expects($this->once())->method('getCode');
9393
$groupTest->method('getId');
@@ -114,7 +114,7 @@ public function testInitAddToCustomerGroups()
114114

115115
$groupTest = $this->getMockBuilder(GroupInterface::class)
116116
->disableOriginalConstructor()
117-
->setMethods(['getCode', 'getId'])
117+
->onlyMethods(['getCode', 'getId'])
118118
->getMockForAbstractClass();
119119

120120
$expectedCode = 'code';
@@ -184,7 +184,7 @@ public function testIsValidAddMessagesCall($value, $hasEmptyColumns, $customerGr
184184

185185
$groupTest = $this->getMockBuilder(GroupInterface::class)
186186
->disableOriginalConstructor()
187-
->setMethods(['getCode', 'getId'])
187+
->onlyMethods(['getCode', 'getId'])
188188
->getMockForAbstractClass();
189189
$groupTest->expects($this->once())->method('getCode');
190190
$groupTest->method('getId');
@@ -198,7 +198,7 @@ public function testIsValidAddMessagesCall($value, $hasEmptyColumns, $customerGr
198198
/**
199199
* @return array
200200
*/
201-
public function isValidResultFalseDataProvider()
201+
public static function isValidResultFalseDataProvider()
202202
{
203203
return [
204204
// First if condition cases.
@@ -306,7 +306,7 @@ public function isValidResultFalseDataProvider()
306306
/**
307307
* @return array
308308
*/
309-
public function isValidAddMessagesCallDataProvider()
309+
public static function isValidAddMessagesCallDataProvider()
310310
{
311311
return [
312312
// First if condition cases.

app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function testIsValid(array $value, $expectedResult)
5151
*
5252
* @return array
5353
*/
54-
public function isValidDataProvider()
54+
public static function isValidDataProvider()
5555
{
5656
return [
5757
[

app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/WebsiteTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class WebsiteTest extends TestCase
4040
protected function setUp(): void
4141
{
4242
$this->webSiteModel = $this->getMockBuilder(Website::class)
43-
->setMethods(['getBaseCurrency'])
43+
->onlyMethods(['getBaseCurrency'])
4444
->disableOriginalConstructor()
4545
->getMock();
4646
$this->storeResolver = $this->createPartialMock(
@@ -56,7 +56,7 @@ protected function setUp(): void
5656
$this->website = $this->getMockBuilder(
5757
WebsiteValidator::class
5858
)
59-
->setMethods(['getAllWebsitesValue', '_clearMessages', '_addMessages'])
59+
->onlyMethods(['getAllWebsitesValue', '_clearMessages', '_addMessages'])
6060
->setConstructorArgs([$this->storeResolver, $this->webSiteModel, $this->currencyResolver])
6161
->getMock();
6262
}
@@ -121,7 +121,7 @@ public function testGetAllWebsitesValue()
121121
$websiteString = $this->getMockBuilder(
122122
WebsiteValidator::class
123123
)
124-
->setMethods(['_clearMessages', '_addMessages'])
124+
->onlyMethods(['_clearMessages', '_addMessages'])
125125
->setConstructorArgs([$this->storeResolver, $this->webSiteModel, $this->currencyResolver])
126126
->getMock();
127127
$result = $websiteString->getAllWebsitesValue();
@@ -132,7 +132,7 @@ public function testGetAllWebsitesValue()
132132
/**
133133
* @return array
134134
*/
135-
public function isValidReturnDataProvider()
135+
public static function isValidReturnDataProvider()
136136
{
137137
return [
138138
// False cases.

app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/ValidatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected function setUp(): void
4444
$this->validator = $this->getMockBuilder(
4545
\Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator::class
4646
)
47-
->setMethods(['_clearMessages', '_addMessages'])
47+
->onlyMethods(['_clearMessages', '_addMessages'])
4848
->setConstructorArgs([$this->validators])
4949
->getMock();
5050
}
@@ -84,7 +84,7 @@ public function testInit()
8484
/**
8585
* @return array
8686
*/
87-
public function isValidDataProvider()
87+
public static function isValidDataProvider()
8888
{
8989
return [
9090
[

0 commit comments

Comments
 (0)