7 declare(strict_types=1);
22 private $objectManager;
27 private $deployConfig;
32 $this->deployConfig = $this->objectManager->get(DeploymentConfig::class);
35 public function testChangeEncryptionKey()
37 $testPath =
'test/config';
40 $structureMock = $this->createMock(\
Magento\Config\Model\Config\Structure\Proxy::class);
41 $structureMock->expects($this->once())
42 ->method(
'getFieldPathsByAttribute')
43 ->will($this->returnValue([$testPath]));
47 $configModel->saveConfig($testPath, $this->legacyEncrypt($testValue),
'default', 0);
50 $patch = $this->objectManager->create(
51 \
Magento\EncryptionKey\Setup\Patch\Data\SodiumChachaPatch::class,
53 'structure' => $structureMock,
61 $configModel->getMainTable(),
62 [
'config_id',
'value']
73 $encyptor = $this->objectManager->get(\
Magento\Framework\Encryption\EncryptorInterface::class);
75 $rawConfigValue = array_pop(
$values);
77 $this->assertNotEquals($testValue, $rawConfigValue);
79 $this->assertEquals($testValue, $encyptor->decrypt($rawConfigValue));
82 private function legacyEncrypt(
string $data): string
85 $handle = @mcrypt_module_open(MCRYPT_RIJNDAEL_256,
'', MCRYPT_MODE_CBC,
'');
88 @mcrypt_generic_init(
$handle, $this->deployConfig->get(static::PATH_KEY),
$initVector);
92 @mcrypt_generic_deinit(
$handle);
const CIPHER_RIJNDAEL_256
static getObjectManager()