-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MAGETWO-36930: [GITHUB] Store config re-encrypt encrypted values on s…
…ave #1223 - Fix to make sure values are not encrypted if not changed - Removed re-encrypting values - Added integration test
- Loading branch information
Showing
3 changed files
with
65 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
dev/tests/integration/testsuite/Magento/Config/Model/Config/Backend/EncryptedTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Config\Model\Config\Backend; | ||
|
||
use Magento\TestFramework\Helper\Bootstrap; | ||
|
||
/** | ||
* @magentoAppArea adminhtml | ||
*/ | ||
class EncryptedTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @magentoDbIsolation enabled | ||
*/ | ||
public function testEncryptionSave() | ||
{ | ||
$originalValue = '1Password'; | ||
|
||
/** @var $model \Magento\Config\Model\Config\Backend\Encrypted */ | ||
$model = Bootstrap::getObjectManager()->create('Magento\Config\Model\Config\Backend\Encrypted'); | ||
$model->setPath('carriers/usps/password'); | ||
$model->setScopeId(0); | ||
$model->setScope('default'); | ||
$model->setScopeCode(''); | ||
$model->setValue($originalValue); | ||
$model->save(); | ||
|
||
// Pass in the obscured value | ||
$model->setPath('carriers/usps/password'); | ||
$model->setScopeId(0); | ||
$model->setScope('default'); | ||
$model->setScopeCode(''); | ||
$model->setValue('*****'); | ||
$model->save(); | ||
|
||
//Verify original value is not changed for obscured value | ||
$value = $model->load($model->getId())->getValue(); | ||
$this->assertEquals($originalValue, $value, 'Original value is not expected to change.'); | ||
|
||
// Verify if actual value is changed | ||
$changedValue = 'newPassword'; | ||
|
||
$model->setPath('carriers/usps/password'); | ||
$model->setScopeId(0); | ||
$model->setScope('default'); | ||
$model->setScopeCode(''); | ||
$model->setValue($changedValue); | ||
$model->save(); | ||
|
||
//Verify original value is changed | ||
$value = $model->load($model->getId())->getValue(); | ||
$this->assertEquals($changedValue, $value, 'Original value is expected to change.'); | ||
} | ||
} |