Skip to content

Commit 90e7d55

Browse files
authored
Merge branch '2.4-develop' into 2.4-develop-fast-lane-prs
2 parents 9d267b1 + 5c97ea7 commit 90e7d55

File tree

637 files changed

+7417
-1070
lines changed

Some content is hidden

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

637 files changed

+7417
-1070
lines changed

app/code/Magento/AsynchronousOperations/Model/MassPublisher.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function __construct(
7979
}
8080

8181
/**
82-
* {@inheritdoc}
82+
* @inheritdoc
8383
*/
8484
public function publish($topicName, $data)
8585
{
@@ -91,6 +91,7 @@ public function publish($topicName, $data)
9191
[
9292
'body' => $message,
9393
'properties' => [
94+
'topic_name' => $topicName,
9495
'delivery_mode' => 2,
9596
'message_id' => $this->messageIdGenerator->generate($topicName),
9697
]

app/code/Magento/Authorization/Model/Acl/Loader/Rule.php

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\Authorization\Model\Acl\Loader;
99

10+
use Magento\Framework\Acl;
1011
use Magento\Framework\Acl\Data\CacheInterface;
1112
use Magento\Framework\Acl\LoaderInterface;
1213
use Magento\Framework\Acl\RootResource;
@@ -21,7 +22,12 @@ class Rule implements LoaderInterface
2122
/**
2223
* Rules array cache key
2324
*/
24-
const ACL_RULE_CACHE_KEY = 'authorization_rule_cached_data';
25+
public const ACL_RULE_CACHE_KEY = 'authorization_rule_cached_data';
26+
27+
/**
28+
* Allow everything resource id
29+
*/
30+
private const ALLOW_EVERYTHING = 'Magento_Backend::all';
2531

2632
/**
2733
* @var ResourceConnection
@@ -75,27 +81,74 @@ public function __construct(
7581
/**
7682
* Populate ACL with rules from external storage
7783
*
78-
* @param \Magento\Framework\Acl $acl
84+
* @param Acl $acl
7985
* @return void
8086
*/
81-
public function populateAcl(\Magento\Framework\Acl $acl)
87+
public function populateAcl(Acl $acl)
8288
{
89+
$result = $this->applyPermissionsAccordingToRules($acl);
90+
$this->applyDenyPermissionsForMissingRules($acl, ...$result);
91+
}
92+
93+
/**
94+
* Apply ACL with rules
95+
*
96+
* @param Acl $acl
97+
* @return array[]
98+
*/
99+
private function applyPermissionsAccordingToRules(Acl $acl): array
100+
{
101+
$foundResources = $foundDeniedRoles = [];
83102
foreach ($this->getRulesArray() as $rule) {
84103
$role = $rule['role_id'];
85104
$resource = $rule['resource_id'];
86105
$privileges = !empty($rule['privileges']) ? explode(',', $rule['privileges']) : null;
87106

88107
if ($acl->has($resource)) {
108+
$foundResources[$resource] = $resource;
89109
if ($rule['permission'] == 'allow') {
90110
if ($resource === $this->_rootResource->getId()) {
91111
$acl->allow($role, null, $privileges);
92112
}
93113
$acl->allow($role, $resource, $privileges);
94114
} elseif ($rule['permission'] == 'deny') {
115+
$foundDeniedRoles[$role] = $role;
95116
$acl->deny($role, $resource, $privileges);
96117
}
97118
}
98119
}
120+
return [$foundResources, $foundDeniedRoles];
121+
}
122+
123+
/**
124+
* Apply deny permissions for missing rules
125+
*
126+
* For all rules that were not regenerated in authorization_rule table,
127+
* when adding a new module and without re-saving all roles,
128+
* consider not present rules with deny permissions
129+
*
130+
* @param Acl $acl
131+
* @param array $resources
132+
* @param array $deniedRoles
133+
* @return void
134+
*/
135+
private function applyDenyPermissionsForMissingRules(
136+
Acl $acl,
137+
array $resources,
138+
array $deniedRoles
139+
) {
140+
if (count($resources) && count($deniedRoles)
141+
//ignore denying missing permission if all are allowed
142+
&& !(count($resources) === 1 && isset($resources[static::ALLOW_EVERYTHING]))
143+
) {
144+
foreach ($acl->getResources() as $resource) {
145+
if (!isset($resources[$resource])) {
146+
foreach ($deniedRoles as $role) {
147+
$acl->deny($role, $resource, null);
148+
}
149+
}
150+
}
151+
}
99152
}
100153

101154
/**

app/code/Magento/Authorization/Test/Unit/Model/Acl/Loader/RuleTest.php

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ static function ($value) {
9797
*/
9898
public function testPopulateAclFromCache(): void
9999
{
100+
$rules = [
101+
['role_id' => 1, 'resource_id' => 'Magento_Backend::all', 'permission' => 'allow'],
102+
['role_id' => 2, 'resource_id' => 1, 'permission' => 'allow'],
103+
['role_id' => 3, 'resource_id' => 1, 'permission' => 'deny']
104+
];
100105
$this->resourceMock->expects($this->never())->method('getTable');
101106
$this->resourceMock->expects($this->never())
102107
->method('getConnection');
@@ -105,13 +110,7 @@ public function testPopulateAclFromCache(): void
105110
->method('load')
106111
->with(Rule::ACL_RULE_CACHE_KEY)
107112
->willReturn(
108-
json_encode(
109-
[
110-
['role_id' => 1, 'resource_id' => 'Magento_Backend::all', 'permission' => 'allow'],
111-
['role_id' => 2, 'resource_id' => 1, 'permission' => 'allow'],
112-
['role_id' => 3, 'resource_id' => 1, 'permission' => 'deny']
113-
]
114-
)
113+
json_encode($rules)
115114
);
116115

117116
$aclMock = $this->createMock(Acl::class);
@@ -123,9 +122,21 @@ public function testPopulateAclFromCache(): void
123122
['1', 'Magento_Backend::all', null],
124123
['2', 1, null]
125124
);
125+
126126
$aclMock
127127
->method('deny')
128-
->with('3', 1, null);
128+
->withConsecutive(
129+
['3', 1, null]
130+
);
131+
132+
$aclMock
133+
->method('getResources')
134+
->willReturn([
135+
'Magento_Backend::all',
136+
'Magento_Backend::admin',
137+
'Vendor_MyModule::menu',
138+
'Vendor_MyModule::index'
139+
]);
129140

130141
$this->model->populateAcl($aclMock);
131142
}

app/code/Magento/AwsS3/Test/Mftf/Test/AdminAwsS3ImportBundleProductTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="deleteDirectory" stepKey="deleteImportImagesFilesDirectoryS3" after="deleteImportFilesDirectoryS3">
6060
<argument name="path">var/import/images/{{ImportProduct_Bundle.name}}</argument>
6161
</helper>
62+
<actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache" after="deleteImportImagesFilesDirectoryS3">
63+
<argument name="tags" value=""/>
64+
</actionGroup>
6265

6366
<!-- Disable AWS S3 Remote Storage & Delete Local Data -->
6467
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.disable_options}}" stepKey="disableRemoteStorage" after="logoutFromAdmin"/>

