‪TYPO3CMS  11.5
SilentConfigurationUpgradeServiceTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use PHPUnit\Framework\MockObject\MockObject;
21 use Prophecy\Argument;
22 use Prophecy\PhpUnit\ProphecyTrait;
26 use TYPO3\CMS\Core\Configuration\ConfigurationManager;
34 use TYPO3\CMS\Fluid\Core\Cache\FluidTemplateCache;
37 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
38 
42 class ‪SilentConfigurationUpgradeServiceTest extends UnitTestCase
43 {
44  use ProphecyTrait;
45 
49  protected ‪$configurationManager;
50 
54  protected ‪$backupPackageManager;
55 
59  protected function ‪setUp(): void
60  {
62  parent::setUp();
63  }
64 
68  protected function ‪tearDown(): void
69  {
71  parent::tearDown();
72  }
73 
77  protected function ‪createConfigurationManagerWithMockedMethods(array $methods): void
78  {
79  $this->configurationManager = $this->getMockBuilder(ConfigurationManager::class)
80  ->onlyMethods($methods)
81  ->getMock();
82  }
83 
88  {
89  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
90  SilentConfigurationUpgradeService::class,
91  ['dummy'],
92  [],
93  '',
94  false
95  );
96 
97  $obsoleteLocalConfigurationSettings = [
98  'SYS/form_enctype',
99  ];
100 
101  $currentLocalConfiguration = [
102  [$obsoleteLocalConfigurationSettings, true],
103  ];
105  [
106  'removeLocalConfigurationKeysByPath',
107  ]
108  );
109  $this->configurationManager->expects(self::once())
110  ->method('removeLocalConfigurationKeysByPath')
111  ->willReturnMap($currentLocalConfiguration);
112 
113  $this->expectException(ConfigurationChangedException::class);
114 
115  $silentConfigurationUpgradeServiceInstance->_set('obsoleteLocalConfigurationSettings', $obsoleteLocalConfigurationSettings);
116  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
117 
118  $silentConfigurationUpgradeServiceInstance->_call('removeObsoleteLocalConfigurationSettings');
119  }
120 
125  {
126  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
127  SilentConfigurationUpgradeService::class,
128  ['dummy'],
129  [],
130  '',
131  false
132  );
133 
134  $obsoleteLocalConfigurationSettings = [
135  'SYS/form_enctype',
136  ];
137 
138  $currentLocalConfiguration = [
139  [$obsoleteLocalConfigurationSettings, false],
140  ];
142  [
143  'removeLocalConfigurationKeysByPath',
144  ]
145  );
146  $this->configurationManager->expects(self::once())
147  ->method('removeLocalConfigurationKeysByPath')
148  ->willReturnMap($currentLocalConfiguration);
149 
150  $silentConfigurationUpgradeServiceInstance->_set('obsoleteLocalConfigurationSettings', $obsoleteLocalConfigurationSettings);
151  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
152 
153  $silentConfigurationUpgradeServiceInstance->_call('removeObsoleteLocalConfigurationSettings');
154  }
155 
159  public function ‪doNotGenerateEncryptionKeyIfExists(): void
160  {
161  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
162  SilentConfigurationUpgradeService::class,
163  ['dummy'],
164  [],
165  '',
166  false
167  );
168 
169  $currentLocalConfiguration = [
170  ['SYS/encryptionKey', 'EnCrYpTiOnKeY'],
171  ];
172 
174  [
175  'getLocalConfigurationValueByPath',
176  'setLocalConfigurationValueByPath',
177  ]
178  );
179  $this->configurationManager->expects(self::once())
180  ->method('getLocalConfigurationValueByPath')
181  ->willReturnMap($currentLocalConfiguration);
182  $this->configurationManager->expects(self::never())
183  ->method('setLocalConfigurationValueByPath');
184 
185  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
186 
187  $silentConfigurationUpgradeServiceInstance->_call('generateEncryptionKeyIfNeeded');
188  }
189 
193  public function ‪generateEncryptionKeyIfNotExists(): void
194  {
195  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
196  SilentConfigurationUpgradeService::class,
197  ['dummy'],
198  [],
199  '',
200  false
201  );
202 
203  $closure = static function () {
204  throw new ‪MissingArrayPathException('Path does not exist in array', 1476109266);
205  };
206 
208  [
209  'getLocalConfigurationValueByPath',
210  'setLocalConfigurationValueByPath',
211  ]
212  );
213  $this->configurationManager->expects(self::once())
214  ->method('getLocalConfigurationValueByPath')
215  ->willReturnCallback($closure);
216  $this->configurationManager->expects(self::once())
217  ->method('setLocalConfigurationValueByPath')
218  ->with(self::equalTo('SYS/encryptionKey'), self::isType('string'));
219 
220  $this->expectException(ConfigurationChangedException::class);
221 
222  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
223 
224  $silentConfigurationUpgradeServiceInstance->_call('generateEncryptionKeyIfNeeded');
225  }
226 
232  public function ‪httpSettingsMappingDataProvider(): array
233  {
234  return [
235  'No changes overridden in Local Configuration' => [
236  ['timeout' => 100],
237  ['HTTP/timeout' => 100],
238  false,
239  ],
240  'Old and unused settings removed' => [
241  ['adapter' => 'curl'],
242  [],
243  true,
244  ],
245  'Old and used settings changed' => [
246  ['protocol_version' => '1.1'],
247  ['HTTP/version' => '1.1'],
248  true,
249  ],
250 
252  'Redirects moved to default' => [
253  ['follow_redirects' => true],
254  [],
255  true,
256  ],
257  'Redirects moved #1' => [
258  ['follow_redirects' => true, 'max_redirects' => 200, 'strict_redirects' => false],
259  ['HTTP/allow_redirects' => ['max' => 200]],
260  true,
261  ],
262  'Redirects moved #2' => [
263  ['follow_redirects' => false, 'max_redirects' => 200, 'strict_redirects' => false],
264  ['HTTP/allow_redirects' => false],
265  true,
266  ],
267  'Redirects moved #3' => [
268  ['follow_redirects' => true, 'max_redirects' => 400, 'strict_redirects' => 1],
269  ['HTTP/allow_redirects' => ['max' => 400, 'strict' => true]],
270  true,
271  ],
272 
274  'Proxy host set' => [
275  ['proxy_host' => 'vpn.myproxy.com'],
276  ['HTTP/proxy' => 'http://vpn.myproxy.com'],
277  true,
278  ],
279  'Proxy host set + port' => [
280  ['proxy_host' => 'vpn.myproxy.com', 'proxy_port' => 8080],
281  ['HTTP/proxy' => 'http://vpn.myproxy.com:8080'],
282  true,
283  ],
284  'Proxy host set + port + verification' => [
285  ['proxy_host' => 'vpn.myproxy.com', 'proxy_port' => 8080, 'proxy_auth_scheme' => 'basic', 'proxy_user' => 'myuser', 'proxy_password' => 'mysecret'],
286  ['HTTP/proxy' => 'http://myuser:mysecret@vpn.myproxy.com:8080'],
287  true,
288  ],
289 
291  'Only ssl_capath set, invalid migration' => [
292  ['ssl_capath' => '/foo/bar/'],
293  [],
294  true,
295  ],
296  'Verification activated, but only ssl_capath set, using default' => [
297  ['ssl_verify_peer' => 1, 'ssl_capath' => '/foo/bar/'],
298  [],
299  true,
300  ],
301  'Verification activated, with ssl_capath and ssl_cafile set' => [
302  ['ssl_verify_peer' => 1, 'ssl_capath' => '/foo/bar/', 'ssl_cafile' => 'supersecret.crt'],
303  ['HTTP/verify' => '/foo/bar/supersecret.crt'],
304  true,
305  ],
306 
308  'SSL key certification' => [
309  ['ssl_local_cert' => '/foo/bar/supersecret.key'],
310  ['HTTP/ssl_key' => '/foo/bar/supersecret.key'],
311  true,
312  ],
313  'SSL key certification + passphrase' => [
314  ['ssl_local_cert' => '/foo/bar/supersecret.key', 'ssl_passphrase' => 'donotcopypasteme'],
315  ['HTTP/ssl_key' => ['/foo/bar/supersecret.key', 'donotcopypasteme']],
316  true,
317  ],
318  'SSL key passphrase only - no migration' => [
319  ['ssl_passphrase' => 'donotcopypasteme'],
320  [],
321  true,
322  ],
323  ];
324  }
325 
333  public function ‪transferHttpSettingsIfSet(array $currentLocalConfiguration, array $newSettings, bool $localConfigurationNeedsUpdate): void
334  {
335  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
336  SilentConfigurationUpgradeService::class,
337  ['dummy'],
338  [],
339  '',
340  false
341  );
342 
344  [
345  'setLocalConfigurationValuesByPathValuePairs',
346  'removeLocalConfigurationKeysByPath',
347  'getLocalConfiguration',
348  ]
349  );
350 
351  $this->configurationManager
352  ->method('getLocalConfiguration')
353  ->willReturn(['HTTP' => $currentLocalConfiguration]);
354  if ($localConfigurationNeedsUpdate) {
355  if (!empty($newSettings)) {
356  $this->configurationManager->expects(self::once())
357  ->method('setLocalConfigurationValuesByPathValuePairs')
358  ->with($newSettings);
359  }
360  $this->configurationManager->expects(self::atMost(1))->method('removeLocalConfigurationKeysByPath');
361  }
362 
363  if ($localConfigurationNeedsUpdate) {
364  $this->expectException(ConfigurationChangedException::class);
365  }
366 
367  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
368 
369  $silentConfigurationUpgradeServiceInstance->_call('transferHttpSettings');
370  }
371 
376  {
377  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
378  SilentConfigurationUpgradeService::class,
379  ['dummy'],
380  [],
381  '',
382  false
383  );
384 
385  $currentLocalConfiguration = [
386  ['GFX/im', 0],
387  ['GFX/im_path', ''],
388  ['GFX/im_path_lzw', ''],
389  ['GFX/imagefile_ext', 'gif,jpg,png'],
390  ['GFX/thumbnails', 0],
391  ];
393  [
394  'getLocalConfigurationValueByPath',
395  'getDefaultConfigurationValueByPath',
396  'setLocalConfigurationValuesByPathValuePairs',
397  ]
398  );
399  $this->configurationManager->expects(self::exactly(5))
400  ->method('getLocalConfigurationValueByPath')
401  ->willReturnMap($currentLocalConfiguration);
402  $this->configurationManager->expects(self::never())
403  ->method('getDefaultConfigurationValueByPath');
404  $this->configurationManager->expects(self::once())
405  ->method('setLocalConfigurationValuesByPathValuePairs')
406  ->withConsecutive(
407  [['GFX/imagefile_ext' => 'gif,jpg,jpeg,png']]
408  );
409 
410  $this->expectException(ConfigurationChangedException::class);
411 
412  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
413 
414  $silentConfigurationUpgradeServiceInstance->_call('disableImageMagickDetailSettingsIfImageMagickIsDisabled');
415  }
416 
421  {
422  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
423  SilentConfigurationUpgradeService::class,
424  ['dummy'],
425  [],
426  '',
427  false
428  );
429 
430  $currentLocalConfiguration = [
431  ['GFX/im', 1],
432  ['GFX/im_path', ''],
433  ['GFX/im_path_lzw', ''],
434  ['GFX/imagefile_ext', 'gif,jpg,jpeg,png'],
435  ['GFX/thumbnails', 0],
436  ];
438  [
439  'getLocalConfigurationValueByPath',
440  'getDefaultConfigurationValueByPath',
441  'setLocalConfigurationValuesByPathValuePairs',
442  ]
443  );
444  $this->configurationManager->expects(self::exactly(5))
445  ->method('getLocalConfigurationValueByPath')
446  ->willReturnMap($currentLocalConfiguration);
447  $this->configurationManager->expects(self::never())
448  ->method('getDefaultConfigurationValueByPath');
449  $this->configurationManager->expects(self::never())
450  ->method('setLocalConfigurationValuesByPathValuePairs');
451 
452  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
453 
454  $silentConfigurationUpgradeServiceInstance->_call('disableImageMagickDetailSettingsIfImageMagickIsDisabled');
455  }
456 
460  public function ‪setImageMagickDetailSettings(): void
461  {
462  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
463  SilentConfigurationUpgradeService::class,
464  ['dummy'],
465  [],
466  '',
467  false
468  );
469 
470  $currentLocalConfiguration = [
471  ['GFX/processor', 'GraphicsMagick'],
472  ['GFX/processor_allowTemporaryMasksAsPng', 1],
473  ['GFX/processor_effects', false],
474  ];
476  [
477  'getLocalConfigurationValueByPath',
478  'getDefaultConfigurationValueByPath',
479  'setLocalConfigurationValuesByPathValuePairs',
480  ]
481  );
482  $this->configurationManager->expects(self::exactly(3))
483  ->method('getLocalConfigurationValueByPath')
484  ->willReturnMap($currentLocalConfiguration);
485  $this->configurationManager->expects(self::never())
486  ->method('getDefaultConfigurationValueByPath');
487  $this->configurationManager->expects(self::once())
488  ->method('setLocalConfigurationValuesByPathValuePairs')
489  ->withConsecutive([
490  [
491  'GFX/processor_allowTemporaryMasksAsPng' => 0,
492  ],
493  ]);
494 
495  $this->expectException(ConfigurationChangedException::class);
496 
497  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
498 
499  $silentConfigurationUpgradeServiceInstance->_call('setImageMagickDetailSettings');
500  }
501 
505  public function ‪doNotSetImageMagickDetailSettings(): void
506  {
507  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
508  SilentConfigurationUpgradeService::class,
509  ['dummy'],
510  [],
511  '',
512  false
513  );
514 
515  $currentLocalConfiguration = [
516  ['GFX/processor', ''],
517  ['GFX/processor_allowTemporaryMasksAsPng', 0],
518  ['GFX/processor_effects', 0],
519  ];
521  [
522  'getLocalConfigurationValueByPath',
523  'getDefaultConfigurationValueByPath',
524  'setLocalConfigurationValuesByPathValuePairs',
525  ]
526  );
527  $this->configurationManager->expects(self::exactly(3))
528  ->method('getLocalConfigurationValueByPath')
529  ->willReturnMap($currentLocalConfiguration);
530  $this->configurationManager->expects(self::never())
531  ->method('getDefaultConfigurationValueByPath');
532  $this->configurationManager->expects(self::never())
533  ->method('setLocalConfigurationValuesByPathValuePairs');
534 
535  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
536 
537  $silentConfigurationUpgradeServiceInstance->_call('setImageMagickDetailSettings');
538  }
539 
547  public function ‪migratesGraphicsProcessorEffects($currentValue, bool $expectedMigratedValue): void
548  {
549  ‪$configurationManager = $this->prophesize(ConfigurationManager::class);
550  ‪$configurationManager->getLocalConfigurationValueByPath('GFX/processor')->willReturn('GraphicsMagick');
551  ‪$configurationManager->getLocalConfigurationValueByPath('GFX/processor_allowTemporaryMasksAsPng')->willReturn(false);
552  ‪$configurationManager->getLocalConfigurationValueByPath('GFX/processor_effects')->willReturn($currentValue);
553  ‪$configurationManager->setLocalConfigurationValuesByPathValuePairs([
554  'GFX/processor_effects' => $expectedMigratedValue,
555  ])->shouldBeCalled();
556 
557  $this->expectException(ConfigurationChangedException::class);
558 
559  $silentConfigurationUpgradeService = new ‪SilentConfigurationUpgradeService(‪$configurationManager->reveal());
560  // Call protected method
561  \Closure::bind(function () {
562  return $this->‪setImageMagickDetailSettings();
563  }, $silentConfigurationUpgradeService, SilentConfigurationUpgradeService::class)();
564  }
565 
569  public function ‪graphicsProcessorEffects(): array
570  {
571  return [
572  'integer 1' => [
573  1,
574  true,
575  ],
576  'integer 0' => [
577  0,
578  false,
579  ],
580  'integer -1' => [
581  -1,
582  false,
583  ],
584  'string "1"' => [
585  '1',
586  true,
587  ],
588  'string "0"' => [
589  '0',
590  false,
591  ],
592  'string "-1"' => [
593  '-1',
594  false,
595  ],
596  ];
597  }
598 
602  public function ‪migrateNonExistingLangDebug(): void
603  {
604  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
605  SilentConfigurationUpgradeService::class,
606  ['dummy'],
607  [],
608  '',
609  false
610  );
611 
612  $currentLocalConfiguration = [
613  ];
615  [
616  'getLocalConfigurationValueByPath',
617  'setLocalConfigurationValueByPath',
618  ]
619  );
620 
621  $this->configurationManager->expects(self::once())
622  ->method('getLocalConfigurationValueByPath')
623  ->willReturnMap($currentLocalConfiguration);
624  $this->configurationManager->expects(self::never())
625  ->method('setLocalConfigurationValueByPath');
626 
627  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
628 
629  $silentConfigurationUpgradeServiceInstance->_call('migrateLangDebug');
630  }
631 
635  public function ‪migrateExistingLangDebug(): void
636  {
637  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
638  SilentConfigurationUpgradeService::class,
639  ['dummy'],
640  [],
641  '',
642  false
643  );
644 
645  $currentLocalConfiguration = [
646  ['BE/lang/debug', false],
647  ];
649  [
650  'getLocalConfigurationValueByPath',
651  'setLocalConfigurationValueByPath',
652  ]
653  );
654 
655  $this->configurationManager->expects(self::once())
656  ->method('getLocalConfigurationValueByPath')
657  ->willReturnMap($currentLocalConfiguration);
658  $this->configurationManager->expects(self::once())
659  ->method('setLocalConfigurationValueByPath')
660  ->with(self::equalTo('BE/languageDebug'), false);
661 
662  $this->expectException(ConfigurationChangedException::class);
663  $this->expectExceptionCode(1379024938);
664 
665  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
666  $silentConfigurationUpgradeServiceInstance->_call('migrateLangDebug');
667  }
668 
672  public function ‪migrateCacheHashOptions(): void
673  {
674  $oldConfig = [
675  'FE/cHashOnlyForParameters' => 'foo,bar',
676  'FE/cHashExcludedParameters' => 'bar,foo',
677  'FE/cHashRequiredParameters' => 'bar,baz',
678  'FE/cHashExcludedParametersIfEmpty' => '*',
679  ];
680 
681  ‪$configurationManager = $this->prophesize(ConfigurationManager::class);
682 
683  foreach ($oldConfig as $key => $value) {
684  ‪$configurationManager->getLocalConfigurationValueByPath($key)
685  ->shouldBeCalled()
686  ->willReturn($value);
687  }
688 
689  ‪$configurationManager->setLocalConfigurationValuesByPathValuePairs(Argument::cetera())->shouldBeCalled();
690  ‪$configurationManager->removeLocalConfigurationKeysByPath(Argument::cetera())->shouldBeCalled();
691 
692  $this->expectException(ConfigurationChangedException::class);
693  $this->expectExceptionCode(1379024938);
694 
695  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
696  SilentConfigurationUpgradeService::class,
697  ['dummy'],
698  [],
699  '',
700  false
701  );
702 
703  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', ‪$configurationManager->reveal());
704  $silentConfigurationUpgradeServiceInstance->_call('migrateCacheHashOptions');
705  }
706 
711  {
712  $configurationManagerProphecy = $this->prophesize(ConfigurationManager::class);
713  $configurationManagerException = new ‪MissingArrayPathException('Path does not exist in array', 1533989414);
714  $configurationManagerProphecy->getLocalConfigurationValueByPath('EXTENSIONS/saltedpasswords')
715  ->shouldBeCalled()->willThrow($configurationManagerException);
716  $configurationManagerProphecy->setLocalConfigurationValuesByPathValuePairs(Argument::cetera())
717  ->shouldNotBeCalled();
718  $silentConfigurationUpgradeService = $this->getAccessibleMock(
719  SilentConfigurationUpgradeService::class,
720  ['dummy'],
721  [$configurationManagerProphecy->reveal()]
722  );
723  $silentConfigurationUpgradeService->_call('migrateSaltedPasswordsSettings');
724  }
725 
730  {
731  $configurationManagerProphecy = $this->prophesize(ConfigurationManager::class);
732  $configurationManagerProphecy->getLocalConfigurationValueByPath('EXTENSIONS/saltedpasswords')
733  ->shouldBeCalled()->willReturn([]);
734  $configurationManagerProphecy->setLocalConfigurationValuesByPathValuePairs(Argument::cetera())
735  ->shouldNotBeCalled();
736  $silentConfigurationUpgradeService = $this->getAccessibleMock(
737  SilentConfigurationUpgradeService::class,
738  ['dummy'],
739  [$configurationManagerProphecy->reveal()]
740  );
741  $silentConfigurationUpgradeService->_call('migrateSaltedPasswordsSettings');
742  }
743 
748  {
749  $configurationManagerProphecy = $this->prophesize(ConfigurationManager::class);
750  $configurationManagerProphecy->getLocalConfigurationValueByPath('EXTENSIONS/saltedpasswords')
751  ->shouldBeCalled()->willReturn(['thereIs' => 'something']);
752  $argonBeProphecy = $this->prophesize(Argon2iPasswordHash::class);
753  $argonBeProphecy->isAvailable()->shouldBeCalled()->willReturn(true);
754  GeneralUtility::addInstance(Argon2iPasswordHash::class, $argonBeProphecy->reveal());
755  $argonFeProphecy = $this->prophesize(Argon2iPasswordHash::class);
756  $argonFeProphecy->isAvailable()->shouldBeCalled()->willReturn(true);
757  GeneralUtility::addInstance(Argon2iPasswordHash::class, $argonFeProphecy->reveal());
758  $configurationManagerProphecy->removeLocalConfigurationKeysByPath(['EXTENSIONS/saltedpasswords'])
759  ->shouldBeCalled();
760  $silentConfigurationUpgradeService = $this->getAccessibleMock(
761  SilentConfigurationUpgradeService::class,
762  ['dummy'],
763  [$configurationManagerProphecy->reveal()]
764  );
765  $this->expectException(ConfigurationChangedException::class);
766  $this->expectExceptionCode(1379024938);
767  $silentConfigurationUpgradeService->_call('migrateSaltedPasswordsSettings');
768  }
769 
774  {
775  $configurationManagerProphecy = $this->prophesize(ConfigurationManager::class);
776  $configurationManagerProphecy->getLocalConfigurationValueByPath('EXTENSIONS/saltedpasswords')
777  ->shouldBeCalled()->willReturn(['thereIs' => 'something']);
778  $argon2idBeProphecy = $this->prophesize(Argon2idPasswordHash::class);
779  $argon2idBeProphecy->isAvailable()->shouldBeCalled()->willReturn(false);
780  GeneralUtility::addInstance(Argon2idPasswordHash::class, $argon2idBeProphecy->reveal());
781  $argonBeProphecy = $this->prophesize(Argon2iPasswordHash::class);
782  $argonBeProphecy->isAvailable()->shouldBeCalled()->willReturn(false);
783  GeneralUtility::addInstance(Argon2iPasswordHash::class, $argonBeProphecy->reveal());
784  $bcryptBeProphecy = $this->prophesize(BcryptPasswordHash::class);
785  $bcryptBeProphecy->isAvailable()->shouldBeCalled()->willReturn(true);
786  GeneralUtility::addInstance(BcryptPasswordHash::class, $bcryptBeProphecy->reveal());
787  $argon2idFeProphecy = $this->prophesize(Argon2idPasswordHash::class);
788  $argon2idFeProphecy->isAvailable()->shouldBeCalled()->willReturn(false);
789  GeneralUtility::addInstance(Argon2idPasswordHash::class, $argon2idFeProphecy->reveal());
790  $argonFeProphecy = $this->prophesize(Argon2iPasswordHash::class);
791  $argonFeProphecy->isAvailable()->shouldBeCalled()->willReturn(false);
792  GeneralUtility::addInstance(Argon2iPasswordHash::class, $argonFeProphecy->reveal());
793  $bcryptFeProphecy = $this->prophesize(BcryptPasswordHash::class);
794  $bcryptFeProphecy->isAvailable()->shouldBeCalled()->willReturn(true);
795  GeneralUtility::addInstance(BcryptPasswordHash::class, $bcryptFeProphecy->reveal());
796  $configurationManagerProphecy->setLocalConfigurationValuesByPathValuePairs([
797  'BE/passwordHashing/className' => BcryptPasswordHash::class,
798  'FE/passwordHashing/className' => BcryptPasswordHash::class,
799  ])->shouldBeCalled();
800  $configurationManagerProphecy->removeLocalConfigurationKeysByPath(['EXTENSIONS/saltedpasswords'])
801  ->shouldBeCalled();
802  $silentConfigurationUpgradeService = $this->getAccessibleMock(
803  SilentConfigurationUpgradeService::class,
804  ['dummy'],
805  [$configurationManagerProphecy->reveal()]
806  );
807  $this->expectException(ConfigurationChangedException::class);
808  $this->expectExceptionCode(1379024938);
809  $silentConfigurationUpgradeService->_call('migrateSaltedPasswordsSettings');
810  }
811 
815  public function ‪migrateCachingFrameworkCachesMigratesData(): void
816  {
817  $oldCacheConfigurations = [
818  'cache_rootline' => [
819  'frontend' => VariableFrontend::class,
820  'backend' => Typo3DatabaseBackend::class,
821  'options' => [
822  'defaultLifetime' => 2592000,
823  ],
824  'groups' => ['pages'],
825  ],
826  'fluid_template' => [
827  'backend' => SimpleFileBackend::class,
828  'frontend' => FluidTemplateCache::class,
829  'groups' => ['system'],
830  ],
831  ];
832  $newCacheConfigurations = [
833  'rootline' => [
834  'frontend' => VariableFrontend::class,
835  'backend' => Typo3DatabaseBackend::class,
836  'options' => [
837  'defaultLifetime' => 2592000,
838  ],
839  'groups' => ['pages'],
840  ],
841  'fluid_template' => [
842  'backend' => SimpleFileBackend::class,
843  'frontend' => FluidTemplateCache::class,
844  'groups' => ['system'],
845  ],
846  ];
847  ‪$configurationManager = $this->prophesize(ConfigurationManager::class);
848  ‪$configurationManager->getLocalConfigurationValueByPath('SYS/caching/cacheConfigurations')
849  ->shouldBeCalled()
850  ->willReturn($oldCacheConfigurations);
851 
852  ‪$configurationManager->setLocalConfigurationValueByPath('SYS/caching/cacheConfigurations', $newCacheConfigurations)->shouldBeCalled();
853 
854  $this->expectException(ConfigurationChangedException::class);
855  $this->expectExceptionCode(1379024938);
856 
857  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
858  SilentConfigurationUpgradeService::class,
859  ['dummy'],
860  [],
861  '',
862  false
863  );
864 
865  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', ‪$configurationManager->reveal());
866  $silentConfigurationUpgradeServiceInstance->_call('migrateCachingFrameworkCaches');
867  }
868 
873  {
874  $oldCacheConfigurations = [
875  'rootline' => [
876  'frontend' => VariableFrontend::class,
877  'backend' => Typo3DatabaseBackend::class,
878  'options' => [
879  'defaultLifetime' => 2592000,
880  ],
881  'groups' => ['pages'],
882  ],
883  'fluid_template' => [
884  'backend' => SimpleFileBackend::class,
885  'frontend' => FluidTemplateCache::class,
886  'groups' => ['system'],
887  ],
888  ];
889  ‪$configurationManager = $this->prophesize(ConfigurationManager::class);
890  ‪$configurationManager->getLocalConfigurationValueByPath('SYS/caching/cacheConfigurations')
891  ->shouldBeCalled()
892  ->willReturn($oldCacheConfigurations);
893 
894  ‪$configurationManager->setLocalConfigurationValueByPath(Argument::cetera())->shouldNotBeCalled();
895 
896  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
897  SilentConfigurationUpgradeService::class,
898  ['dummy'],
899  [],
900  '',
901  false
902  );
903 
904  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', ‪$configurationManager->reveal());
905  $silentConfigurationUpgradeServiceInstance->_call('migrateCachingFrameworkCaches');
906  }
907 
909  {
910  return [
911  'empty string is kept' => [
912  '',
913  ],
914  'explicitAllow is kept' => [
915  'explicitAllow',
916  ],
917  'explicitDeny is kept' => [
918  'explicitDeny',
919  ],
920  'something else is kept' => [
921  'something',
922  ],
923  ];
924  }
925 
930  public function ‪migrateExplicitADmodeKeepsCurrentValue(string $value): void
931  {
932  ‪$configurationManager = $this->prophesize(ConfigurationManager::class);
933  ‪$configurationManager->getLocalConfigurationValueByPath('BE/explicitADmode')
934  ->shouldBeCalled()
935  ->willReturn($value);
936  ‪$configurationManager->setLocalConfigurationValueByPath(Argument::cetera())->shouldNotBeCalled();
937  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
938  SilentConfigurationUpgradeService::class,
939  ['dummy'],
940  [],
941  '',
942  false
943  );
944  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', ‪$configurationManager->reveal());
945  $silentConfigurationUpgradeServiceInstance->_call('migrateExplicitADmode');
946  }
947 
951  public function ‪migrateExplicitADmodeMigratesIfNeeded(): void
952  {
953  ‪$configurationManager = $this->prophesize(ConfigurationManager::class);
954  ‪$configurationManager->getLocalConfigurationValueByPath('BE/explicitADmode')
955  ->shouldBeCalled()
956  ->willThrow(new MissingArrayPathException('Path does not exist in array', 1628189230));
957  ‪$configurationManager->setLocalConfigurationValueByPath('BE/explicitADmode', 'explicitDeny')->shouldBeCalled();
958  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
959  SilentConfigurationUpgradeService::class,
960  ['dummy'],
961  [],
962  '',
963  false
964  );
965  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', ‪$configurationManager->reveal());
966  $this->expectException(ConfigurationChangedException::class);
967  $this->expectExceptionCode(1379024938);
968  $silentConfigurationUpgradeServiceInstance->_call('migrateExplicitADmode');
969  }
970 }
‪TYPO3\CMS\Core\Crypto\PasswordHashing\BcryptPasswordHash
Definition: BcryptPasswordHash.php:32
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateSaltedPasswordsSettingsDoesNothingIfExtensionConfigsAreNotSet
‪migrateSaltedPasswordsSettingsDoesNothingIfExtensionConfigsAreNotSet()
Definition: SilentConfigurationUpgradeServiceTest.php:707
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateSaltedPasswordsSettingsDoesNothingIfExtensionConfigsAreEmpty
‪migrateSaltedPasswordsSettingsDoesNothingIfExtensionConfigsAreEmpty()
Definition: SilentConfigurationUpgradeServiceTest.php:726
‪TYPO3\CMS\Install\Service\Exception\ConfigurationChangedException
Definition: ConfigurationChangedException.php:25
‪TYPO3\CMS\Core\Package\UnitTestPackageManager
Definition: UnitTestPackageManager.php:25
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateNonExistingLangDebug
‪migrateNonExistingLangDebug()
Definition: SilentConfigurationUpgradeServiceTest.php:599
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migratesGraphicsProcessorEffects
‪migratesGraphicsProcessorEffects($currentValue, bool $expectedMigratedValue)
Definition: SilentConfigurationUpgradeServiceTest.php:544
‪TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService
Definition: SilentConfigurationUpgradeService.php:43
‪TYPO3\CMS\Core\Utility\Exception\MissingArrayPathException
Definition: MissingArrayPathException.php:27
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\doNotSetImageMagickDetailSettings
‪doNotSetImageMagickDetailSettings()
Definition: SilentConfigurationUpgradeServiceTest.php:502
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\setImageMagickDetailSettings
‪setImageMagickDetailSettings()
Definition: SilentConfigurationUpgradeServiceTest.php:457
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\removeObsoleteLocalConfigurationSettingsIfThereAreOldSettings
‪removeObsoleteLocalConfigurationSettingsIfThereAreOldSettings()
Definition: SilentConfigurationUpgradeServiceTest.php:84
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateSaltedPasswordsSetsSpecificHashMethodIfArgon2idAndArgon2iIsNotAvailable
‪migrateSaltedPasswordsSetsSpecificHashMethodIfArgon2idAndArgon2iIsNotAvailable()
Definition: SilentConfigurationUpgradeServiceTest.php:770
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateCachingFrameworkCachesMigratesData
‪migrateCachingFrameworkCachesMigratesData()
Definition: SilentConfigurationUpgradeServiceTest.php:812
‪TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend
Definition: Typo3DatabaseBackend.php:30
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateCachingFrameworkCachesDoesNotMigrateWithoutPrefix
‪migrateCachingFrameworkCachesDoesNotMigrateWithoutPrefix()
Definition: SilentConfigurationUpgradeServiceTest.php:869
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\transferHttpSettingsIfSet
‪transferHttpSettingsIfSet(array $currentLocalConfiguration, array $newSettings, bool $localConfigurationNeedsUpdate)
Definition: SilentConfigurationUpgradeServiceTest.php:330
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\setPackageManager
‪static setPackageManager(PackageManager $packageManager)
Definition: ExtensionManagementUtility.php:66
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\generateEncryptionKeyIfNotExists
‪generateEncryptionKeyIfNotExists()
Definition: SilentConfigurationUpgradeServiceTest.php:190
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\createConfigurationManagerWithMockedMethods
‪createConfigurationManagerWithMockedMethods(array $methods)
Definition: SilentConfigurationUpgradeServiceTest.php:74
‪TYPO3\CMS\Core\Cache\Frontend\VariableFrontend
Definition: VariableFrontend.php:25
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateExplicitADmodeKeepsCurrentValueDataProvider
‪migrateExplicitADmodeKeepsCurrentValueDataProvider()
Definition: SilentConfigurationUpgradeServiceTest.php:905
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\graphicsProcessorEffects
‪array graphicsProcessorEffects()
Definition: SilentConfigurationUpgradeServiceTest.php:566
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateSaltedPasswordsSettingsRemovesExtensionsConfigAndSetsNothingElseIfArgon2iIsAvailable
‪migrateSaltedPasswordsSettingsRemovesExtensionsConfigAndSetsNothingElseIfArgon2iIsAvailable()
Definition: SilentConfigurationUpgradeServiceTest.php:744
‪TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend
Definition: SimpleFileBackend.php:33
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateExistingLangDebug
‪migrateExistingLangDebug()
Definition: SilentConfigurationUpgradeServiceTest.php:632
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateExplicitADmodeKeepsCurrentValue
‪migrateExplicitADmodeKeepsCurrentValue(string $value)
Definition: SilentConfigurationUpgradeServiceTest.php:927
‪TYPO3\CMS\Core\Tests\Unit\Utility\AccessibleProxies\ExtensionManagementUtilityAccessibleProxy\getPackageManager
‪static getPackageManager()
Definition: ExtensionManagementUtilityAccessibleProxy.php:35
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\tearDown
‪tearDown()
Definition: SilentConfigurationUpgradeServiceTest.php:65
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\$backupPackageManager
‪UnitTestPackageManager $backupPackageManager
Definition: SilentConfigurationUpgradeServiceTest.php:51
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\httpSettingsMappingDataProvider
‪array httpSettingsMappingDataProvider()
Definition: SilentConfigurationUpgradeServiceTest.php:229
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\doNotDisableImageMagickDetailSettingsIfImageMagickIsEnabled
‪doNotDisableImageMagickDetailSettingsIfImageMagickIsEnabled()
Definition: SilentConfigurationUpgradeServiceTest.php:417
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\disableImageMagickDetailSettingsIfImageMagickIsDisabled
‪disableImageMagickDetailSettingsIfImageMagickIsDisabled()
Definition: SilentConfigurationUpgradeServiceTest.php:372
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateCacheHashOptions
‪migrateCacheHashOptions()
Definition: SilentConfigurationUpgradeServiceTest.php:669
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateExplicitADmodeMigratesIfNeeded
‪migrateExplicitADmodeMigratesIfNeeded()
Definition: SilentConfigurationUpgradeServiceTest.php:948
‪TYPO3\CMS\Core\Tests\Unit\Utility\AccessibleProxies\ExtensionManagementUtilityAccessibleProxy
Definition: ExtensionManagementUtilityAccessibleProxy.php:29
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\doNotGenerateEncryptionKeyIfExists
‪doNotGenerateEncryptionKeyIfExists()
Definition: SilentConfigurationUpgradeServiceTest.php:156
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\setUp
‪setUp()
Definition: SilentConfigurationUpgradeServiceTest.php:56
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\doNotRemoveObsoleteLocalConfigurationSettingsIfThereAreNoOldSettings
‪doNotRemoveObsoleteLocalConfigurationSettingsIfThereAreNoOldSettings()
Definition: SilentConfigurationUpgradeServiceTest.php:121
‪TYPO3\CMS\Install\Tests\Unit\Service
Definition: ClearTableServiceTest.php:18
‪TYPO3\CMS\Core\Crypto\PasswordHashing\Argon2idPasswordHash
Definition: Argon2idPasswordHash.php:31
‪TYPO3\CMS\Core\Crypto\PasswordHashing\Argon2iPasswordHash
Definition: Argon2iPasswordHash.php:31
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\$configurationManager
‪ConfigurationManager MockObject $configurationManager
Definition: SilentConfigurationUpgradeServiceTest.php:47
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest
Definition: SilentConfigurationUpgradeServiceTest.php:43