‪TYPO3CMS  10.4
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 Prophecy\Argument;
21 use Prophecy\Prophecy\ObjectProphecy;
25 use TYPO3\CMS\Core\Configuration\ConfigurationManager;
29 use TYPO3\CMS\Core\Package\PackageManager;
34 use TYPO3\CMS\Fluid\Core\Cache\FluidTemplateCache;
37 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
38 
42 class ‪SilentConfigurationUpgradeServiceTest extends UnitTestCase
43 {
47  protected ‪$configurationManager;
48 
52  protected ‪$backupPackageManager;
53 
57  protected function ‪setUp(): void
58  {
60  parent::setUp();
61  }
62 
66  protected function ‪tearDown(): void
67  {
69  parent::tearDown();
70  }
71 
75  protected function ‪createConfigurationManagerWithMockedMethods(array $methods)
76  {
77  $this->configurationManager = $this->getMockBuilder(ConfigurationManager::class)
78  ->setMethods($methods)
79  ->getMock();
80  }
81 
88  {
89  return [
90  ['', 'rsa', true, false],
91  ['normal', 'rsa', true, true],
92  ['rsa', 'normal', false, true],
93  ];
94  }
95 
104  public function ‪configureBackendLoginSecurity($current, $setting, $isPackageActive, $hasLocalConfig)
105  {
107  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
108  SilentConfigurationUpgradeService::class,
109  ['dummy'],
110  [],
111  '',
112  false
113  );
114 
116  $packageManager = $this->createMock(PackageManager::class);
117  $packageManager->expects(self::any())
118  ->method('isPackageActive')
119  ->willReturn($isPackageActive);
121 
122  $currentLocalConfiguration = [
123  ['BE/loginSecurityLevel', $current]
124  ];
125  $closure = function () {
126  throw new ‪MissingArrayPathException('Path does not exist in array', 1538160231);
127  };
128 
130  [
131  'getLocalConfigurationValueByPath',
132  'setLocalConfigurationValueByPath',
133  ]
134  );
135  if ($hasLocalConfig) {
136  $this->configurationManager->expects(self::once())
137  ->method('getLocalConfigurationValueByPath')
138  ->willReturnMap($currentLocalConfiguration);
139  } else {
140  $this->configurationManager->expects(self::once())
141  ->method('getLocalConfigurationValueByPath')
142  ->willReturnCallback($closure);
143  }
144  $this->configurationManager->expects(self::once())
145  ->method('setLocalConfigurationValueByPath')
146  ->with(self::equalTo('BE/loginSecurityLevel'), self::equalTo($setting));
147 
148  $this->expectException(ConfigurationChangedException::class);
149 
150  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
151 
152  $silentConfigurationUpgradeServiceInstance->_call('configureBackendLoginSecurity');
153  }
154 
161  {
162  return [
163  ['', 'rsa', true, false],
164  ['normal', 'rsa', true, true],
165  ['rsa', 'normal', false, true],
166  ];
167  }
168 
177  public function ‪configureFrontendLoginSecurity($current, $setting, $isPackageActive, $hasLocalConfig)
178  {
180  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
181  SilentConfigurationUpgradeService::class,
182  ['dummy'],
183  [],
184  '',
185  false
186  );
187 
189  $packageManager = $this->createMock(PackageManager::class);
190  $packageManager->expects(self::any())
191  ->method('isPackageActive')
192  ->willReturn($isPackageActive);
194 
195  $currentLocalConfiguration = [
196  ['FE/loginSecurityLevel', $current]
197  ];
198  $closure = function () {
199  throw new ‪MissingArrayPathException('Path does not exist in array', 1476109311);
200  };
201 
203  [
204  'getLocalConfigurationValueByPath',
205  'setLocalConfigurationValueByPath',
206  ]
207  );
208  if ($hasLocalConfig) {
209  $this->configurationManager->expects(self::once())
210  ->method('getLocalConfigurationValueByPath')
211  ->willReturnMap($currentLocalConfiguration);
212  } else {
213  $this->configurationManager->expects(self::once())
214  ->method('getLocalConfigurationValueByPath')
215  ->willReturnCallback($closure);
216  }
217  if ($isPackageActive === false) {
218  $this->configurationManager->expects(self::once())
219  ->method('setLocalConfigurationValueByPath')
220  ->with(self::equalTo('FE/loginSecurityLevel'), self::equalTo($setting));
221 
222  $this->expectException(ConfigurationChangedException::class);
223  }
224 
225  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
226 
227  $silentConfigurationUpgradeServiceInstance->_call('configureFrontendLoginSecurity');
228  }
229 
234  {
236  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
237  SilentConfigurationUpgradeService::class,
238  ['dummy'],
239  [],
240  '',
241  false
242  );
243 
244  $obsoleteLocalConfigurationSettings = [
245  'SYS/form_enctype',
246  ];
247 
248  $currentLocalConfiguration = [
249  [$obsoleteLocalConfigurationSettings, true]
250  ];
252  [
253  'removeLocalConfigurationKeysByPath',
254  ]
255  );
256  $this->configurationManager->expects(self::exactly(1))
257  ->method('removeLocalConfigurationKeysByPath')
258  ->willReturnMap($currentLocalConfiguration);
259 
260  $this->expectException(ConfigurationChangedException::class);
261 
262  $silentConfigurationUpgradeServiceInstance->_set('obsoleteLocalConfigurationSettings', $obsoleteLocalConfigurationSettings);
263  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
264 
265  $silentConfigurationUpgradeServiceInstance->_call('removeObsoleteLocalConfigurationSettings');
266  }
267 
272  {
274  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
275  SilentConfigurationUpgradeService::class,
276  ['dummy'],
277  [],
278  '',
279  false
280  );
281 
282  $obsoleteLocalConfigurationSettings = [
283  'SYS/form_enctype',
284  ];
285 
286  $currentLocalConfiguration = [
287  [$obsoleteLocalConfigurationSettings, false]
288  ];
290  [
291  'removeLocalConfigurationKeysByPath',
292  ]
293  );
294  $this->configurationManager->expects(self::exactly(1))
295  ->method('removeLocalConfigurationKeysByPath')
296  ->willReturnMap($currentLocalConfiguration);
297 
298  $silentConfigurationUpgradeServiceInstance->_set('obsoleteLocalConfigurationSettings', $obsoleteLocalConfigurationSettings);
299  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
300 
301  $silentConfigurationUpgradeServiceInstance->_call('removeObsoleteLocalConfigurationSettings');
302  }
303 
307  public function ‪doNotGenerateEncryptionKeyIfExists()
308  {
310  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
311  SilentConfigurationUpgradeService::class,
312  ['dummy'],
313  [],
314  '',
315  false
316  );
317 
318  $currentLocalConfiguration = [
319  ['SYS/encryptionKey', 'EnCrYpTiOnKeY']
320  ];
321 
323  [
324  'getLocalConfigurationValueByPath',
325  'setLocalConfigurationValueByPath',
326  ]
327  );
328  $this->configurationManager->expects(self::exactly(1))
329  ->method('getLocalConfigurationValueByPath')
330  ->willReturnMap($currentLocalConfiguration);
331  $this->configurationManager->expects(self::never())
332  ->method('setLocalConfigurationValueByPath');
333 
334  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
335 
336  $silentConfigurationUpgradeServiceInstance->_call('generateEncryptionKeyIfNeeded');
337  }
338 
342  public function ‪generateEncryptionKeyIfNotExists()
343  {
345  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
346  SilentConfigurationUpgradeService::class,
347  ['dummy'],
348  [],
349  '',
350  false
351  );
352 
353  $closure = function () {
354  throw new ‪MissingArrayPathException('Path does not exist in array', 1476109266);
355  };
356 
358  [
359  'getLocalConfigurationValueByPath',
360  'setLocalConfigurationValueByPath',
361  ]
362  );
363  $this->configurationManager->expects(self::exactly(1))
364  ->method('getLocalConfigurationValueByPath')
365  ->willReturnCallback($closure);
366  $this->configurationManager->expects(self::once())
367  ->method('setLocalConfigurationValueByPath')
368  ->with(self::equalTo('SYS/encryptionKey'), self::isType('string'));
369 
370  $this->expectException(ConfigurationChangedException::class);
371 
372  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
373 
374  $silentConfigurationUpgradeServiceInstance->_call('generateEncryptionKeyIfNeeded');
375  }
376 
382  public function ‪httpSettingsMappingDataProvider(): array
383  {
384  return [
385  'No changes overridden in Local Configuration' => [
386  ['timeout' => 100],
387  ['HTTP/timeout' => 100],
388  false
389  ],
390  'Old and unused settings removed' => [
391  ['adapter' => 'curl'],
392  [],
393  true
394  ],
395  'Old and used settings changed' => [
396  ['protocol_version' => '1.1'],
397  ['HTTP/version' => '1.1'],
398  true
399  ],
400 
402  'Redirects moved to default' => [
403  ['follow_redirects' => true],
404  [],
405  true
406  ],
407  'Redirects moved #1' => [
408  ['follow_redirects' => true, 'max_redirects' => 200, 'strict_redirects' => false],
409  ['HTTP/allow_redirects' => ['max' => 200]],
410  true
411  ],
412  'Redirects moved #2' => [
413  ['follow_redirects' => false, 'max_redirects' => 200, 'strict_redirects' => false],
414  ['HTTP/allow_redirects' => false],
415  true
416  ],
417  'Redirects moved #3' => [
418  ['follow_redirects' => true, 'max_redirects' => 400, 'strict_redirects' => 1],
419  ['HTTP/allow_redirects' => ['max' => 400, 'strict' => true]],
420  true
421  ],
422 
424  'Proxy host set' => [
425  ['proxy_host' => 'vpn.myproxy.com'],
426  ['HTTP/proxy' => 'http://vpn.myproxy.com'],
427  true
428  ],
429  'Proxy host set + port' => [
430  ['proxy_host' => 'vpn.myproxy.com', 'proxy_port' => 8080],
431  ['HTTP/proxy' => 'http://vpn.myproxy.com:8080'],
432  true
433  ],
434  'Proxy host set + port + verification' => [
435  ['proxy_host' => 'vpn.myproxy.com', 'proxy_port' => 8080, 'proxy_auth_scheme' => 'basic', 'proxy_user' => 'myuser', 'proxy_password' => 'mysecret'],
436  ['HTTP/proxy' => 'http://myuser:mysecret@vpn.myproxy.com:8080'],
437  true
438  ],
439 
441  'Only ssl_capath set, invalid migration' => [
442  ['ssl_capath' => '/foo/bar/'],
443  [],
444  true
445  ],
446  'Verification activated, but only ssl_capath set, using default' => [
447  ['ssl_verify_peer' => 1, 'ssl_capath' => '/foo/bar/'],
448  [],
449  true
450  ],
451  'Verification activated, with ssl_capath and ssl_cafile set' => [
452  ['ssl_verify_peer' => 1, 'ssl_capath' => '/foo/bar/', 'ssl_cafile' => 'supersecret.crt'],
453  ['HTTP/verify' => '/foo/bar/supersecret.crt'],
454  true
455  ],
456 
458  'SSL key certification' => [
459  ['ssl_local_cert' => '/foo/bar/supersecret.key'],
460  ['HTTP/ssl_key' => '/foo/bar/supersecret.key'],
461  true
462  ],
463  'SSL key certification + passphrase' => [
464  ['ssl_local_cert' => '/foo/bar/supersecret.key', 'ssl_passphrase' => 'donotcopypasteme'],
465  ['HTTP/ssl_key' => ['/foo/bar/supersecret.key', 'donotcopypasteme']],
466  true
467  ],
468  'SSL key passphrase only - no migration' => [
469  ['ssl_passphrase' => 'donotcopypasteme'],
470  [],
471  true
472  ],
473  ];
474  }
475 
483  public function ‪transferHttpSettingsIfSet($currentLocalConfiguration, $newSettings, $localConfigurationNeedsUpdate)
484  {
486  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
487  SilentConfigurationUpgradeService::class,
488  ['dummy'],
489  [],
490  '',
491  false
492  );
493 
495  [
496  'setLocalConfigurationValuesByPathValuePairs',
497  'removeLocalConfigurationKeysByPath',
498  'getLocalConfiguration'
499  ]
500  );
501 
502  $this->configurationManager->expects(self::any())
503  ->method('getLocalConfiguration')
504  ->willReturn(['HTTP' => $currentLocalConfiguration]);
505  if ($localConfigurationNeedsUpdate) {
506  if (!empty($newSettings)) {
507  $this->configurationManager->expects(self::once())
508  ->method('setLocalConfigurationValuesByPathValuePairs')
509  ->with($newSettings);
510  }
511  $this->configurationManager->expects(self::atMost(1))->method('removeLocalConfigurationKeysByPath');
512  }
513 
514  if ($localConfigurationNeedsUpdate) {
515  $this->expectException(ConfigurationChangedException::class);
516  }
517 
518  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
519 
520  $silentConfigurationUpgradeServiceInstance->_call('transferHttpSettings');
521  }
522 
527  {
529  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
530  SilentConfigurationUpgradeService::class,
531  ['dummy'],
532  [],
533  '',
534  false
535  );
536 
537  $currentLocalConfiguration = [
538  ['GFX/im', 0],
539  ['GFX/im_path', ''],
540  ['GFX/im_path_lzw', ''],
541  ['GFX/imagefile_ext', 'gif,jpg,png'],
542  ['GFX/thumbnails', 0]
543  ];
545  [
546  'getLocalConfigurationValueByPath',
547  'getDefaultConfigurationValueByPath',
548  'setLocalConfigurationValuesByPathValuePairs',
549  ]
550  );
551  $this->configurationManager->expects(self::exactly(5))
552  ->method('getLocalConfigurationValueByPath')
553  ->willReturnMap($currentLocalConfiguration);
554  $this->configurationManager->expects(self::never())
555  ->method('getDefaultConfigurationValueByPath');
556  $this->configurationManager->expects(self::once())
557  ->method('setLocalConfigurationValuesByPathValuePairs')
558  ->withConsecutive(
559  [['GFX/imagefile_ext' => 'gif,jpg,jpeg,png']]
560  );
561 
562  $this->expectException(ConfigurationChangedException::class);
563 
564  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
565 
566  $silentConfigurationUpgradeServiceInstance->_call('disableImageMagickDetailSettingsIfImageMagickIsDisabled');
567  }
568 
573  {
575  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
576  SilentConfigurationUpgradeService::class,
577  ['dummy'],
578  [],
579  '',
580  false
581  );
582 
583  $currentLocalConfiguration = [
584  ['GFX/im', 1],
585  ['GFX/im_path', ''],
586  ['GFX/im_path_lzw', ''],
587  ['GFX/imagefile_ext', 'gif,jpg,jpeg,png'],
588  ['GFX/thumbnails', 0]
589  ];
591  [
592  'getLocalConfigurationValueByPath',
593  'getDefaultConfigurationValueByPath',
594  'setLocalConfigurationValuesByPathValuePairs',
595  ]
596  );
597  $this->configurationManager->expects(self::exactly(5))
598  ->method('getLocalConfigurationValueByPath')
599  ->willReturnMap($currentLocalConfiguration);
600  $this->configurationManager->expects(self::never())
601  ->method('getDefaultConfigurationValueByPath');
602  $this->configurationManager->expects(self::never())
603  ->method('setLocalConfigurationValuesByPathValuePairs');
604 
605  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
606 
607  $silentConfigurationUpgradeServiceInstance->_call('disableImageMagickDetailSettingsIfImageMagickIsDisabled');
608  }
609 
613  public function ‪setImageMagickDetailSettings()
614  {
616  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
617  SilentConfigurationUpgradeService::class,
618  ['dummy'],
619  [],
620  '',
621  false
622  );
623 
624  $currentLocalConfiguration = [
625  ['GFX/processor', 'GraphicsMagick'],
626  ['GFX/processor_allowTemporaryMasksAsPng', 1],
627  ['GFX/processor_effects', false],
628  ];
630  [
631  'getLocalConfigurationValueByPath',
632  'getDefaultConfigurationValueByPath',
633  'setLocalConfigurationValuesByPathValuePairs',
634  ]
635  );
636  $this->configurationManager->expects(self::exactly(3))
637  ->method('getLocalConfigurationValueByPath')
638  ->willReturnMap($currentLocalConfiguration);
639  $this->configurationManager->expects(self::never())
640  ->method('getDefaultConfigurationValueByPath');
641  $this->configurationManager->expects(self::once())
642  ->method('setLocalConfigurationValuesByPathValuePairs')
643  ->withConsecutive([
644  [
645  'GFX/processor_allowTemporaryMasksAsPng' => 0,
646  ]
647  ]);
648 
649  $this->expectException(ConfigurationChangedException::class);
650 
651  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
652 
653  $silentConfigurationUpgradeServiceInstance->_call('setImageMagickDetailSettings');
654  }
655 
659  public function ‪doNotSetImageMagickDetailSettings()
660  {
662  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
663  SilentConfigurationUpgradeService::class,
664  ['dummy'],
665  [],
666  '',
667  false
668  );
669 
670  $currentLocalConfiguration = [
671  ['GFX/processor', ''],
672  ['GFX/processor_allowTemporaryMasksAsPng', 0],
673  ['GFX/processor_effects', 0],
674  ];
676  [
677  'getLocalConfigurationValueByPath',
678  'getDefaultConfigurationValueByPath',
679  'setLocalConfigurationValuesByPathValuePairs',
680  ]
681  );
682  $this->configurationManager->expects(self::exactly(3))
683  ->method('getLocalConfigurationValueByPath')
684  ->willReturnMap($currentLocalConfiguration);
685  $this->configurationManager->expects(self::never())
686  ->method('getDefaultConfigurationValueByPath');
687  $this->configurationManager->expects(self::never())
688  ->method('setLocalConfigurationValuesByPathValuePairs');
689 
690  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
691 
692  $silentConfigurationUpgradeServiceInstance->_call('setImageMagickDetailSettings');
693  }
694 
702  public function ‪migratesGraphicsProcessorEffects($currentValue, $expectedMigratedValue)
703  {
705  ‪$configurationManager = $this->prophesize(ConfigurationManager::class);
706  ‪$configurationManager->getLocalConfigurationValueByPath('GFX/processor')->willReturn('GraphicsMagick');
707  ‪$configurationManager->getLocalConfigurationValueByPath('GFX/processor_allowTemporaryMasksAsPng')->willReturn(false);
708  ‪$configurationManager->getLocalConfigurationValueByPath('GFX/processor_effects')->willReturn($currentValue);
709  ‪$configurationManager->setLocalConfigurationValuesByPathValuePairs([
710  'GFX/processor_effects' => $expectedMigratedValue,
711  ])->shouldBeCalled();
712 
713  $this->expectException(ConfigurationChangedException::class);
714 
715  $silentConfigurationUpgradeService = new ‪SilentConfigurationUpgradeService(‪$configurationManager->reveal());
716  // Call protected method
717  \Closure::bind(function () {
718  return $this->‪setImageMagickDetailSettings();
719  }, $silentConfigurationUpgradeService, SilentConfigurationUpgradeService::class)();
720  }
721 
725  public function ‪graphicsProcessorEffects(): array
726  {
727  return [
728  'integer 1' => [
729  1,
730  true,
731  ],
732  'integer 0' => [
733  0,
734  false,
735  ],
736  'integer -1' => [
737  -1,
738  false,
739  ],
740  'string "1"' => [
741  '1',
742  true,
743  ],
744  'string "0"' => [
745  '0',
746  false,
747  ],
748  'string "-1"' => [
749  '-1',
750  false,
751  ],
752  ];
753  }
754 
758  public function ‪migrateNonExistingLangDebug()
759  {
761  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
762  SilentConfigurationUpgradeService::class,
763  ['dummy'],
764  [],
765  '',
766  false
767  );
768 
769  $currentLocalConfiguration = [
770  ];
772  [
773  'getLocalConfigurationValueByPath',
774  'setLocalConfigurationValueByPath',
775  ]
776  );
777 
778  $this->configurationManager->expects(self::exactly(1))
779  ->method('getLocalConfigurationValueByPath')
780  ->willReturnMap($currentLocalConfiguration);
781  $this->configurationManager->expects(self::never())
782  ->method('setLocalConfigurationValueByPath');
783 
784  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
785 
786  $silentConfigurationUpgradeServiceInstance->_call('migrateLangDebug');
787  }
788 
792  public function ‪migrateExistingLangDebug()
793  {
795  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
796  SilentConfigurationUpgradeService::class,
797  ['dummy'],
798  [],
799  '',
800  false
801  );
802 
803  $currentLocalConfiguration = [
804  ['BE/lang/debug', false]
805  ];
807  [
808  'getLocalConfigurationValueByPath',
809  'setLocalConfigurationValueByPath',
810  ]
811  );
812 
813  $this->configurationManager->expects(self::exactly(1))
814  ->method('getLocalConfigurationValueByPath')
815  ->willReturnMap($currentLocalConfiguration);
816  $this->configurationManager->expects(self::once())
817  ->method('setLocalConfigurationValueByPath')
818  ->with(self::equalTo('BE/languageDebug'), false);
819 
820  $this->expectException(ConfigurationChangedException::class);
821  $this->expectExceptionCode(1379024938);
822 
823  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
824  $silentConfigurationUpgradeServiceInstance->_call('migrateLangDebug');
825  }
826 
830  public function ‪migrateCacheHashOptions()
831  {
832  $oldConfig = [
833  'FE/cHashOnlyForParameters' => 'foo,bar',
834  'FE/cHashExcludedParameters' => 'bar,foo',
835  'FE/cHashRequiredParameters' => 'bar,baz',
836  'FE/cHashExcludedParametersIfEmpty' => '*'
837  ];
838 
840  ‪$configurationManager = $this->prophesize(ConfigurationManager::class);
841 
842  foreach ($oldConfig as $key => $value) {
843  ‪$configurationManager->getLocalConfigurationValueByPath($key)
844  ->shouldBeCalled()
845  ->willReturn($value);
846  }
847 
848  ‪$configurationManager->setLocalConfigurationValuesByPathValuePairs(Argument::cetera())->shouldBeCalled();
849  ‪$configurationManager->removeLocalConfigurationKeysByPath(Argument::cetera())->shouldBeCalled();
850 
851  $this->expectException(ConfigurationChangedException::class);
852  $this->expectExceptionCode(1379024938);
853 
855  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
856  SilentConfigurationUpgradeService::class,
857  ['dummy'],
858  [],
859  '',
860  false
861  );
862 
863  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', ‪$configurationManager->reveal());
864  $silentConfigurationUpgradeServiceInstance->_call('migrateCacheHashOptions');
865  }
866 
871  {
872  $configurationManagerProphecy = $this->prophesize(ConfigurationManager::class);
873  $configurationManagerException = new ‪MissingArrayPathException('Path does not exist in array', 1533989414);
874  $configurationManagerProphecy->getLocalConfigurationValueByPath('EXTENSIONS/saltedpasswords')
875  ->shouldBeCalled()->willThrow($configurationManagerException);
876  $configurationManagerProphecy->setLocalConfigurationValuesByPathValuePairs(Argument::cetera())
877  ->shouldNotBeCalled();
878  $silentConfigurationUpgradeService = $this->getAccessibleMock(
879  SilentConfigurationUpgradeService::class,
880  ['dummy'],
881  [$configurationManagerProphecy->reveal()]
882  );
883  $silentConfigurationUpgradeService->_call('migrateSaltedPasswordsSettings');
884  }
885 
890  {
891  $configurationManagerProphecy = $this->prophesize(ConfigurationManager::class);
892  $configurationManagerProphecy->getLocalConfigurationValueByPath('EXTENSIONS/saltedpasswords')
893  ->shouldBeCalled()->willReturn([]);
894  $configurationManagerProphecy->setLocalConfigurationValuesByPathValuePairs(Argument::cetera())
895  ->shouldNotBeCalled();
896  $silentConfigurationUpgradeService = $this->getAccessibleMock(
897  SilentConfigurationUpgradeService::class,
898  ['dummy'],
899  [$configurationManagerProphecy->reveal()]
900  );
901  $silentConfigurationUpgradeService->_call('migrateSaltedPasswordsSettings');
902  }
903 
908  {
909  $configurationManagerProphecy = $this->prophesize(ConfigurationManager::class);
910  $configurationManagerException = new ‪MissingArrayPathException('Path does not exist in array', 1533989428);
911  $configurationManagerProphecy->getLocalConfigurationValueByPath('EXTENSIONS/saltedpasswords')
912  ->shouldBeCalled()->willReturn(['thereIs' => 'something']);
913  $argonBeProphecy = $this->prophesize(Argon2iPasswordHash::class);
914  $argonBeProphecy->isAvailable()->shouldBeCalled()->willReturn(true);
915  GeneralUtility::addInstance(Argon2iPasswordHash::class, $argonBeProphecy->reveal());
916  $argonFeProphecy = $this->prophesize(Argon2iPasswordHash::class);
917  $argonFeProphecy->isAvailable()->shouldBeCalled()->willReturn(true);
918  GeneralUtility::addInstance(Argon2iPasswordHash::class, $argonFeProphecy->reveal());
919  $configurationManagerProphecy->removeLocalConfigurationKeysByPath(['EXTENSIONS/saltedpasswords'])
920  ->shouldBeCalled();
921  $silentConfigurationUpgradeService = $this->getAccessibleMock(
922  SilentConfigurationUpgradeService::class,
923  ['dummy'],
924  [$configurationManagerProphecy->reveal()]
925  );
926  $this->expectException(ConfigurationChangedException::class);
927  $this->expectExceptionCode(1379024938);
928  $silentConfigurationUpgradeService->_call('migrateSaltedPasswordsSettings');
929  }
930 
935  {
936  $configurationManagerProphecy = $this->prophesize(ConfigurationManager::class);
937  $configurationManagerProphecy->getLocalConfigurationValueByPath('EXTENSIONS/saltedpasswords')
938  ->shouldBeCalled()->willReturn(['thereIs' => 'something']);
939  $argon2idBeProphecy = $this->prophesize(Argon2idPasswordHash::class);
940  $argon2idBeProphecy->isAvailable()->shouldBeCalled()->willReturn(false);
941  GeneralUtility::addInstance(Argon2idPasswordHash::class, $argon2idBeProphecy->reveal());
942  $argonBeProphecy = $this->prophesize(Argon2iPasswordHash::class);
943  $argonBeProphecy->isAvailable()->shouldBeCalled()->willReturn(false);
944  GeneralUtility::addInstance(Argon2iPasswordHash::class, $argonBeProphecy->reveal());
945  $bcryptBeProphecy = $this->prophesize(BcryptPasswordHash::class);
946  $bcryptBeProphecy->isAvailable()->shouldBeCalled()->willReturn(true);
947  GeneralUtility::addInstance(BcryptPasswordHash::class, $bcryptBeProphecy->reveal());
948  $argon2idFeProphecy = $this->prophesize(Argon2idPasswordHash::class);
949  $argon2idFeProphecy->isAvailable()->shouldBeCalled()->willReturn(false);
950  GeneralUtility::addInstance(Argon2idPasswordHash::class, $argon2idFeProphecy->reveal());
951  $argonFeProphecy = $this->prophesize(Argon2iPasswordHash::class);
952  $argonFeProphecy->isAvailable()->shouldBeCalled()->willReturn(false);
953  GeneralUtility::addInstance(Argon2iPasswordHash::class, $argonFeProphecy->reveal());
954  $bcryptFeProphecy = $this->prophesize(BcryptPasswordHash::class);
955  $bcryptFeProphecy->isAvailable()->shouldBeCalled()->willReturn(true);
956  GeneralUtility::addInstance(BcryptPasswordHash::class, $bcryptFeProphecy->reveal());
957  $configurationManagerProphecy->setLocalConfigurationValuesByPathValuePairs([
958  'BE/passwordHashing/className' => BcryptPasswordHash::class,
959  'FE/passwordHashing/className' => BcryptPasswordHash::class,
960  ])->shouldBeCalled();
961  $configurationManagerProphecy->removeLocalConfigurationKeysByPath(['EXTENSIONS/saltedpasswords'])
962  ->shouldBeCalled();
963  $silentConfigurationUpgradeService = $this->getAccessibleMock(
964  SilentConfigurationUpgradeService::class,
965  ['dummy'],
966  [$configurationManagerProphecy->reveal()]
967  );
968  $this->expectException(ConfigurationChangedException::class);
969  $this->expectExceptionCode(1379024938);
970  $silentConfigurationUpgradeService->_call('migrateSaltedPasswordsSettings');
971  }
972 
977  {
978  $oldCacheConfigurations = [
979  'cache_rootline' => [
980  'frontend' => VariableFrontend::class,
981  'backend' => Typo3DatabaseBackend::class,
982  'options' => [
983  'defaultLifetime' => 2592000,
984  ],
985  'groups' => ['pages']
986  ],
987  'fluid_template' => [
988  'backend' => SimpleFileBackend::class,
989  'frontend' => FluidTemplateCache::class,
990  'groups' => ['system'],
991  ],
992  ];
993  $newCacheConfigurations = [
994  'rootline' => [
995  'frontend' => VariableFrontend::class,
996  'backend' => Typo3DatabaseBackend::class,
997  'options' => [
998  'defaultLifetime' => 2592000,
999  ],
1000  'groups' => ['pages']
1001  ],
1002  'fluid_template' => [
1003  'backend' => SimpleFileBackend::class,
1004  'frontend' => FluidTemplateCache::class,
1005  'groups' => ['system'],
1006  ],
1007  ];
1009  ‪$configurationManager = $this->prophesize(ConfigurationManager::class);
1010  ‪$configurationManager->getLocalConfigurationValueByPath('SYS/caching/cacheConfigurations')
1011  ->shouldBeCalled()
1012  ->willReturn($oldCacheConfigurations);
1013 
1014  ‪$configurationManager->setLocalConfigurationValueByPath('SYS/caching/cacheConfigurations', $newCacheConfigurations)->shouldBeCalled();
1015 
1016  $this->expectException(ConfigurationChangedException::class);
1017  $this->expectExceptionCode(1379024938);
1018 
1020  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
1021  SilentConfigurationUpgradeService::class,
1022  ['dummy'],
1023  [],
1024  '',
1025  false
1026  );
1027 
1028  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', ‪$configurationManager->reveal());
1029  $silentConfigurationUpgradeServiceInstance->_call('migrateCachingFrameworkCaches');
1030  }
1031 
1036  {
1037  $oldCacheConfigurations = [
1038  'rootline' => [
1039  'frontend' => VariableFrontend::class,
1040  'backend' => Typo3DatabaseBackend::class,
1041  'options' => [
1042  'defaultLifetime' => 2592000,
1043  ],
1044  'groups' => ['pages']
1045  ],
1046  'fluid_template' => [
1047  'backend' => SimpleFileBackend::class,
1048  'frontend' => FluidTemplateCache::class,
1049  'groups' => ['system'],
1050  ],
1051  ];
1053  ‪$configurationManager = $this->prophesize(ConfigurationManager::class);
1054  ‪$configurationManager->getLocalConfigurationValueByPath('SYS/caching/cacheConfigurations')
1055  ->shouldBeCalled()
1056  ->willReturn($oldCacheConfigurations);
1057 
1058  ‪$configurationManager->setLocalConfigurationValueByPath(Argument::cetera())->shouldNotBeCalled();
1059 
1061  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
1062  SilentConfigurationUpgradeService::class,
1063  ['dummy'],
1064  [],
1065  '',
1066  false
1067  );
1068 
1069  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', ‪$configurationManager->reveal());
1070  $silentConfigurationUpgradeServiceInstance->_call('migrateCachingFrameworkCaches');
1071  }
1072 }
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\configureBackendLoginSecurity
‪configureBackendLoginSecurity($current, $setting, $isPackageActive, $hasLocalConfig)
Definition: SilentConfigurationUpgradeServiceTest.php:102
‪TYPO3\CMS\Core\Crypto\PasswordHashing\BcryptPasswordHash
Definition: BcryptPasswordHash.php:32
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateSaltedPasswordsSettingsDoesNothingIfExtensionConfigsAreNotSet
‪migrateSaltedPasswordsSettingsDoesNothingIfExtensionConfigsAreNotSet()
Definition: SilentConfigurationUpgradeServiceTest.php:868
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migratesGraphicsProcessorEffects
‪migratesGraphicsProcessorEffects($currentValue, $expectedMigratedValue)
Definition: SilentConfigurationUpgradeServiceTest.php:700
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateSaltedPasswordsSettingsDoesNothingIfExtensionConfigsAreEmpty
‪migrateSaltedPasswordsSettingsDoesNothingIfExtensionConfigsAreEmpty()
Definition: SilentConfigurationUpgradeServiceTest.php:887
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\configureFrontendLoginSecurityLocalconfiguration
‪array configureFrontendLoginSecurityLocalconfiguration()
Definition: SilentConfigurationUpgradeServiceTest.php:158
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\transferHttpSettingsIfSet
‪transferHttpSettingsIfSet($currentLocalConfiguration, $newSettings, $localConfigurationNeedsUpdate)
Definition: SilentConfigurationUpgradeServiceTest.php:481
‪TYPO3\CMS\Install\Service\Exception\ConfigurationChangedException
Definition: ConfigurationChangedException.php:26
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateNonExistingLangDebug
‪migrateNonExistingLangDebug()
Definition: SilentConfigurationUpgradeServiceTest.php:756
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\configureFrontendLoginSecurity
‪configureFrontendLoginSecurity($current, $setting, $isPackageActive, $hasLocalConfig)
Definition: SilentConfigurationUpgradeServiceTest.php:175
‪TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService
Definition: SilentConfigurationUpgradeService.php:44
‪TYPO3\CMS\Core\Utility\Exception\MissingArrayPathException
Definition: MissingArrayPathException.php:28
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\doNotSetImageMagickDetailSettings
‪doNotSetImageMagickDetailSettings()
Definition: SilentConfigurationUpgradeServiceTest.php:657
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\setImageMagickDetailSettings
‪setImageMagickDetailSettings()
Definition: SilentConfigurationUpgradeServiceTest.php:611
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\removeObsoleteLocalConfigurationSettingsIfThereAreOldSettings
‪removeObsoleteLocalConfigurationSettingsIfThereAreOldSettings()
Definition: SilentConfigurationUpgradeServiceTest.php:231
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateSaltedPasswordsSetsSpecificHashMethodIfArgon2idAndArgon2iIsNotAvailable
‪migrateSaltedPasswordsSetsSpecificHashMethodIfArgon2idAndArgon2iIsNotAvailable()
Definition: SilentConfigurationUpgradeServiceTest.php:932
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateCachingFrameworkCachesMigratesData
‪migrateCachingFrameworkCachesMigratesData()
Definition: SilentConfigurationUpgradeServiceTest.php:974
‪TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend
Definition: Typo3DatabaseBackend.php:31
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\$configurationManager
‪ConfigurationManager PHPUnit Framework MockObject MockObject $configurationManager
Definition: SilentConfigurationUpgradeServiceTest.php:46
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateCachingFrameworkCachesDoesNotMigrateWithoutPrefix
‪migrateCachingFrameworkCachesDoesNotMigrateWithoutPrefix()
Definition: SilentConfigurationUpgradeServiceTest.php:1033
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility
Definition: ExtensionManagementUtility.php:43
‪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:340
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\createConfigurationManagerWithMockedMethods
‪createConfigurationManagerWithMockedMethods(array $methods)
Definition: SilentConfigurationUpgradeServiceTest.php:73
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\configureBackendLoginSecurityLocalconfiguration
‪array configureBackendLoginSecurityLocalconfiguration()
Definition: SilentConfigurationUpgradeServiceTest.php:85
‪TYPO3\CMS\Core\Cache\Frontend\VariableFrontend
Definition: VariableFrontend.php:25
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\graphicsProcessorEffects
‪array graphicsProcessorEffects()
Definition: SilentConfigurationUpgradeServiceTest.php:723
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateSaltedPasswordsSettingsRemovesExtensionsConfigAndSetsNothingElseIfArgon2iIsAvailable
‪migrateSaltedPasswordsSettingsRemovesExtensionsConfigAndSetsNothingElseIfArgon2iIsAvailable()
Definition: SilentConfigurationUpgradeServiceTest.php:905
‪TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend
Definition: SimpleFileBackend.php:33
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateExistingLangDebug
‪migrateExistingLangDebug()
Definition: SilentConfigurationUpgradeServiceTest.php:790
‪TYPO3\CMS\Core\Tests\Unit\Utility\AccessibleProxies\ExtensionManagementUtilityAccessibleProxy\getPackageManager
‪static getPackageManager()
Definition: ExtensionManagementUtilityAccessibleProxy.php:32
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\tearDown
‪tearDown()
Definition: SilentConfigurationUpgradeServiceTest.php:64
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\httpSettingsMappingDataProvider
‪array httpSettingsMappingDataProvider()
Definition: SilentConfigurationUpgradeServiceTest.php:380
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\doNotDisableImageMagickDetailSettingsIfImageMagickIsEnabled
‪doNotDisableImageMagickDetailSettingsIfImageMagickIsEnabled()
Definition: SilentConfigurationUpgradeServiceTest.php:570
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\disableImageMagickDetailSettingsIfImageMagickIsDisabled
‪disableImageMagickDetailSettingsIfImageMagickIsDisabled()
Definition: SilentConfigurationUpgradeServiceTest.php:524
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateCacheHashOptions
‪migrateCacheHashOptions()
Definition: SilentConfigurationUpgradeServiceTest.php:828
‪TYPO3\CMS\Core\Tests\Unit\Utility\AccessibleProxies\ExtensionManagementUtilityAccessibleProxy
Definition: ExtensionManagementUtilityAccessibleProxy.php:26
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\doNotGenerateEncryptionKeyIfExists
‪doNotGenerateEncryptionKeyIfExists()
Definition: SilentConfigurationUpgradeServiceTest.php:305
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\setUp
‪setUp()
Definition: SilentConfigurationUpgradeServiceTest.php:55
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\doNotRemoveObsoleteLocalConfigurationSettingsIfThereAreNoOldSettings
‪doNotRemoveObsoleteLocalConfigurationSettingsIfThereAreNoOldSettings()
Definition: SilentConfigurationUpgradeServiceTest.php:269
‪TYPO3\CMS\Install\Tests\Unit\Service
Definition: ClearTableServiceTest.php:16
‪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\$backupPackageManager
‪TYPO3 CMS Core Package UnitTestPackageManager $backupPackageManager
Definition: SilentConfigurationUpgradeServiceTest.php:50
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest
Definition: SilentConfigurationUpgradeServiceTest.php:43