Skip to content

Commit e19523d

Browse files
authored
Merge pull request #1432 from magento-okapis/Okapis-PR
[okapis] MAGETWO-70573: Impossible to configure Redis through the CLI
2 parents 024f8aa + 47ff3d5 commit e19523d

File tree

13 files changed

+1665
-53
lines changed

13 files changed

+1665
-53
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Mtf\Util\Command\Cli;
8+
9+
use Magento\Mtf\Util\Command\Cli;
10+
11+
/**
12+
* Setup Magento for tests executions.
13+
*/
14+
class DeployMode extends Cli
15+
{
16+
/**
17+
* Parameter for Magento command to set the deploy mode
18+
*/
19+
const PARAM_DEPLOY_MODE_DEVELOPER = 'deploy:mode:set developer';
20+
21+
/**
22+
* Parameter for Magento command to set the deploy mode to Production
23+
*/
24+
const PARAM_DEPLOY_MODE_PRODUCTION = 'deploy:mode:set production';
25+
26+
/**
27+
* set the deployment mode to developer
28+
*
29+
* @return void
30+
*/
31+
public function setDeployModeToDeveloper()
32+
{
33+
parent::execute(DeployMode::PARAM_DEPLOY_MODE_DEVELOPER);
34+
}
35+
36+
/**
37+
* set the deployment mode to production
38+
*
39+
* @return void
40+
*/
41+
public function setDeployModeToProduction()
42+
{
43+
parent::execute(DeployMode::PARAM_DEPLOY_MODE_PRODUCTION);
44+
}
45+
}

dev/tests/functional/tests/app/Magento/Backend/Test/Repository/ConfigData.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,15 @@
183183
<item name="value" xsi:type="number">1</item>
184184
</field>
185185
</dataset>
186+
187+
<dataset name="minify_js_files">
188+
<field name="dev/js/minify_files" xsi:type="array">
189+
<item name="scope" xsi:type="string">default</item>
190+
<item name="scope_id" xsi:type="number">0</item>
191+
<item name="label" xsi:type="string">Yes</item>
192+
<item name="value" xsi:type="number">1</item>
193+
</field>
194+
</dataset>
186195

