Skip to content

Commit a450ec2

Browse files
author
CI bot
committed
Merge remote-tracking branch 'remotes/dev/master'
2 parents 34faea8 + 2a8529a commit a450ec2

File tree

14 files changed

+194
-24
lines changed

14 files changed

+194
-24
lines changed

Diff for: src/Oro/Bundle/DataGridBundle/Resources/public/default/scss/variables/datagrid-header-cell-config.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ $datagrid-header-cell-link-font-size: 12px !default;
1717
$datagrid-header-cell-link-font-weight: font-weight('semi-bold') !default;
1818
$datagrid-header-cell-link-line-height: 1 !default;
1919
$datagrid-header-cell-link-color: get-color('text', 'secondary') !default;
20-
$datagrid-header-cell-link-opacity: null !default;
20+
$datagrid-header-cell-link-opacity: 1 !default;
2121
$datagrid-header-cell-link-text-transform: uppercase !default;
2222
$datagrid-header-cell-link-position: relative !default;
2323
$datagrid-header-cell-link-hover-color: get-color('neutral', 'dark') !default;

Diff for: src/Oro/Bundle/MessageQueueBundle/Resources/config/mq_topics_test.yml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ services:
44
- { name: oro_message_queue.topic }
55

66
Oro\Component\MessageQueue\Test\Async\Topic\BasicMessageTestTopic: ~
7+
Oro\Component\MessageQueue\Test\Async\Topic\RequeueTestTopic: ~
78
Oro\Component\MessageQueue\Test\Async\Topic\DependentMessageTestTopic: ~
89
Oro\Component\MessageQueue\Test\Async\Topic\DependentMessageDependentJobTestTopic: ~
910
Oro\Component\MessageQueue\Test\Async\Topic\UniqueJobTestTopic: ~

Diff for: src/Oro/Bundle/MessageQueueBundle/Resources/config/services_test.yml

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ services:
2121
tags:
2222
- { name: 'oro_message_queue.client.message_processor' }
2323

24+
oro_message_queue.async.requeue_processor:
25+
class: Oro\Component\MessageQueue\Test\Async\RequeueProcessor
26+
tags:
27+
- { name: 'oro_message_queue.client.message_processor' }
28+
2429
oro_message_queue.async.unique_message_processor:
2530
class: Oro\Component\MessageQueue\Test\Async\UniqueMessageProcessor
2631
arguments:

Diff for: src/Oro/Bundle/MessageQueueBundle/Security/SecurityAwareConsumptionExtension.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ public function onPreReceived(Context $context): void
5353
// The data for the token is invalid, but this does not prevent the consumer from executing.
5454
// For example, a user was deleted before we started performing actions on them with the consumer, etc.
5555
$context->getLogger()->error($exception->getMessage());
56-
$context->setStatus(MessageProcessorInterface::REJECT);
56+
// There is no point in changing the status, since the status of the message is already known.
57+
if (!$context->getStatus()) {
58+
$context->setStatus(MessageProcessorInterface::ACK);
59+
}
5760

