Esempio n. 1
0
 public function testValidateKeyDefault()
 {
     $crypt = $this->getMock('Magento\\Framework\\Encryption\\Crypt', array(), array(), '', false);
     $this->_cryptFactory->expects($this->once())->method('create')->with(array('key' => 'cryptKey'))->will($this->returnValue($crypt));
     $this->assertSame($crypt, $this->_model->validateKey(null));
     // Ensure crypt factory is invoked only once
     $this->assertSame($crypt, $this->_model->validateKey(null));
 }
Esempio n. 2
0
 public function testValidateKey()
 {
     $actual = $this->_model->validateKey('some_key');
     $crypt = new Crypt('some_key', MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC, $actual->getInitVector());
     $expectedEncryptedData = base64_encode($crypt->encrypt('data'));
     $actualEncryptedData = base64_encode($actual->encrypt('data'));
     $this->assertEquals($expectedEncryptedData, $actualEncryptedData);
     $this->assertEquals($crypt->decrypt($expectedEncryptedData), $actual->decrypt($actualEncryptedData));
 }
Esempio n. 3
0
 public function testValidateKey()
 {
     $validKey = md5(uniqid());
     $this->assertInstanceOf('Magento\\Framework\\Encryption\\Crypt', $this->_model->validateKey($validKey));
 }