Skip to content

Commit f860995

Browse files
committed
MAGETWO-96314: Fix performance on MAGETWO-81469
- fixed unit test
1 parent db74133 commit f860995

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/internal/Magento/Framework/Encryption/Test/Unit/EncryptorTest.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public function validateHashDataProvider()
109109
* @param mixed $key
110110
*
111111
* @dataProvider encryptWithEmptyKeyDataProvider
112+
* @expectedException \SodiumException
112113
*/
113114
public function testEncryptWithEmptyKey($key)
114115
{
@@ -161,8 +162,14 @@ public function testEncrypt()
161162
$data = 'Mares eat oats and does eat oats, but little lambs eat ivy.';
162163

163164
$actual = $this->_model->encrypt($data);
165+
166+
// Extract the initialization vector and encrypted data
167+
$parts = explode(':', $actual, 3);
168+
list(, , $encryptedData) = $parts;
169+
170+
$crypt = new SodiumChachaIetf(self::CRYPT_KEY_1);
164171
// Verify decrypted matches original data
165-
$this->assertEquals($data, $this->_model->decrypt($actual));
172+
$this->assertEquals($data, $crypt->decrypt(base64_decode((string)$encryptedData)));
166173
}
167174

168175
public function testDecrypt()
@@ -186,7 +193,7 @@ public function testLegacyDecrypt()
186193
list(, , $iv, $encrypted) = $parts;
187194

188195
// Decrypt returned data with RIJNDAEL_256 cipher, cbc mode
189-
$crypt = new Crypt(self::CRYPT_KEY_1, MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB, $iv);
196+
$crypt = new Crypt(self::CRYPT_KEY_1, MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC, $iv);
190197
// Verify decrypted matches original data
191198
$this->assertEquals($encrypted, base64_encode($crypt->encrypt($actual)));
192199
}
@@ -217,7 +224,7 @@ public function testEncryptDecryptNewKeyAdded()
217224

218225
public function testValidateKey()
219226
{
220-
$this->assertNull($this->_model->validateKey(self::CRYPT_KEY_1));
227+
$this->_model->validateKey(self::CRYPT_KEY_1);
221228
}
222229

223230
/**
@@ -259,3 +266,4 @@ public function testGetHashMustUseSpecifiedHashingAlgo($password, $salt, $hashAl
259266
$this->assertEquals($expected, $hash);
260267
}
261268
}
269+

0 commit comments

Comments
 (0)