From d205405dcc9be9bbfa02dd6b86226c823be157f9 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Wed, 1 Jan 2020 11:27:09 +0100 Subject: [PATCH] Updated DeprecatedConfigParser to remove the secret key --- .../Core/src/Config/DeprecatedConfigParser.php | 9 ++++++++- .../test/Config/DeprecatedConfigParserTest.php | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/module/Core/src/Config/DeprecatedConfigParser.php b/module/Core/src/Config/DeprecatedConfigParser.php index 059c81a9..92074bfc 100644 --- a/module/Core/src/Config/DeprecatedConfigParser.php +++ b/module/Core/src/Config/DeprecatedConfigParser.php @@ -10,7 +10,7 @@ class DeprecatedConfigParser { public function __invoke(array $config): array { - return compose([$this, 'parseNotFoundRedirect'])($config); + return compose([$this, 'parseNotFoundRedirect'], [$this, 'removeSecretKey'])($config); } public function parseNotFoundRedirect(array $config): array @@ -30,4 +30,11 @@ class DeprecatedConfigParser return $config; } + + public function removeSecretKey(array $config): array + { + // Removing secret_key from any generated config will prevent the AppOptions object from crashing + unset($config['app_options']['secret_key']); + return $config; + } } diff --git a/module/Core/test/Config/DeprecatedConfigParserTest.php b/module/Core/test/Config/DeprecatedConfigParserTest.php index 3d6d4815..0da1d314 100644 --- a/module/Core/test/Config/DeprecatedConfigParserTest.php +++ b/module/Core/test/Config/DeprecatedConfigParserTest.php @@ -91,4 +91,21 @@ class DeprecatedConfigParserTest extends TestCase $this->assertEquals($expected, $result); } + + /** @test */ + public function removesTheOldSecretKey(): void + { + $config = [ + 'app_options' => [ + 'secret_key' => 'foobar', + ], + ]; + $expected = [ + 'app_options' => [], + ]; + + $result = ($this->postProcessor)($config); + + $this->assertEquals($expected, $result); + } }