5861
return;
5962
} catch (InvalidTokenSerializationException $exception) {

Diff for: src/Oro/Bundle/MessageQueueBundle/Tests/Functional/Security/SecurityAwareConsumptionExtensionTest.php

+43-1
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22

33
namespace Oro\Bundle\MessageQueueBundle\Tests\Functional\Security;
44

5+
use Doctrine\Persistence\ManagerRegistry;
56
use Oro\Bundle\MessageQueueBundle\Security\SecurityAwareDriver;
67
use Oro\Bundle\MessageQueueBundle\Test\Functional\MessageQueueExtension;
78
use Oro\Bundle\SecurityBundle\Exception\InvalidTokenSerializationException;
89
use Oro\Bundle\TestFrameworkBundle\Test\WebTestCase;
10+
use Oro\Bundle\UserBundle\Entity\User;
11+
use Oro\Bundle\UserBundle\Tests\Functional\DataFixtures\LoadUserData;
912
use Oro\Component\MessageQueue\Client\Message;
1013
use Oro\Component\MessageQueue\Consumption\MessageProcessorInterface;
1114
use Oro\Component\MessageQueue\Test\Async\Topic\BasicMessageTestTopic;
15+
use Oro\Component\MessageQueue\Test\Async\Topic\RequeueTestTopic;
1216

1317
class SecurityAwareConsumptionExtensionTest extends WebTestCase
1418
{
@@ -18,6 +22,7 @@ class SecurityAwareConsumptionExtensionTest extends WebTestCase
1822
protected function setUp(): void
1923
{
2024
$this->initClient();
25+
$this->loadFixtures([LoadUserData::class]);
2126

2227
self::purgeMessageQueue();
2328
}
@@ -56,13 +61,37 @@ public function testWithInvalidToken(): void
5661
self::consume(1);
5762
}
5863

64+
public function testWithInvalidTokenAndRedelivered(): void
65+
{
66+
$user = $this->getReference(LoadUserData::SIMPLE_USER);
67+
68+
$serializedToken = 'organizationId=1;userId=%s;userClass=Oro\\Bundle\\UserBundle\\Entity\\User;roles=';
69+
$serializedToken = sprintf($serializedToken, $user->getId());
70+
71+
// Simulate the situation when a message is re-queued.
72+
self::sendMessage(RequeueTestTopic::getName(), $this->createMessage($serializedToken));
73+
74+
self::consume();
75+
$requeueMessages = self::getProcessedMessagesByStatus(MessageProcessorInterface::REQUEUE);
76+
self::assertCount(1, $requeueMessages);
77+
78+
// Remove the user and start the consumer. Expect the security token to be invalid and the 're-queue' message
79+
// to be rejected without error.
80+
$this->removeUser($user->getId());
81+
self::assertEmpty(self::getProcessedMessagesByStatus(MessageProcessorInterface::REJECT));
82+
83+
self::consume();
84+
$rejectMessages = self::getProcessedMessagesByStatus(MessageProcessorInterface::REJECT);
85+
self::assertCount(1, $rejectMessages);
86+
}
87+
5988
public function testWithInvalidUserAndOrganization(): void
6089
{
6190
$serializedToken = 'organizationId=100;userId=50;userClass=Oro\\Bundle\\UserBundle\\Entity\\User;roles=';
6291
$sentMessage = self::sendMessage(BasicMessageTestTopic::getName(), $this->createMessage($serializedToken));
6392
self::consume();
6493

65-
self::assertProcessedMessageStatus(MessageProcessorInterface::REJECT, $sentMessage);
94+
self::assertProcessedMessageStatus(MessageProcessorInterface::ACK, $sentMessage);
6695
}
6796

6897
private function createMessage(string $serializedToken = ''): Message
@@ -73,4 +102,17 @@ private function createMessage(string $serializedToken = ''): Message
73102

74103
return $message;
75104
}
105+
106+
private function removeUser(int $userId): void
107+
{
108+
/** @var ManagerRegistry $managerRegistry */
109+
$managerRegistry = $this->getContainer()->get('doctrine');
110+
$entityManager = $managerRegistry->getManager();
111+
$originalUser = $managerRegistry->getRepository(User::class)->find($userId);
112+
if ($originalUser) {
113+
$entityManager->remove($originalUser);
114+
$entityManager->flush($originalUser);
115+
$entityManager->clear();
116+
}
117+
}
76118
}

Diff for: src/Oro/Bundle/MessageQueueBundle/Tests/Unit/Security/SecurityAwareConsumptionExtensionTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function testOnPreReceivedShouldRejectMessageIfSecurityTokenCannotBeDeser
108108
->with('Exception message');
109109

110110
$this->extension->onPreReceived($context);
111-
$this->assertEquals(MessageProcessorInterface::REJECT, $context->getStatus());
111+
$this->assertEquals(MessageProcessorInterface::ACK, $context->getStatus());
112112
}
113113

