Skip to content

Commit d7b1b8a

Browse files
author
Bohdan Korablov
committed
MAGETWO-69584: Command config:sensitive:set does not work on the cloud
1 parent 6dbbb74 commit d7b1b8a

File tree

4 files changed

+31
-29
lines changed

4 files changed

+31
-29
lines changed

app/code/Magento/Config/Console/Command/ConfigSet/ProcessorFacade.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
use Magento\Framework\Exception\ConfigurationMismatchException;
1313
use Magento\Framework\Exception\CouldNotSaveException;
1414
use Magento\Framework\Exception\ValidatorException;
15+
use Magento\Deploy\Model\DeploymentConfig\Hash;
16+
use Magento\Config\App\Config\Type\System;
1517

1618
/**
1719
* Processor facade for config:set command.
@@ -46,19 +48,29 @@ class ProcessorFacade
4648
*/
4749
private $configSetProcessorFactory;
4850

51+
/**
52+
* The hash manager.
53+
*
54+
* @var Hash
55+
*/
56+
private $hash;
57+
4958
/**
5059
* @param ValidatorInterface $scopeValidator The scope validator
5160
* @param PathValidator $pathValidator The path validator
5261
* @param ConfigSetProcessorFactory $configSetProcessorFactory The factory for config:set processors
62+
* @param Hash $hash The hash manager
5363
*/
5464
public function __construct(
5565
ValidatorInterface $scopeValidator,
5666
PathValidator $pathValidator,
57-
ConfigSetProcessorFactory $configSetProcessorFactory
67+
ConfigSetProcessorFactory $configSetProcessorFactory,
68+
Hash $hash
5869
) {
5970
$this->scopeValidator = $scopeValidator;
6071
$this->pathValidator = $pathValidator;
6172
$this->configSetProcessorFactory = $configSetProcessorFactory;
73+
$this->hash = $hash;
6274
}
6375

6476
/**
@@ -93,6 +105,8 @@ public function process($path, $value, $scope, $scopeCode, $lock)
93105
// The processing flow depends on --lock option.
94106
$processor->process($path, $value, $scope, $scopeCode);
95107

108+
$this->hash->regenerate(System::CONFIG_TYPE);
109+
96110
return $message;
97111
}
98112
}

app/code/Magento/Config/Console/Command/ConfigSetCommand.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Magento\Config\App\Config\Type\System;
99
use Magento\Config\Console\Command\ConfigSet\ProcessorFacadeFactory;
1010
use Magento\Deploy\Model\DeploymentConfig\ChangeDetector;
11-
use Magento\Deploy\Model\DeploymentConfig\Hash;
1211
use Magento\Framework\App\Config\ScopeConfigInterface;
1312
use Magento\Framework\Console\Cli;
1413
use Symfony\Component\Console\Command\Command;
@@ -46,13 +45,6 @@ class ConfigSetCommand extends Command
4645
*/
4746
private $changeDetector;
4847

49-
/**
50-
* The hash manager.
51-
*
52-
* @var Hash
53-
*/
54-
private $hash;
55-
5648
/**
5749
* The factory for processor facade.
5850
*
@@ -63,18 +55,15 @@ class ConfigSetCommand extends Command
6355
/**
6456
* @param EmulatedAdminhtmlAreaProcessor $emulatedAreaProcessor Emulator adminhtml area for CLI command
6557
* @param ChangeDetector $changeDetector The config change detector
66-
* @param Hash $hash The hash manager
6758
* @param ProcessorFacadeFactory $processorFacadeFactory The factory for processor facade
6859
*/
6960
public function __construct(
7061
EmulatedAdminhtmlAreaProcessor $emulatedAreaProcessor,
7162
ChangeDetector $changeDetector,
72-
Hash $hash,
7363
ProcessorFacadeFactory $processorFacadeFactory
7464
) {
7565
$this->emulatedAreaProcessor = $emulatedAreaProcessor;
7666
$this->changeDetector = $changeDetector;
77-
$this->hash = $hash;
7867
$this->processorFacadeFactory = $processorFacadeFactory;
7968

8069
parent::__construct();
@@ -146,8 +135,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
146135
$input->getOption(static::OPTION_LOCK)
147136
);
148137

149-
$this->hash->regenerate(System::CONFIG_TYPE);
150-
151138
return $message;
152139
});
153140