187196
<dataset name="enable_https_frontend_admin">
188197
<field name="web/secure/use_in_frontend" xsi:type="array">
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Backend\Test\TestCase;
7+
8+
use Magento\Mtf\TestCase\Injectable;
9+
use Magento\Backend\Test\Page\Adminhtml\Dashboard;
10+
use Magento\Mtf\Util\Command\Cli\DeployMode;
11+
use Magento\Mtf\TestStep\TestStepFactory;
12+
13+
/**
14+
* Verify visibility of form elements on Configuration page.
15+
*
16+
* @ZephyrId MAGETWO-71416
17+
*/
18+
class LoginAfterJSMinificationTest extends Injectable
19+
{
20+
21+
/**
22+
* Admin dashboard page
23+
* @var Dashboard
24+
*/
25+
private $adminDashboardPage;
26+
27+
/**
28+
* Factory for Test Steps.
29+
*
30+
* @var TestStepFactory
31+
*/
32+
private $stepFactory;
33+
34+
/**
35+
* Configuration setting.
36+
*
37+
* @var string
38+
*/
39+
private $configData;
40+
41+
/**
42+
* Prepare data for further test execution.
43+
*
44+
* @param Dashboard $adminDashboardPage
45+
* @return void
46+
*/
47+
public function __inject(
48+
Dashboard $adminDashboardPage,
49+
TestStepFactory $stepFactory
50+
) {
51+
$this->adminDashboardPage = $adminDashboardPage;
52+
$this->stepFactory = $stepFactory;
53+
}
54+
55+
/**
56+
* Admin login test after JS minification is turned on in production mode
57+
* @param DeployMode $cli
58+
* @param null $configData
59+
* @return void
60+
*/
61+
public function test(
62+
DeployMode $cli,
63+
$configData = null
64+
) {
65+
$this->configData = $configData;
66+
67+
//Pre-conditions
68+
$cli->setDeployModeToDeveloper();
69+
$this->objectManager->create(
70+
\Magento\Config\Test\TestStep\SetupConfigurationStep::class,
71+
['configData' => $this->configData]
72+
)->run();
73+
74+
// Steps
75+
$cli->setDeployModeToProduction();
76+
$this->adminDashboardPage->open();
77+
}
78+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd">
9+
<testCase name="Magento\Backend\Test\TestCase\LoginAfterJSMinificationTest" summary="Verify login is successful after JS minification is enabled">
10+
<variation name="LoginAfterJSMinificationEnabledVariation1" summary="Verify login is successful after JS minification" ticketId="MAGETWO-71416">
11+
<data name="tag" xsi:type="string">severity:S1</data>
12+
<data name="configData" xsi:type="string">minify_js_files</data>
13+
<data name="menuItem" xsi:type="string">Dashboard</data>
14+
<data name="pageTitle" xsi:type="string">Dashboard</data>
15+
<constraint name="Magento\Backend\Test\Constraint\AssertBackendPageIsAvailable" />
16+
</variation>
17+
</testCase>
18+
</config>

setup/src/Magento/Setup/Model/ConfigOptionsList.php

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,15 @@ class ConfigOptionsList implements ConfigOptionsListInterface
3636
/**
3737
* @var array
3838
*/
39-
private $validSaveHandlers = [
40-
ConfigOptionsListConstants::SESSION_SAVE_FILES,
41-
ConfigOptionsListConstants::SESSION_SAVE_DB,
39+
private $configOptionsCollection = [];
40+
41+
/**
42+
* @var array
43+
*/
44+
private $configOptionsListClasses = [
45+
\Magento\Setup\Model\ConfigOptionsList\Session::class,
46+
\Magento\Setup\Model\ConfigOptionsList\Cache::class,
47+
\Magento\Setup\Model\ConfigOptionsList\PageCache::class
4248
];
4349

4450
/**
@@ -51,6 +57,9 @@ public function __construct(ConfigGenerator $configGenerator, DbValidator $dbVal
5157
{
5258
$this->configGenerator = $configGenerator;
5359
$this->dbValidator = $dbValidator;
60+
foreach ($this->configOptionsListClasses as $className) {
61+
$this->configOptionsCollection[] = \Magento\Framework\App\ObjectManager::getInstance()->get($className);
62+
}
5463
}
5564

5665
/**
@@ -59,21 +68,13 @@ public function __construct(ConfigGenerator $configGenerator, DbValidator $dbVal
5968
*/
6069
public function getOptions()
6170
{
62-
return [
71+
$options = [
6372
new TextConfigOption(
6473
ConfigOptionsListConstants::INPUT_KEY_ENCRYPTION_KEY,
6574
TextConfigOption::FRONTEND_WIZARD_TEXT,
6675
ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY,
6776
'Encryption key'
6877
),
69-
new SelectConfigOption(
70-
ConfigOptionsListConstants::INPUT_KEY_SESSION_SAVE,
71-
SelectConfigOption::FRONTEND_WIZARD_SELECT,
72-
$this->validSaveHandlers,
73-
ConfigOptionsListConstants::CONFIG_PATH_SESSION_SAVE,
74-
'Session save handler',
75-
ConfigOptionsListConstants::SESSION_SAVE_FILES
76-
),
7778
new TextConfigOption(
7879
ConfigOptionsListConstants::INPUT_KEY_DB_HOST,
7980
TextConfigOption::FRONTEND_WIZARD_TEXT,
@@ -150,6 +151,12 @@ public function getOptions()
150151
'http Cache hosts'
151152
),
152153
];
154+
155+
foreach ($this->configOptionsCollection as $configOptionsList) {
156+
$options = array_merge($options, $configOptionsList->getOptions());
157+
}
158+
159+
return $options;
153160
}
154161

155162
/**
@@ -159,7 +166,6 @@ public function createConfig(array $data, DeploymentConfig $deploymentConfig)
159166
{
160167
$configData = [];
161168
$configData[] = $this->configGenerator->createCryptConfig($data, $deploymentConfig);
162-
$configData[] = $this->configGenerator->createSessionConfig($data);
163169
$definitionConfig = $this->configGenerator->createDefinitionsConfig($data);
164170
if (isset($definitionConfig)) {
165171
$configData[] = $definitionConfig;
@@ -169,6 +175,11 @@ public function createConfig(array $data, DeploymentConfig $deploymentConfig)
169175
$configData[] = $this->configGenerator->createXFrameConfig();
170176
$configData[] = $this->configGenerator->createModeConfig();
171177
$configData[] = $this->configGenerator->createCacheHostsConfig($data);
178+
179+
foreach ($this->configOptionsCollection as $configOptionsList) {
180+
$configData[] = $configOptionsList->createConfig($data, $deploymentConfig);
181+
}
182+
172183
return $configData;
173184
}
174185

@@ -197,9 +208,12 @@ public function validate(array $options, DeploymentConfig $deploymentConfig)
197208
$errors = array_merge($errors, $this->validateDbSettings($options, $deploymentConfig));
198209
}
199210

211+
foreach ($this->configOptionsCollection as $configOptionsList) {
212+
$errors = array_merge($errors, $configOptionsList->validate($options, $deploymentConfig));
213+
}
214+
200215
$errors = array_merge(
201216
$errors,
202-
$this->validateSessionSave($options),
203217
$this->validateEncryptionKey($options)
204218
);
205219

@@ -251,24 +265,6 @@ private function getDbSettings(array $options, DeploymentConfig $deploymentConfi
251265
return $options;
252266
}
253267

254-
/**
255-
* Validates session save param
256-
*
257-
* @param array $options
258-
* @return string[]
259-
*/
260-
private function validateSessionSave(array $options)
261-
{
262-
$errors = [];
263-
if (isset($options[ConfigOptionsListConstants::INPUT_KEY_SESSION_SAVE])
264-
&& !in_array($options[ConfigOptionsListConstants::INPUT_KEY_SESSION_SAVE], $this->validSaveHandlers)
265-
) {
266-
$errors[] = "Invalid session handler '{$options[ConfigOptionsListConstants::INPUT_KEY_SESSION_SAVE]}'";
267-
}
268-
269-
return $errors;
270-
}
271-
272268
/**
273269
* Validates encryption key param
274270
*

0 commit comments

Comments
 (0)