‪TYPO3CMS  9.5
SilentConfigurationUpgradeServiceTest.php
Go to the documentation of this file.
1 <?php
2 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 
18 use Prophecy\Argument;
19 use Prophecy\Prophecy\ObjectProphecy;
20 use TYPO3\CMS\Core\Configuration\ConfigurationManager;
23 use TYPO3\CMS\Core\Package\PackageManager;
30 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
31 
35 class ‪SilentConfigurationUpgradeServiceTest extends UnitTestCase
36 {
40  protected ‪$configurationManager;
41 
45  protected ‪$backupPackageManager;
46 
50  protected function ‪setUp()
51  {
53  parent::setUp();
54  }
55 
59  protected function ‪tearDown()
60  {
62  parent::tearDown();
63  }
64 
68  protected function ‪createConfigurationManagerWithMockedMethods(array $methods)
69  {
70  $this->configurationManager = $this->getMockBuilder(ConfigurationManager::class)
71  ->setMethods($methods)
72  ->getMock();
73  }
74 
81  {
82  return [
83  ['', 'rsa', true, false],
84  ['normal', 'rsa', true, true],
85  ['rsa', 'normal', false, true],
86  ];
87  }
88 
97  public function ‪configureBackendLoginSecurity($current, $setting, $isPackageActive, $hasLocalConfig)
98  {
100  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
101  SilentConfigurationUpgradeService::class,
102  ['dummy'],
103  [],
104  '',
105  false
106  );
107 
109  $packageManager = $this->createMock(PackageManager::class);
110  $packageManager->expects($this->any())
111  ->method('isPackageActive')
112  ->will($this->returnValue($isPackageActive));
114 
115  $currentLocalConfiguration = [
116  ['BE/loginSecurityLevel', $current]
117  ];
118  $closure = function () {
119  throw new ‪MissingArrayPathException('Path does not exist in array', 1538160231);
120  };
121 
123  [
124  'getLocalConfigurationValueByPath',
125  'setLocalConfigurationValueByPath',
126  ]
127  );
128  if ($hasLocalConfig) {
129  $this->configurationManager->expects($this->once())
130  ->method('getLocalConfigurationValueByPath')
131  ->will($this->returnValueMap($currentLocalConfiguration));
132  } else {
133  $this->configurationManager->expects($this->once())
134  ->method('getLocalConfigurationValueByPath')
135  ->will($this->returnCallback($closure));
136  }
137  $this->configurationManager->expects($this->once())
138  ->method('setLocalConfigurationValueByPath')
139  ->with($this->equalTo('BE/loginSecurityLevel'), $this->equalTo($setting));
140 
141  $this->expectException(ConfigurationChangedException::class);
142 
143  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
144 
145  $silentConfigurationUpgradeServiceInstance->_call('configureBackendLoginSecurity');
146  }
147 
154  {
155  return [
156  ['', 'rsa', true, false],
157  ['normal', 'rsa', true, true],
158  ['rsa', 'normal', false, true],
159  ];
160  }
161 
170  public function ‪configureFrontendLoginSecurity($current, $setting, $isPackageActive, $hasLocalConfig)
171  {
173  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
174  SilentConfigurationUpgradeService::class,
175  ['dummy'],
176  [],
177  '',
178  false
179  );
180 
182  $packageManager = $this->createMock(PackageManager::class);
183  $packageManager->expects($this->any())
184  ->method('isPackageActive')
185  ->will($this->returnValue($isPackageActive));
187 
188  $currentLocalConfiguration = [
189  ['FE/loginSecurityLevel', $current]
190  ];
191  $closure = function () {
192  throw new ‪MissingArrayPathException('Path does not exist in array', 1476109311);
193  };
194 
196  [
197  'getLocalConfigurationValueByPath',
198  'setLocalConfigurationValueByPath',
199  ]
200  );
201  if ($hasLocalConfig) {
202  $this->configurationManager->expects($this->once())
203  ->method('getLocalConfigurationValueByPath')
204  ->will($this->returnValueMap($currentLocalConfiguration));
205  } else {
206  $this->configurationManager->expects($this->once())
207  ->method('getLocalConfigurationValueByPath')
208  ->will($this->returnCallback($closure));
209  }
210  if ($isPackageActive === false) {
211  $this->configurationManager->expects($this->once())
212  ->method('setLocalConfigurationValueByPath')
213  ->with($this->equalTo('FE/loginSecurityLevel'), $this->equalTo($setting));
214 
215  $this->expectException(ConfigurationChangedException::class);
216  }
217 
218  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
219 
220  $silentConfigurationUpgradeServiceInstance->_call('configureFrontendLoginSecurity');
221  }
222 
227  {
229  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
230  SilentConfigurationUpgradeService::class,
231  ['dummy'],
232  [],
233  '',
234  false
235  );
236 
237  $obsoleteLocalConfigurationSettings = [
238  'SYS/form_enctype',
239  ];
240 
241  $currentLocalConfiguration = [
242  [$obsoleteLocalConfigurationSettings, true]
243  ];
245  [
246  'removeLocalConfigurationKeysByPath',
247  ]
248  );
249  $this->configurationManager->expects($this->exactly(1))
250  ->method('removeLocalConfigurationKeysByPath')
251  ->will($this->returnValueMap($currentLocalConfiguration));
252 
253  $this->expectException(ConfigurationChangedException::class);
254 
255  $silentConfigurationUpgradeServiceInstance->_set('obsoleteLocalConfigurationSettings', $obsoleteLocalConfigurationSettings);
256  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
257 
258  $silentConfigurationUpgradeServiceInstance->_call('removeObsoleteLocalConfigurationSettings');
259  }
260 
265  {
267  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
268  SilentConfigurationUpgradeService::class,
269  ['dummy'],
270  [],
271  '',
272  false
273  );
274 
275  $obsoleteLocalConfigurationSettings = [
276  'SYS/form_enctype',
277  ];
278 
279  $currentLocalConfiguration = [
280  [$obsoleteLocalConfigurationSettings, false]
281  ];
283  [
284  'removeLocalConfigurationKeysByPath',
285  ]
286  );
287  $this->configurationManager->expects($this->exactly(1))
288  ->method('removeLocalConfigurationKeysByPath')
289  ->will($this->returnValueMap($currentLocalConfiguration));
290 
291  $silentConfigurationUpgradeServiceInstance->_set('obsoleteLocalConfigurationSettings', $obsoleteLocalConfigurationSettings);
292  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
293 
294  $silentConfigurationUpgradeServiceInstance->_call('removeObsoleteLocalConfigurationSettings');
295  }
296 
300  public function ‪doNotGenerateEncryptionKeyIfExists()
301  {
303  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
304  SilentConfigurationUpgradeService::class,
305  ['dummy'],
306  [],
307  '',
308  false
309  );
310 
311  $currentLocalConfiguration = [
312  ['SYS/encryptionKey', 'EnCrYpTiOnKeY']
313  ];
314 
316  [
317  'getLocalConfigurationValueByPath',
318  'setLocalConfigurationValueByPath',
319  ]
320  );
321  $this->configurationManager->expects($this->exactly(1))
322  ->method('getLocalConfigurationValueByPath')
323  ->will($this->returnValueMap($currentLocalConfiguration));
324  $this->configurationManager->expects($this->never())
325  ->method('setLocalConfigurationValueByPath');
326 
327  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
328 
329  $silentConfigurationUpgradeServiceInstance->_call('generateEncryptionKeyIfNeeded');
330  }
331 
335  public function ‪generateEncryptionKeyIfNotExists()
336  {
338  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
339  SilentConfigurationUpgradeService::class,
340  ['dummy'],
341  [],
342  '',
343  false
344  );
345 
346  $closure = function () {
347  throw new ‪MissingArrayPathException('Path does not exist in array', 1476109266);
348  };
349 
351  [
352  'getLocalConfigurationValueByPath',
353  'setLocalConfigurationValueByPath',
354  ]
355  );
356  $this->configurationManager->expects($this->exactly(1))
357  ->method('getLocalConfigurationValueByPath')
358  ->will($this->returnCallback($closure));
359  $this->configurationManager->expects($this->once())
360  ->method('setLocalConfigurationValueByPath')
361  ->with($this->equalTo('SYS/encryptionKey'), $this->isType('string'));
362 
363  $this->expectException(ConfigurationChangedException::class);
364 
365  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
366 
367  $silentConfigurationUpgradeServiceInstance->_call('generateEncryptionKeyIfNeeded');
368  }
369 
375  public function ‪httpSettingsMappingDataProvider(): array
376  {
377  return [
378  'No changes overridden in Local Configuration' => [
379  ['timeout' => 100],
380  ['HTTP/timeout' => 100],
381  false
382  ],
383  'Old and unused settings removed' => [
384  ['adapter' => 'curl'],
385  [],
386  true
387  ],
388  'Old and used settings changed' => [
389  ['protocol_version' => '1.1'],
390  ['HTTP/version' => '1.1'],
391  true
392  ],
393 
395  'Redirects moved to default' => [
396  ['follow_redirects' => true],
397  [],
398  true
399  ],
400  'Redirects moved #1' => [
401  ['follow_redirects' => true, 'max_redirects' => 200, 'strict_redirects' => false],
402  ['HTTP/allow_redirects' => ['max' => 200]],
403  true
404  ],
405  'Redirects moved #2' => [
406  ['follow_redirects' => false, 'max_redirects' => 200, 'strict_redirects' => false],
407  ['HTTP/allow_redirects' => false],
408  true
409  ],
410  'Redirects moved #3' => [
411  ['follow_redirects' => true, 'max_redirects' => 400, 'strict_redirects' => 1],
412  ['HTTP/allow_redirects' => ['max' => 400, 'strict' => true]],
413  true
414  ],
415 
417  'Proxy host set' => [
418  ['proxy_host' => 'vpn.myproxy.com'],
419  ['HTTP/proxy' => 'http://vpn.myproxy.com'],
420  true
421  ],
422  'Proxy host set + port' => [
423  ['proxy_host' => 'vpn.myproxy.com', 'proxy_port' => 8080],
424  ['HTTP/proxy' => 'http://vpn.myproxy.com:8080'],
425  true
426  ],
427  'Proxy host set + port + verification' => [
428  ['proxy_host' => 'vpn.myproxy.com', 'proxy_port' => 8080, 'proxy_auth_scheme' => 'basic', 'proxy_user' => 'myuser', 'proxy_password' => 'mysecret'],
429  ['HTTP/proxy' => 'http://myuser:mysecret@vpn.myproxy.com:8080'],
430  true
431  ],
432 
434  'Only ssl_capath set, invalid migration' => [
435  ['ssl_capath' => '/foo/bar/'],
436  [],
437  true
438  ],
439  'Verification activated, but only ssl_capath set, using default' => [
440  ['ssl_verify_peer' => 1, 'ssl_capath' => '/foo/bar/'],
441  [],
442  true
443  ],
444  'Verification activated, with ssl_capath and ssl_cafile set' => [
445  ['ssl_verify_peer' => 1, 'ssl_capath' => '/foo/bar/', 'ssl_cafile' => 'supersecret.crt'],
446  ['HTTP/verify' => '/foo/bar/supersecret.crt'],
447  true
448  ],
449 
451  'SSL key certification' => [
452  ['ssl_local_cert' => '/foo/bar/supersecret.key'],
453  ['HTTP/ssl_key' => '/foo/bar/supersecret.key'],
454  true
455  ],
456  'SSL key certification + passphrase' => [
457  ['ssl_local_cert' => '/foo/bar/supersecret.key', 'ssl_passphrase' => 'donotcopypasteme'],
458  ['HTTP/ssl_key' => ['/foo/bar/supersecret.key', 'donotcopypasteme']],
459  true
460  ],
461  'SSL key passphrase only - no migration' => [
462  ['ssl_passphrase' => 'donotcopypasteme'],
463  [],
464  true
465  ],
466  ];
467  }
468 
476  public function ‪transferHttpSettingsIfSet($currentLocalConfiguration, $newSettings, $localConfigurationNeedsUpdate)
477  {
479  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
480  SilentConfigurationUpgradeService::class,
481  ['dummy'],
482  [],
483  '',
484  false
485  );
486 
488  [
489  'setLocalConfigurationValuesByPathValuePairs',
490  'removeLocalConfigurationKeysByPath',
491  'getLocalConfiguration'
492  ]
493  );
494 
495  $this->configurationManager->expects($this->any())
496  ->method('getLocalConfiguration')
497  ->willReturn(['HTTP' => $currentLocalConfiguration]);
498  if ($localConfigurationNeedsUpdate) {
499  if (!empty($newSettings)) {
500  $this->configurationManager->expects($this->once())
501  ->method('setLocalConfigurationValuesByPathValuePairs')
502  ->with($newSettings);
503  }
504  $this->configurationManager->expects($this->atMost(1))->method('removeLocalConfigurationKeysByPath');
505  }
506 
507  if ($localConfigurationNeedsUpdate) {
508  $this->expectException(ConfigurationChangedException::class);
509  }
510 
511  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
512 
513  $silentConfigurationUpgradeServiceInstance->_call('transferHttpSettings');
514  }
515 
520  {
522  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
523  SilentConfigurationUpgradeService::class,
524  ['dummy'],
525  [],
526  '',
527  false
528  );
529 
530  $currentLocalConfiguration = [
531  ['GFX/im', 0],
532  ['GFX/im_path', ''],
533  ['GFX/im_path_lzw', ''],
534  ['GFX/imagefile_ext', 'gif,jpg,png'],
535  ['GFX/thumbnails', 0]
536  ];
538  [
539  'getLocalConfigurationValueByPath',
540  'getDefaultConfigurationValueByPath',
541  'setLocalConfigurationValuesByPathValuePairs',
542  ]
543  );
544  $this->configurationManager->expects($this->exactly(5))
545  ->method('getLocalConfigurationValueByPath')
546  ->will($this->returnValueMap($currentLocalConfiguration));
547  $this->configurationManager->expects($this->never())
548  ->method('getDefaultConfigurationValueByPath');
549  $this->configurationManager->expects($this->once())
550  ->method('setLocalConfigurationValuesByPathValuePairs')
551  ->withConsecutive(
552  [['GFX/imagefile_ext' => 'gif,jpg,jpeg,png']]
553  );
554 
555  $this->expectException(ConfigurationChangedException::class);
556 
557  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
558 
559  $silentConfigurationUpgradeServiceInstance->_call('disableImageMagickDetailSettingsIfImageMagickIsDisabled');
560  }
561 
566  {
568  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
569  SilentConfigurationUpgradeService::class,
570  ['dummy'],
571  [],
572  '',
573  false
574  );
575 
576  $currentLocalConfiguration = [
577  ['GFX/im', 1],
578  ['GFX/im_path', ''],
579  ['GFX/im_path_lzw', ''],
580  ['GFX/imagefile_ext', 'gif,jpg,jpeg,png'],
581  ['GFX/thumbnails', 0]
582  ];
584  [
585  'getLocalConfigurationValueByPath',
586  'getDefaultConfigurationValueByPath',
587  'setLocalConfigurationValuesByPathValuePairs',
588  ]
589  );
590  $this->configurationManager->expects($this->exactly(5))
591  ->method('getLocalConfigurationValueByPath')
592  ->will($this->returnValueMap($currentLocalConfiguration));
593  $this->configurationManager->expects($this->never())
594  ->method('getDefaultConfigurationValueByPath');
595  $this->configurationManager->expects($this->never())
596  ->method('setLocalConfigurationValuesByPathValuePairs');
597 
598  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
599 
600  $silentConfigurationUpgradeServiceInstance->_call('disableImageMagickDetailSettingsIfImageMagickIsDisabled');
601  }
602 
606  public function ‪setImageMagickDetailSettings()
607  {
609  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
610  SilentConfigurationUpgradeService::class,
611  ['dummy'],
612  [],
613  '',
614  false
615  );
616 
617  $currentLocalConfiguration = [
618  ['GFX/processor', 'GraphicsMagick'],
619  ['GFX/processor_allowTemporaryMasksAsPng', 1],
620  ['GFX/processor_effects', false],
621  ];
623  [
624  'getLocalConfigurationValueByPath',
625  'getDefaultConfigurationValueByPath',
626  'setLocalConfigurationValuesByPathValuePairs',
627  ]
628  );
629  $this->configurationManager->expects($this->exactly(3))
630  ->method('getLocalConfigurationValueByPath')
631  ->will($this->returnValueMap($currentLocalConfiguration));
632  $this->configurationManager->expects($this->never())
633  ->method('getDefaultConfigurationValueByPath');
634  $this->configurationManager->expects($this->once())
635  ->method('setLocalConfigurationValuesByPathValuePairs')
636  ->withConsecutive([
637  [
638  'GFX/processor_allowTemporaryMasksAsPng' => 0,
639  ]
640  ]);
641 
642  $this->expectException(ConfigurationChangedException::class);
643 
644  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
645 
646  $silentConfigurationUpgradeServiceInstance->_call('setImageMagickDetailSettings');
647  }
648 
652  public function ‪doNotSetImageMagickDetailSettings()
653  {
655  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
656  SilentConfigurationUpgradeService::class,
657  ['dummy'],
658  [],
659  '',
660  false
661  );
662 
663  $currentLocalConfiguration = [
664  ['GFX/processor', ''],
665  ['GFX/processor_allowTemporaryMasksAsPng', 0],
666  ['GFX/processor_effects', 0],
667  ];
669  [
670  'getLocalConfigurationValueByPath',
671  'getDefaultConfigurationValueByPath',
672  'setLocalConfigurationValuesByPathValuePairs',
673  ]
674  );
675  $this->configurationManager->expects($this->exactly(3))
676  ->method('getLocalConfigurationValueByPath')
677  ->will($this->returnValueMap($currentLocalConfiguration));
678  $this->configurationManager->expects($this->never())
679  ->method('getDefaultConfigurationValueByPath');
680  $this->configurationManager->expects($this->never())
681  ->method('setLocalConfigurationValuesByPathValuePairs');
682 
683  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
684 
685  $silentConfigurationUpgradeServiceInstance->_call('setImageMagickDetailSettings');
686  }
687 
695  public function ‪migratesGraphicsProcessorEffects($currentValue, $expectedMigratedValue)
696  {
698  ‪$configurationManager = $this->prophesize(ConfigurationManager::class);
699  ‪$configurationManager->getLocalConfigurationValueByPath('GFX/processor')->willReturn('GraphicsMagick');
700  ‪$configurationManager->getLocalConfigurationValueByPath('GFX/processor_allowTemporaryMasksAsPng')->willReturn(false);
701  ‪$configurationManager->getLocalConfigurationValueByPath('GFX/processor_effects')->willReturn($currentValue);
702  ‪$configurationManager->setLocalConfigurationValuesByPathValuePairs([
703  'GFX/processor_effects' => $expectedMigratedValue,
704  ])->shouldBeCalled();
705 
706  $this->expectException(ConfigurationChangedException::class);
707 
708  $silentConfigurationUpgradeService = new ‪SilentConfigurationUpgradeService(‪$configurationManager->reveal());
709 
710  $this->callInaccessibleMethod($silentConfigurationUpgradeService, 'setImageMagickDetailSettings');
711  }
712 
716  public function ‪graphicsProcessorEffects(): array
717  {
718  return [
719  'integer 1' => [
720  1,
721  true,
722  ],
723  'integer 0' => [
724  0,
725  false,
726  ],
727  'integer -1' => [
728  -1,
729  false,
730  ],
731  'string "1"' => [
732  '1',
733  true,
734  ],
735  'string "0"' => [
736  '0',
737  false,
738  ],
739  'string "-1"' => [
740  '-1',
741  false,
742  ],
743  ];
744  }
745 
749  public function ‪migrateNonExistingLangDebug()
750  {
752  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
753  SilentConfigurationUpgradeService::class,
754  ['dummy'],
755  [],
756  '',
757  false
758  );
759 
760  $currentLocalConfiguration = [
761  ];
763  [
764  'getLocalConfigurationValueByPath',
765  'setLocalConfigurationValueByPath',
766  ]
767  );
768 
769  $this->configurationManager->expects($this->exactly(1))
770  ->method('getLocalConfigurationValueByPath')
771  ->will($this->returnValueMap($currentLocalConfiguration));
772  $this->configurationManager->expects($this->never())
773  ->method('setLocalConfigurationValueByPath');
774 
775  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
776 
777  $silentConfigurationUpgradeServiceInstance->_call('migrateLangDebug');
778  }
779 
783  public function ‪migrateExistingLangDebug()
784  {
786  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
787  SilentConfigurationUpgradeService::class,
788  ['dummy'],
789  [],
790  '',
791  false
792  );
793 
794  $currentLocalConfiguration = [
795  ['BE/lang/debug', false]
796  ];
798  [
799  'getLocalConfigurationValueByPath',
800  'setLocalConfigurationValueByPath',
801  ]
802  );
803 
804  $this->configurationManager->expects($this->exactly(1))
805  ->method('getLocalConfigurationValueByPath')
806  ->will($this->returnValueMap($currentLocalConfiguration));
807  $this->configurationManager->expects($this->once())
808  ->method('setLocalConfigurationValueByPath')
809  ->with($this->equalTo('BE/languageDebug'), false);
810 
811  $this->expectException(ConfigurationChangedException::class);
812  $this->expectExceptionCode(1379024938);
813 
814  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
815  $silentConfigurationUpgradeServiceInstance->_call('migrateLangDebug');
816  }
817 
821  public function ‪migrateCacheHashOptions()
822  {
823  $oldConfig = [
824  'FE/cHashOnlyForParameters' => 'foo,bar',
825  'FE/cHashExcludedParameters' => 'bar,foo',
826  'FE/cHashRequiredParameters' => 'bar,baz',
827  'FE/cHashExcludedParametersIfEmpty' => '*'
828  ];
829 
831  ‪$configurationManager = $this->prophesize(ConfigurationManager::class);
832 
833  foreach ($oldConfig as $key => $value) {
834  ‪$configurationManager->getLocalConfigurationValueByPath($key)
835  ->shouldBeCalled()
836  ->willReturn($value);
837  }
838 
839  ‪$configurationManager->setLocalConfigurationValuesByPathValuePairs(Argument::cetera())->shouldBeCalled();
840  ‪$configurationManager->removeLocalConfigurationKeysByPath(Argument::cetera())->shouldBeCalled();
841 
842  $this->expectException(ConfigurationChangedException::class);
843  $this->expectExceptionCode(1379024938);
844 
846  $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
847  SilentConfigurationUpgradeService::class,
848  ['dummy'],
849  [],
850  '',
851  false
852  );
853 
854  $silentConfigurationUpgradeServiceInstance->_set('configurationManager', ‪$configurationManager->reveal());
855  $silentConfigurationUpgradeServiceInstance->_call('migrateCacheHashOptions');
856  }
857 
862  {
863  $configurationManagerProphecy = $this->prophesize(ConfigurationManager::class);
864  $configurationManagerException = new ‪MissingArrayPathException('Path does not exist in array', 1533989414);
865  $configurationManagerProphecy->getLocalConfigurationValueByPath('EXTENSIONS/saltedpasswords')
866  ->shouldBeCalled()->willThrow($configurationManagerException);
867  $configurationManagerProphecy->getLocalConfigurationValueByPath('EXT/extConf/saltedpasswords')
868  ->shouldBeCalled()->willThrow($configurationManagerException);
869  $configurationManagerProphecy->setLocalConfigurationValuesByPathValuePairs(Argument::cetera())
870  ->shouldNotBeCalled();
871  $silentConfigurationUpgradeService = $this->getAccessibleMock(
872  SilentConfigurationUpgradeService::class,
873  ['dummy'],
874  [$configurationManagerProphecy->reveal()]
875  );
876  $silentConfigurationUpgradeService->_call('migrateSaltedPasswordsSettings');
877  }
878 
883  {
884  $configurationManagerProphecy = $this->prophesize(ConfigurationManager::class);
885  $configurationManagerProphecy->getLocalConfigurationValueByPath('EXTENSIONS/saltedpasswords')
886  ->shouldBeCalled()->willReturn([]);
887  $configurationManagerProphecy->getLocalConfigurationValueByPath('EXT/extConf/saltedpasswords')
888  ->shouldBeCalled()->willReturn('');
889  $configurationManagerProphecy->setLocalConfigurationValuesByPathValuePairs(Argument::cetera())
890  ->shouldNotBeCalled();
891  $silentConfigurationUpgradeService = $this->getAccessibleMock(
892  SilentConfigurationUpgradeService::class,
893  ['dummy'],
894  [$configurationManagerProphecy->reveal()]
895  );
896  $silentConfigurationUpgradeService->_call('migrateSaltedPasswordsSettings');
897  }
898 
903  {
904  $configurationManagerProphecy = $this->prophesize(ConfigurationManager::class);
905  $configurationManagerException = new ‪MissingArrayPathException('Path does not exist in array', 1533989428);
906  $configurationManagerProphecy->getLocalConfigurationValueByPath('EXTENSIONS/saltedpasswords')
907  ->shouldBeCalled()->willReturn(['thereIs' => 'something']);
908  $configurationManagerProphecy->getLocalConfigurationValueByPath('EXT/extConf/saltedpasswords')
909  ->shouldBeCalled()->willThrow($configurationManagerException);
910  $argonBeProphecy = $this->prophesize(Argon2iPasswordHash::class);
911  $argonBeProphecy->isAvailable()->shouldBeCalled()->willReturn(true);
912  GeneralUtility::addInstance(Argon2iPasswordHash::class, $argonBeProphecy->reveal());
913  $argonFeProphecy = $this->prophesize(Argon2iPasswordHash::class);
914  $argonFeProphecy->isAvailable()->shouldBeCalled()->willReturn(true);
915  GeneralUtility::addInstance(Argon2iPasswordHash::class, $argonFeProphecy->reveal());
916  $configurationManagerProphecy->removeLocalConfigurationKeysByPath(['EXTENSIONS/saltedpasswords'])
917  ->shouldBeCalled();
918  $silentConfigurationUpgradeService = $this->getAccessibleMock(
919  SilentConfigurationUpgradeService::class,
920  ['dummy'],
921  [$configurationManagerProphecy->reveal()]
922  );
923  $this->expectException(ConfigurationChangedException::class);
924  $this->expectExceptionCode(1379024938);
925  $silentConfigurationUpgradeService->_call('migrateSaltedPasswordsSettings');
926  }
927 
932  {
933  $configurationManagerProphecy = $this->prophesize(ConfigurationManager::class);
934  $configurationManagerException = new ‪MissingArrayPathException('Path does not exist in array', 1533989434);
935  $configurationManagerProphecy->getLocalConfigurationValueByPath('EXTENSIONS/saltedpasswords')
936  ->shouldBeCalled()->willThrow($configurationManagerException);
937  $configurationManagerProphecy->getLocalConfigurationValueByPath('EXT/extConf/saltedpasswords')
938  ->shouldBeCalled()->willReturn('someConfiguration');
939  $argonBeProphecy = $this->prophesize(Argon2iPasswordHash::class);
940  $argonBeProphecy->isAvailable()->shouldBeCalled()->willReturn(true);
941  GeneralUtility::addInstance(Argon2iPasswordHash::class, $argonBeProphecy->reveal());
942  $argonFeProphecy = $this->prophesize(Argon2iPasswordHash::class);
943  $argonFeProphecy->isAvailable()->shouldBeCalled()->willReturn(true);
944  GeneralUtility::addInstance(Argon2iPasswordHash::class, $argonFeProphecy->reveal());
945  $configurationManagerProphecy->removeLocalConfigurationKeysByPath(['EXT/extConf/saltedpasswords'])
946  ->shouldBeCalled();
947  $silentConfigurationUpgradeService = $this->getAccessibleMock(
948  SilentConfigurationUpgradeService::class,
949  ['dummy'],
950  [$configurationManagerProphecy->reveal()]
951  );
952  $this->expectException(ConfigurationChangedException::class);
953  $this->expectExceptionCode(1379024938);
954  $silentConfigurationUpgradeService->_call('migrateSaltedPasswordsSettings');
955  }
956 
961  {
962  $configurationManagerProphecy = $this->prophesize(ConfigurationManager::class);
963  $configurationManagerProphecy->getLocalConfigurationValueByPath('EXTENSIONS/saltedpasswords')
964  ->shouldBeCalled()->willReturn(['thereIs' => 'something']);
965  $configurationManagerProphecy->getLocalConfigurationValueByPath('EXT/extConf/saltedpasswords')
966  ->shouldBeCalled()->willReturn('someConfiguration');
967  $argonBeProphecy = $this->prophesize(Argon2iPasswordHash::class);
968  $argonBeProphecy->isAvailable()->shouldBeCalled()->willReturn(false);
969  GeneralUtility::addInstance(Argon2iPasswordHash::class, $argonBeProphecy->reveal());
970  $bcryptBeProphecy = $this->prophesize(BcryptPasswordHash::class);
971  $bcryptBeProphecy->isAvailable()->shouldBeCalled()->willReturn(true);
972  GeneralUtility::addInstance(BcryptPasswordHash::class, $bcryptBeProphecy->reveal());
973  $argonFeProphecy = $this->prophesize(Argon2iPasswordHash::class);
974  $argonFeProphecy->isAvailable()->shouldBeCalled()->willReturn(false);
975  GeneralUtility::addInstance(Argon2iPasswordHash::class, $argonFeProphecy->reveal());
976  $bcryptFeProphecy = $this->prophesize(BcryptPasswordHash::class);
977  $bcryptFeProphecy->isAvailable()->shouldBeCalled()->willReturn(true);
978  GeneralUtility::addInstance(BcryptPasswordHash::class, $bcryptFeProphecy->reveal());
979  $configurationManagerProphecy->setLocalConfigurationValuesByPathValuePairs([
980  'BE/passwordHashing/className' => BcryptPasswordHash::class,
981  'FE/passwordHashing/className' => BcryptPasswordHash::class,
982  ])->shouldBeCalled();
983  $configurationManagerProphecy->removeLocalConfigurationKeysByPath(['EXTENSIONS/saltedpasswords', 'EXT/extConf/saltedpasswords'])
984  ->shouldBeCalled();
985  $silentConfigurationUpgradeService = $this->getAccessibleMock(
986  SilentConfigurationUpgradeService::class,
987  ['dummy'],
988  [$configurationManagerProphecy->reveal()]
989  );
990  $this->expectException(ConfigurationChangedException::class);
991  $this->expectExceptionCode(1379024938);
992  $silentConfigurationUpgradeService->_call('migrateSaltedPasswordsSettings');
993  }
994 }
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\configureBackendLoginSecurity
‪configureBackendLoginSecurity($current, $setting, $isPackageActive, $hasLocalConfig)
Definition: SilentConfigurationUpgradeServiceTest.php:95
‪TYPO3\CMS\Core\Crypto\PasswordHashing\BcryptPasswordHash
Definition: BcryptPasswordHash.php:30
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateSaltedPasswordsSettingsDoesNothingIfExtensionConfigsAreNotSet
‪migrateSaltedPasswordsSettingsDoesNothingIfExtensionConfigsAreNotSet()
Definition: SilentConfigurationUpgradeServiceTest.php:859
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migratesGraphicsProcessorEffects
‪migratesGraphicsProcessorEffects($currentValue, $expectedMigratedValue)
Definition: SilentConfigurationUpgradeServiceTest.php:693
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateSaltedPasswordsSettingsDoesNothingIfExtensionConfigsAreEmpty
‪migrateSaltedPasswordsSettingsDoesNothingIfExtensionConfigsAreEmpty()
Definition: SilentConfigurationUpgradeServiceTest.php:880
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\configureFrontendLoginSecurityLocalconfiguration
‪array configureFrontendLoginSecurityLocalconfiguration()
Definition: SilentConfigurationUpgradeServiceTest.php:151
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\transferHttpSettingsIfSet
‪transferHttpSettingsIfSet($currentLocalConfiguration, $newSettings, $localConfigurationNeedsUpdate)
Definition: SilentConfigurationUpgradeServiceTest.php:474
‪TYPO3\CMS\Install\Service\Exception\ConfigurationChangedException
Definition: ConfigurationChangedException.php:24
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateNonExistingLangDebug
‪migrateNonExistingLangDebug()
Definition: SilentConfigurationUpgradeServiceTest.php:747
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\configureFrontendLoginSecurity
‪configureFrontendLoginSecurity($current, $setting, $isPackageActive, $hasLocalConfig)
Definition: SilentConfigurationUpgradeServiceTest.php:168
‪TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService
Definition: SilentConfigurationUpgradeService.php:42
‪TYPO3\CMS\Core\Utility\Exception\MissingArrayPathException
Definition: MissingArrayPathException.php:26
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\doNotSetImageMagickDetailSettings
‪doNotSetImageMagickDetailSettings()
Definition: SilentConfigurationUpgradeServiceTest.php:650
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\setImageMagickDetailSettings
‪setImageMagickDetailSettings()
Definition: SilentConfigurationUpgradeServiceTest.php:604
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\removeObsoleteLocalConfigurationSettingsIfThereAreOldSettings
‪removeObsoleteLocalConfigurationSettingsIfThereAreOldSettings()
Definition: SilentConfigurationUpgradeServiceTest.php:224
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\$configurationManager
‪ConfigurationManager PHPUnit Framework MockObject MockObject $configurationManager
Definition: SilentConfigurationUpgradeServiceTest.php:39
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateSaltedPasswordsSettingsRemovesExtConfAndSetsNothingElseIfArgon2iIsAvailable
‪migrateSaltedPasswordsSettingsRemovesExtConfAndSetsNothingElseIfArgon2iIsAvailable()
Definition: SilentConfigurationUpgradeServiceTest.php:929
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility
Definition: ExtensionManagementUtility.php:36
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\setPackageManager
‪static setPackageManager(PackageManager $packageManager)
Definition: ExtensionManagementUtility.php:63
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\generateEncryptionKeyIfNotExists
‪generateEncryptionKeyIfNotExists()
Definition: SilentConfigurationUpgradeServiceTest.php:333
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\createConfigurationManagerWithMockedMethods
‪createConfigurationManagerWithMockedMethods(array $methods)
Definition: SilentConfigurationUpgradeServiceTest.php:66
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\configureBackendLoginSecurityLocalconfiguration
‪array configureBackendLoginSecurityLocalconfiguration()
Definition: SilentConfigurationUpgradeServiceTest.php:78
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\graphicsProcessorEffects
‪array graphicsProcessorEffects()
Definition: SilentConfigurationUpgradeServiceTest.php:714
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateSaltedPasswordsSettingsRemovesExtensionsConfigAndSetsNothingElseIfArgon2iIsAvailable
‪migrateSaltedPasswordsSettingsRemovesExtensionsConfigAndSetsNothingElseIfArgon2iIsAvailable()
Definition: SilentConfigurationUpgradeServiceTest.php:900
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateSaltedPasswordsSetsSpecificHashMethodIfArgon2iIsNotAvailable
‪migrateSaltedPasswordsSetsSpecificHashMethodIfArgon2iIsNotAvailable()
Definition: SilentConfigurationUpgradeServiceTest.php:958
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateExistingLangDebug
‪migrateExistingLangDebug()
Definition: SilentConfigurationUpgradeServiceTest.php:781
‪TYPO3\CMS\Core\Tests\Unit\Utility\AccessibleProxies\ExtensionManagementUtilityAccessibleProxy\getPackageManager
‪static getPackageManager()
Definition: ExtensionManagementUtilityAccessibleProxy.php:37
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\tearDown
‪tearDown()
Definition: SilentConfigurationUpgradeServiceTest.php:57
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\httpSettingsMappingDataProvider
‪array httpSettingsMappingDataProvider()
Definition: SilentConfigurationUpgradeServiceTest.php:373
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\doNotDisableImageMagickDetailSettingsIfImageMagickIsEnabled
‪doNotDisableImageMagickDetailSettingsIfImageMagickIsEnabled()
Definition: SilentConfigurationUpgradeServiceTest.php:563
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\disableImageMagickDetailSettingsIfImageMagickIsDisabled
‪disableImageMagickDetailSettingsIfImageMagickIsDisabled()
Definition: SilentConfigurationUpgradeServiceTest.php:517
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\migrateCacheHashOptions
‪migrateCacheHashOptions()
Definition: SilentConfigurationUpgradeServiceTest.php:819
‪TYPO3\CMS\Core\Tests\Unit\Utility\AccessibleProxies\ExtensionManagementUtilityAccessibleProxy
Definition: ExtensionManagementUtilityAccessibleProxy.php:26
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\doNotGenerateEncryptionKeyIfExists
‪doNotGenerateEncryptionKeyIfExists()
Definition: SilentConfigurationUpgradeServiceTest.php:298
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\setUp
‪setUp()
Definition: SilentConfigurationUpgradeServiceTest.php:48
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\doNotRemoveObsoleteLocalConfigurationSettingsIfThereAreNoOldSettings
‪doNotRemoveObsoleteLocalConfigurationSettingsIfThereAreNoOldSettings()
Definition: SilentConfigurationUpgradeServiceTest.php:262
‪TYPO3\CMS\Install\Tests\Unit\Service
Definition: ClearTableServiceTest.php:2
‪TYPO3\CMS\Core\Crypto\PasswordHashing\Argon2iPasswordHash
Definition: Argon2iPasswordHash.php:29
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest\$backupPackageManager
‪TYPO3 CMS Core Package UnitTestPackageManager $backupPackageManager
Definition: SilentConfigurationUpgradeServiceTest.php:43
‪TYPO3\CMS\Install\Tests\Unit\Service\SilentConfigurationUpgradeServiceTest
Definition: SilentConfigurationUpgradeServiceTest.php:36