app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/ProcessorFacadeTest.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Magento\Framework\Exception\ValidatorException;
1616
use Magento\Framework\Exception\CouldNotSaveException;
1717
use Magento\Framework\Exception\ConfigurationMismatchException;
18+
use Magento\Deploy\Model\DeploymentConfig\Hash;
19+
use Magento\Config\App\Config\Type\System;
1820
use PHPUnit_Framework_MockObject_MockObject as Mock;
1921

2022
/**
@@ -49,6 +51,11 @@ class ProcessorFacadeTest extends \PHPUnit_Framework_TestCase
4951
*/
5052
private $processorMock;
5153

54+
/**
55+
* @var Hash|Mock
56+
*/
57+
private $hashMock;
58+
5259
/**
5360
* @inheritdoc
5461
*/
@@ -69,10 +76,15 @@ protected function setUp()
6976
->method('create')
7077
->willReturn($this->processorMock);
7178

79+
$this->hashMock = $this->getMockBuilder(Hash::class)
80+
->disableOriginalConstructor()
81+
->getMock();
82+
7283
$this->model = new ProcessorFacade(
7384
$this->scopeValidatorMock,
7485
$this->pathValidatorMock,
75-
$this->configSetProcessorFactoryMock
86+
$this->configSetProcessorFactoryMock,
87+
$this->hashMock
7688
);
7789
}
7890

@@ -91,6 +103,9 @@ public function testProcess()
91103
$this->processorMock->expects($this->once())
92104
->method('process')
93105
->with('test/test/test', 'test', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null);
106+
$this->hashMock->expects($this->once())
107+
->method('regenerate')
108+
->with(System::CONFIG_TYPE);
94109

95110
$this->assertSame(
96111
'Value was saved.',

app/code/Magento/Config/Test/Unit/Console/Command/ConfigSetCommandTest.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55
*/
66
namespace Magento\Config\Test\Unit\Console\Command;
77

8-
use Magento\Config\App\Config\Type\System;
98
use Magento\Config\Console\Command\ConfigSet\ProcessorFacadeFactory;
109
use Magento\Config\Console\Command\ConfigSet\ProcessorFacade;
1110
use Magento\Config\Console\Command\ConfigSetCommand;
1211
use Magento\Config\Console\Command\EmulatedAdminhtmlAreaProcessor;
1312
use Magento\Deploy\Model\DeploymentConfig\ChangeDetector;
14-
use Magento\Deploy\Model\DeploymentConfig\Hash;
1513
use Magento\Framework\Console\Cli;
1614
use Magento\Framework\Exception\ValidatorException;
1715
use PHPUnit_Framework_MockObject_MockObject as Mock;
@@ -39,11 +37,6 @@ class ConfigSetCommandTest extends \PHPUnit_Framework_TestCase
3937
*/
4038
private $changeDetectorMock;
4139

42-
/**
43-
* @var Hash|Mock
44-
*/
45-
private $hashMock;
46-
4740
/**
4841
* @var ProcessorFacadeFactory|Mock
4942
*/
@@ -65,9 +58,6 @@ protected function setUp()
6558
$this->changeDetectorMock = $this->getMockBuilder(ChangeDetector::class)
6659
->disableOriginalConstructor()
6760
->getMock();
68-
$this->hashMock = $this->getMockBuilder(Hash::class)
69-
->disableOriginalConstructor()
70-
->getMock();
7161
$this->processorFacadeFactoryMock = $this->getMockBuilder(ProcessorFacadeFactory::class)
7262
->disableOriginalConstructor()
7363
->getMock();
@@ -78,7 +68,6 @@ protected function setUp()
7868
$this->command = new ConfigSetCommand(
7969
$this->emulatedAreProcessorMock,
8070
$this->changeDetectorMock,
81-
$this->hashMock,
8271
$this->processorFacadeFactoryMock
8372
);
8473
}
@@ -99,9 +88,6 @@ public function testExecute()
9988
->willReturnCallback(function ($function) {
10089
return $function();
10190
});
102-
$this->hashMock->expects($this->once())
103-
->method('regenerate')
104-
->with(System::CONFIG_TYPE);
10591

10692
$tester = new CommandTester($this->command);
10793
$tester->execute([

0 commit comments

Comments
 (0)