app/code/Magento/AwsS3/Test/Mftf/Test/AdminAwsS3ImportDownloadableProductsWithFileLinksTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@
7575
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="deleteDirectory" stepKey="deleteImportImagesFilesDirectoryS3" after="deleteImportFilesDirectoryS3">
7676
<argument name="path">var/import/images/{{ImportProduct_Downloadable_FileLinks.name}}</argument>
7777
</helper>
78+
<actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache" after="deleteImportImagesFilesDirectoryS3">
79+
<argument name="tags" value=""/>
80+
</actionGroup>
7881

7982
<!-- Disable AWS S3 Remote Storage & Delete Local Data -->
8083
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.disable_options}}" stepKey="disableRemoteStorage" after="logoutFromAdmin"/>

app/code/Magento/AwsS3/Test/Mftf/Test/AdminAwsS3ImportDownloadableProductsWithUrlLinksTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="deleteDirectory" stepKey="deleteImportImagesFilesDirectoryS3" after="deleteImportFilesDirectoryS3">
6060
<argument name="path">var/import/images/{{ImportProduct_Downloadable_UrlLinks.name}}</argument>
6161
</helper>
62+
<actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache" after="deleteImportImagesFilesDirectoryS3">
63+
<argument name="tags" value=""/>
64+
</actionGroup>
6265

6366
<!-- Disable AWS S3 Remote Storage & Delete Local Data -->
6467
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.disable_options}}" stepKey="disableRemoteStorage" after="logoutFromAdmin"/>

app/code/Magento/AwsS3/Test/Mftf/Test/AdminAwsS3ImportGroupedProductTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="deleteDirectory" stepKey="deleteImportImagesFilesDirectoryS3" after="deleteImportFilesDirectoryS3">
6060
<argument name="path">var/import/images/{{ImportProduct_Grouped.name}}</argument>
6161
</helper>
62+
<actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache" after="deleteImportImagesFilesDirectoryS3">
63+
<argument name="tags" value=""/>
64+
</actionGroup>
6265

6366
<!-- Disable AWS S3 Remote Storage & Delete Local Data -->
6467
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.disable_options}}" stepKey="disableRemoteStorage" after="logoutFromAdmin"/>

app/code/Magento/AwsS3/Test/Mftf/Test/AdminAwsS3ImportSimpleAndConfigurableProductsWithAssignedImagesTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@
6060
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="deleteDirectory" stepKey="deleteImportImagesFilesDirectoryS3" after="deleteImportFilesDirectoryS3">
6161
<argument name="path">var/import/images/{{ImportProduct_Configurable.name}}</argument>
6262
</helper>
63+
<actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache" after="deleteImportImagesFilesDirectoryS3">
64+
<argument name="tags" value=""/>
65+
</actionGroup>
6366

6467
<!-- Disable AWS S3 Remote Storage & Delete Local Data -->
6568
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.disable_options}}" stepKey="disableRemoteStorage" after="logoutFromAdmin"/>

app/code/Magento/AwsS3/Test/Mftf/Test/AdminAwsS3ImportSimpleProductImagesDuplicationTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
<helper class="Magento\AwsS3\Test\Mftf\Helper\S3FileAssertions" method="deleteDirectory" stepKey="deleteImportImagesFilesDirectoryS3" after="deleteImportFilesDirectoryS3">
5959
<argument name="path">var/import/images/test_image_duplication</argument>
6060
</helper>
61+
<actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache" after="deleteImportImagesFilesDirectoryS3">
62+
<argument name="tags" value=""/>
63+
</actionGroup>
6164

6265
<!-- Disable AWS S3 Remote Storage & Delete Local Data -->
6366
<magentoCLI command="setup:config:set {{RemoteStorageAwsS3ConfigData.disable_options}}" stepKey="disableRemoteStorage" after="logoutFromAdmin"/>

app/code/Magento/AwsS3/Test/Mftf/Test/AwsS3AdminCreateDownloadableProductWithLinkTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
<actionGroup ref="DeleteProductUsingProductGridActionGroup" stepKey="deleteProduct">
4545
<argument name="product" value="DownloadableProduct"/>
4646
</actionGroup>
47+
<actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="clearFilters"/>
4748

4849
<!-- Log out -->
4950
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>

0 commit comments

Comments
 (0)