114114
public function testOnPreReceivedShouldThrowExceptionIfSecurityTokenCannotBeDeserialized(): void
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{# @name = email_template_order_base_default #}
2+
{# @subject = Email Template Order Base #}
3+
{# @isSystem = 1 #}
4+
{# @isEditable = 1 #}
5+
6+
Email Template Order Base Content
7+
{% block content %}{% endblock content %}
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{# @name = email_template_order_extended_default #}
2+
{# @subject = Email Template Order Extended #}
3+
{# @isSystem = 1 #}
4+
{# @isEditable = 1 #}
5+
6+
{% extends oro_get_email_template('email_template_order_base_default') %}
7+
{% block content %}
8+
Email Template Order Extended Content
9+
{% endblock content %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{# @name = email_template_order_regular_default #}
2+
{# @subject = Email Template Order Regular #}
3+
{# @isSystem = 1 #}
4+
{# @isEditable = 1 #}
5+
6+
Email Template Order Regular Content

Diff for: src/Oro/Bundle/ThemeBundle/Migrations/Data/AbstractLoadThemeConfiguration.php

+36-8
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ abstract protected function getScopes(): iterable;
3434

3535
abstract protected function isApplicable(): bool;
3636

37+
abstract protected function getFrontendTheme(ConfigManager $configManager, ?object $scope = null);
38+
3739
/**
3840
* Options from System configuration that should replace values from theme.yml
3941
*/
@@ -54,16 +56,23 @@ public function load(ObjectManager $manager): void
5456
continue;
5557
}
5658

59+
$themeConfiguration = $this->getThemeConfiguration($this->configManager, $manager, $scope);
60+
if ($themeConfiguration && $themeConfiguration->getTheme() === $frontendTheme) {
61+
continue;
62+
}
63+
5764
$themeConfiguration = $this->createThemeConfiguration($frontendTheme, $scope);
5865

5966
$this->manager->persist($themeConfiguration);
6067
$manager->flush();
6168

62-
$this->configManager->set(
63-
Configuration::getConfigKeyByName(Configuration::THEME_CONFIGURATION),
64-
$themeConfiguration->getId(),
65-
$scope
66-
);
69+
if ($this->isStoreInSystemConfig()) {
70+
$this->configManager->set(
71+
Configuration::getConfigKeyByName(Configuration::THEME_CONFIGURATION),
72+
$themeConfiguration->getId(),
73+
$scope
74+
);
75+
}
6776
}
6877

6978
$this->configManager->flush();
@@ -76,6 +85,11 @@ protected function init(ObjectManager $manager): void
7685
$this->configManager = $this->getConfigManager();
7786
}
7887

88+
protected function isStoreInSystemConfig(): bool
89+
{
90+
return true;
91+
}
92+
7993
protected function createThemeConfiguration(string $frontendTheme, object|null $scope): ThemeConfiguration
8094
{
8195
$definition = $this->themeDefinitionBag->getThemeDefinition($frontendTheme);
@@ -89,9 +103,23 @@ protected function createThemeConfiguration(string $frontendTheme, object|null $
89103
->setConfiguration($this->buildConfigurationFromDefinition($definition, $scope));
90104
}
91105

92-
protected function getFrontendTheme(ConfigManager $configManager, ?object $scope): ?string
93-
{
94-
return $configManager->get('oro_frontend.frontend_theme', false, false, $scope);
106+
protected function getThemeConfiguration(
107+
ConfigManager $configManager,
108+
ObjectManager $manager,
109+
?object $scope = null
110+
): ?ThemeConfiguration {
111+
$themeConfigurationId = $configManager->get(
112+
Configuration::getConfigKeyByName(Configuration::THEME_CONFIGURATION),
113+
false,
114+
false,
115+
$scope
116+
);
117+
118+
if (!$themeConfigurationId) {
119+
return null;
120+
}
121+
122+
return $manager->getRepository(ThemeConfiguration::class)->find($themeConfigurationId);
95123
}
96124

97125
protected function getThemeConfigurationName(array $definition, object|null $scope): string

Diff for: src/Oro/Bundle/ThemeBundle/Tests/Behat/Features/theme_configuration_grid.feature

+23-11
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,31 @@ Feature: Theme Configuration Grid
3232
Scenario: Sort by Name
3333
Given I should see following grid:
3434
| Name |
35+
| Golden Carbon |
3536
| Refreshing Teal |
3637
When I sort grid by "Name"
3738
Then I should see following grid:
3839
| Name |
3940
| Custom |
4041
| Default |
42+
| Golden Carbon |
4143
| Refreshing Teal |
4244
When I sort grid by "Name" again
4345
Then I should see following grid:
4446
| Name |
4547
| Refreshing Teal |
48+
| Golden Carbon |
4649
| Default |
50+
| Custom |
4751
And I reset "Theme Configurations Grid" grid
4852

4953
Scenario: Sort by Description
5054
Given I should see following grid:
5155
| Description |
5256
| |
57+
| |
5358
| Default Description |
59+
| Custom |
5460
When I sort grid by "Description"
5561
Then I should see following grid:
5662
| Description |
@@ -60,24 +66,30 @@ Feature: Theme Configuration Grid
6066
Then I should see following grid:
6167
| Description |
6268
| |
69+
| |
6370
| Default Description |
71+
| Custom |
6472
And I reset "Theme Configurations Grid" grid
6573

6674
Scenario: Sort by Theme
6775
Given I should see following grid:
68-
| Theme |
69-
| default |
70-
| default |
71-
| custom |
76+
| Theme |
77+
| golden_carbon |
78+
| default |
79+
| default |
80+
| custom |
7281
When I sort grid by "Theme"
7382
Then I should see following grid:
74-
| Theme |
75-
| custom |
76-
| default |
83+
| Theme |
84+
| custom |
85+
| default |
86+
| default |
87+
| golden_carbon |
7788
When I sort grid by "Theme" again
7889
Then I should see following grid:
79-
| Theme |
80-
| default |
81-
| default |
82-
| custom |
90+
| Theme |
91+
| golden_carbon |
92+
| default |
93+
| default |
94+
| custom |
8395
And I reset "Theme Configurations Grid" grid

Diff for: src/Oro/Bundle/UserBundle/Resources/public/templates/datagrid/permission/permission-view.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<% var togglerId = _.uniqueId('dropdown-') %>
22
<div
3-
data-toggle="dropdown" role="button" id="<%- togglerId %>"
3+
data-toggle="dropdown" id="<%- togglerId %>"
44
aria-label="<%- _.__('oro.role.permission.edit_label', {label: label}) %>"
55
aria-haspopup="true" aria-expanded="false"
66
data-target="<%- dropdownTarget %>"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Oro\Component\MessageQueue\Test\Async;
4+
5+
use Oro\Component\MessageQueue\Client\TopicSubscriberInterface;
6+
use Oro\Component\MessageQueue\Consumption\MessageProcessorInterface;
7+
use Oro\Component\MessageQueue\Test\Async\Topic\RequeueTestTopic;
8+
use Oro\Component\MessageQueue\Transport\MessageInterface;
9+
use Oro\Component\MessageQueue\Transport\SessionInterface;
10+
11+
/**
12+
* Requeue message processor.
13+
*/
14+
class RequeueProcessor implements MessageProcessorInterface, TopicSubscriberInterface
15+
{
16+
#[\Override]
17+
public function process(MessageInterface $message, SessionInterface $session): string
18+
{
19+
return self::REQUEUE;
20+
}
21+
22+
#[\Override]
23+
public static function getSubscribedTopics(): array
24+
{
25+
return [RequeueTestTopic::getName()];
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Oro\Component\MessageQueue\Test\Async\Topic;
4+
5+
use Oro\Component\MessageQueue\Topic\AbstractTopic;
6+
use Symfony\Component\OptionsResolver\OptionsResolver;
7+
8+
/**
9+
* A test topic for requeue processor.
10+
*/
11+
class RequeueTestTopic extends AbstractTopic
12+
{
13+
#[\Override]
14+
public static function getName(): string
15+
{
16+
return 'oro.message_queue.requeue_processor';
17+
}
18+
19+
#[\Override]
20+
public static function getDescription(): string
21+
{
22+
return 'Test topic for requeue processor.';
23+
}
24+
25+
#[\Override]
26+
public function configureMessageBody(OptionsResolver $resolver): void
27+
{
28+
}
29+
}

0 commit comments

Comments
 (0)