diff --git a/typo3/sysext/backend/Tests/Unit/Controller/FormInlineAjaxControllerTest.php b/typo3/sysext/backend/Tests/Unit/Controller/FormInlineAjaxControllerTest.php index 2ea268c985fdae9bf3a1aaac0a754e3ea0b8c9b1..29ac7213842f487dbb3a49b27b33e21944ae19a6 100644 --- a/typo3/sysext/backend/Tests/Unit/Controller/FormInlineAjaxControllerTest.php +++ b/typo3/sysext/backend/Tests/Unit/Controller/FormInlineAjaxControllerTest.php @@ -25,6 +25,12 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase; final class FormInlineAjaxControllerTest extends UnitTestCase { + protected function setUp(): void + { + parent::setUp(); + $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = ''; + } + /** * @test */ diff --git a/typo3/sysext/core/Tests/Unit/Crypto/HashServiceTest.php b/typo3/sysext/core/Tests/Unit/Crypto/HashServiceTest.php index 81cda048270c38eb2c98ff829561339adcc706bd..7edd90f99d4129e60fb1dd631ba0e90fe7b72f98 100644 --- a/typo3/sysext/core/Tests/Unit/Crypto/HashServiceTest.php +++ b/typo3/sysext/core/Tests/Unit/Crypto/HashServiceTest.php @@ -26,10 +26,11 @@ final class HashServiceTest extends UnitTestCase { protected HashService $subject; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->subject = new HashService(); + $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = ''; } /** diff --git a/typo3/sysext/core/Tests/Unit/FormProtection/AbstractFormProtectionTest.php b/typo3/sysext/core/Tests/Unit/FormProtection/AbstractFormProtectionTest.php index d05ab6a73c2768a96b0fa875c489b5c7807a0f83..0e0d2b6585b0a108f3805fbd232bea80139c82da 100644 --- a/typo3/sysext/core/Tests/Unit/FormProtection/AbstractFormProtectionTest.php +++ b/typo3/sysext/core/Tests/Unit/FormProtection/AbstractFormProtectionTest.php @@ -31,11 +31,9 @@ final class AbstractFormProtectionTest extends UnitTestCase { parent::setUp(); $this->subject = new FormProtectionTesting(); + $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = ''; } - ///////////////////////////////////////// - // Tests concerning the basic functions - ///////////////////////////////////////// /** * @test */ @@ -85,9 +83,6 @@ final class AbstractFormProtectionTest extends UnitTestCase $subject->clean(); } - /////////////////////////////////// - // Tests concerning generateToken - /////////////////////////////////// /** * @test */ @@ -138,9 +133,6 @@ final class AbstractFormProtectionTest extends UnitTestCase self::assertEquals($this->subject->generateToken('foo', 'edit', 'bar'), $this->subject->generateToken('foo', 'edit', 'bar')); } - /////////////////////////////////// - // Tests concerning validateToken - /////////////////////////////////// /** * @test */ diff --git a/typo3/sysext/core/Tests/Unit/FormProtection/BackendFormProtectionTest.php b/typo3/sysext/core/Tests/Unit/FormProtection/BackendFormProtectionTest.php index 2d9a7d348736880ee572c6db59e5d080745ca28d..2848da7385a3e82cde04c22606995104663e7359 100644 --- a/typo3/sysext/core/Tests/Unit/FormProtection/BackendFormProtectionTest.php +++ b/typo3/sysext/core/Tests/Unit/FormProtection/BackendFormProtectionTest.php @@ -41,6 +41,7 @@ final class BackendFormProtectionTest extends UnitTestCase throw new \Exception('Closure called', 1442592030); } ); + $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = ''; } /** diff --git a/typo3/sysext/core/Tests/Unit/FormProtection/InstallToolFormProtectionTest.php b/typo3/sysext/core/Tests/Unit/FormProtection/InstallToolFormProtectionTest.php index 3dcf3167565c111614e5b03da55a920cdc03e5dc..4571d68407082fccf958a93811ae18fee3e6ba6a 100644 --- a/typo3/sysext/core/Tests/Unit/FormProtection/InstallToolFormProtectionTest.php +++ b/typo3/sysext/core/Tests/Unit/FormProtection/InstallToolFormProtectionTest.php @@ -23,6 +23,12 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase; final class InstallToolFormProtectionTest extends UnitTestCase { + protected function setUp(): void + { + parent::setUp(); + $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = ''; + } + /** * @test */ diff --git a/typo3/sysext/core/Tests/Unit/Page/ImportMapTest.php b/typo3/sysext/core/Tests/Unit/Page/ImportMapTest.php index f5f64a2670956a3ec5f9cef0c8d11df8a17cc345..211d58cce5afea52b83b226b665504d5da0f95a6 100644 --- a/typo3/sysext/core/Tests/Unit/Page/ImportMapTest.php +++ b/typo3/sysext/core/Tests/Unit/Page/ImportMapTest.php @@ -51,6 +51,7 @@ final class ImportMapTest extends UnitTestCase ); $this->backupPackageManager = \Closure::bind(fn(): PackageManager => ExtensionManagementUtility::$packageManager, null, ExtensionManagementUtility::class)(); ExtensionManagementUtility::setPackageManager($this->mockPackageManager()); + $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = ''; } protected function tearDown(): void diff --git a/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php b/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php index b35d054eb7df06f02ca1b73b2f4577e52eb12e67..a71f72ef819cb64021c64ec1e218235f44873a2e 100644 --- a/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php +++ b/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php @@ -1780,6 +1780,7 @@ final class GeneralUtilityTest extends UnitTestCase */ public function hmacReturnsHashOfProperLength(): void { + $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = ''; $hmac = GeneralUtility::hmac('message'); self::assertTrue(!empty($hmac) && is_string($hmac)); self::assertEquals(strlen($hmac), 40); @@ -1790,6 +1791,7 @@ final class GeneralUtilityTest extends UnitTestCase */ public function hmacReturnsEqualHashesForEqualInput(): void { + $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = ''; $msg0 = 'message'; $msg1 = 'message'; self::assertEquals(GeneralUtility::hmac($msg0), GeneralUtility::hmac($msg1)); @@ -1800,6 +1802,7 @@ final class GeneralUtilityTest extends UnitTestCase */ public function hmacReturnsNoEqualHashesForNonEqualInput(): void { + $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = ''; $msg0 = 'message0'; $msg1 = 'message1'; self::assertNotEquals(GeneralUtility::hmac($msg0), GeneralUtility::hmac($msg1)); diff --git a/typo3/sysext/form/Tests/Unit/Domain/Configuration/FormDefinitionConversionServiceTest.php b/typo3/sysext/form/Tests/Unit/Domain/Configuration/FormDefinitionConversionServiceTest.php index 9f2360b282e90dd92b6c68d35d9be41ead512051..f45864c60463223103e2e918ed3e742141718652 100644 --- a/typo3/sysext/form/Tests/Unit/Domain/Configuration/FormDefinitionConversionServiceTest.php +++ b/typo3/sysext/form/Tests/Unit/Domain/Configuration/FormDefinitionConversionServiceTest.php @@ -30,6 +30,7 @@ final class FormDefinitionConversionServiceTest extends UnitTestCase */ public function addHmacDataAddsHmacHashes(): void { + $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = ''; $formDefinitionConversionService = $this->getAccessibleMock( FormDefinitionConversionService::class, [ diff --git a/typo3/sysext/form/Tests/Unit/Domain/Configuration/FormDefinitionValidationServiceTest.php b/typo3/sysext/form/Tests/Unit/Domain/Configuration/FormDefinitionValidationServiceTest.php index 0c66bc9ecf422e7e4d546af830eb640dfecae2e3..3554fa39e7d5ccb4f6c06af61bf1d03bd1f3074e 100644 --- a/typo3/sysext/form/Tests/Unit/Domain/Configuration/FormDefinitionValidationServiceTest.php +++ b/typo3/sysext/form/Tests/Unit/Domain/Configuration/FormDefinitionValidationServiceTest.php @@ -247,7 +247,8 @@ final class FormDefinitionValidationServiceTest extends UnitTestCase public static function validateAllPropertyValuesFromCreatableFormElementDataProvider(): array { - $encryptionKeyBackup = $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']; + // Be aware that the $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] assignment in setUp is done + // after the dataProvider intitialization. Therefore, the encryption key must also be defined here. $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = '12345'; $sessionToken = '54321'; @@ -274,8 +275,9 @@ final class FormDefinitionValidationServiceTest extends UnitTestCase ], ]; - // be aware that backup globals does not impact globals used in data providers as these are called before the setUp/tearDown is done - $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = $encryptionKeyBackup; + // Unset global encryption key, so following tests do not use it. Data providers are not covered by phpunit backupGlobals. + // @todo: Refactor this out of the data provider. + unset($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']); return [ [ @@ -422,7 +424,8 @@ final class FormDefinitionValidationServiceTest extends UnitTestCase public static function validateAllPropertyValuesFromCreatablePropertyCollectionElementDataProvider(): array { - $encryptionKeyBackup = $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']; + // Be aware that the $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] assignment in setUp is done + // after the dataProvider intitialization. Therefore, the encryption key must also be defined here. $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = '12345'; $sessionToken = '54321'; @@ -449,8 +452,9 @@ final class FormDefinitionValidationServiceTest extends UnitTestCase ], ]; - // be aware that backup globals does not impact globals used in data providers as these are called before the setUp/tearDown is done - $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = $encryptionKeyBackup; + // Unset global encryption key, so following tests do not use it. Data providers are not covered by phpunit backupGlobals. + // @todo: Refactor this out of the data provider. + unset($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']); return [ [ diff --git a/typo3/sysext/frontend/Tests/Unit/Middleware/PageArgumentValidatorTest.php b/typo3/sysext/frontend/Tests/Unit/Middleware/PageArgumentValidatorTest.php index 7810e27eb5dace865f0b9e9d340d362589a1df18..308dd5165a9793470d2f26b5ee7b905ede9b6d2f 100644 --- a/typo3/sysext/frontend/Tests/Unit/Middleware/PageArgumentValidatorTest.php +++ b/typo3/sysext/frontend/Tests/Unit/Middleware/PageArgumentValidatorTest.php @@ -46,6 +46,7 @@ final class PageArgumentValidatorTest extends UnitTestCase return new Response(); } }; + $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = ''; } /**