Skip to content

Commit 4a78eac

Browse files
committed
AC-6974::Cloud Native S3 Web API test Failures -2.4-develop - Fixed GraphQL testCacheIdHeaderWithCurrency Test
1 parent ac1c853 commit 4a78eac

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

app/code/Magento/GraphQlCache/Setup/ConfigOptionsList.php

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,27 @@
2121
class ConfigOptionsList implements ConfigOptionsListInterface
2222
{
2323
/**
24-
* Input key for the option
25-
*/
26-
private const INPUT_KEY_SALT ='id_salt';
27-
28-
/**
29-
* Path to the values in the deployment config
24+
* @var Random
3025
*/
31-
private const CONFIG_PATH_SALT = 'cache/graphql/id_salt';
26+
private $random;
3227

3328
/**
34-
* @var Random
29+
* Deployment configuration
30+
*
31+
* @var DeploymentConfig
3532
*/
36-
private $random;
33+
private $deploymentConfig;
3734

3835
/**
3936
* @param Random $random
37+
* @param DeploymentConfig $deploymentConfig
4038
*/
41-
public function __construct(Random $random)
42-
{
39+
public function __construct(
40+
Random $random,
41+
DeploymentConfig $deploymentConfig
42+
) {
4343
$this->random = $random;
44+
$this->deploymentConfig = $deploymentConfig;
4445
}
4546

4647
/**
@@ -50,9 +51,9 @@ public function getOptions(): array
5051
{
5152
return [
5253
new TextConfigOption(
53-
self::INPUT_KEY_SALT,
54+
ConfigOptionsListConstants::INPUT_KEY_SALT,
5455
TextConfigOption::FRONTEND_WIZARD_TEXT,
55-
self::CONFIG_PATH_SALT,
56+
ConfigOptionsListConstants::CONFIG_PATH_SALT,
5657
'GraphQl Salt'
5758
),
5859
];
@@ -64,11 +65,18 @@ public function getOptions(): array
6465
*/
6566
public function createConfig(array $data, DeploymentConfig $deploymentConfig)
6667
{
68+
$currentIdSalt = $this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_SALT);
69+
6770
$configData = new ConfigData(ConfigFilePool::APP_ENV);
6871

69-
if (!$this->isDataEmpty($data, self::INPUT_KEY_SALT)) {
70-
$salt = $this->random->getRandomString(ConfigOptionsListConstants::STORE_KEY_RANDOM_STRING_SIZE);
71-
$configData->set(self::CONFIG_PATH_SALT, $salt);
72+
// Use given salt if set, else use current
73+
$id_salt = $data[ConfigOptionsListConstants::INPUT_KEY_SALT] ?? $currentIdSalt;
74+
75+
// If there is no id_salt given or currently set, generate a new one
76+
$id_salt = $id_salt ?? $this->random->getRandomString(ConfigOptionsListConstants::STORE_KEY_RANDOM_STRING_SIZE);
77+
78+
if (!$this->isDataEmpty($data, ConfigOptionsListConstants::INPUT_KEY_SALT)) {
79+
$configData->set(ConfigOptionsListConstants::CONFIG_PATH_SALT, $id_salt);
7280
}
7381

7482
return [$configData];

lib/internal/Magento/Framework/Config/ConfigOptionsListConstants.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class ConfigOptionsListConstants
4040
public const CONFIG_PATH_DB_LOGGER_LOG_EVERYTHING = 'db_logger/log_everything';
4141
public const CONFIG_PATH_DB_LOGGER_QUERY_TIME_THRESHOLD = 'db_logger/query_time_threshold';
4242
public const CONFIG_PATH_DB_LOGGER_INCLUDE_STACKTRACE = 'db_logger/include_stacktrace';
43+
public const CONFIG_PATH_SALT = 'cache/graphql/id_salt';
4344
/**#@-*/
4445

4546
/**
@@ -85,6 +86,7 @@ class ConfigOptionsListConstants
8586
public const INPUT_KEY_RESOURCE = 'resource';
8687
public const INPUT_KEY_SKIP_DB_VALIDATION = 'skip-db-validation';
8788
public const INPUT_KEY_CACHE_HOSTS = 'http-cache-hosts';
89+
public const INPUT_KEY_SALT = 'id_salt';
8890
/**#@-*/
8991

9092
/**#@+

0 commit comments

Comments
 (0)