|
@@ 53-63 (lines=11) @@
|
| 50 |
|
/** |
| 51 |
|
* @throws \Mes\Security\CryptoBundle\Exception\CryptoException |
| 52 |
|
*/ |
| 53 |
|
public function testEncryptWithKeyEncryptsPlaintext() |
| 54 |
|
{ |
| 55 |
|
$this->encryption->expects($this->once()) |
| 56 |
|
->method('encryptWithKey') |
| 57 |
|
->with('The quick brown fox jumps over the lazy dog', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock()) |
| 58 |
|
->will($this->returnValue('ThisIsACipherText')); |
| 59 |
|
|
| 60 |
|
$ciphertext = $this->wrapper->encryptWithKey('The quick brown fox jumps over the lazy dog', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock()); |
| 61 |
|
|
| 62 |
|
$this->assertTrue(ctype_print($ciphertext), 'is printable'); |
| 63 |
|
} |
| 64 |
|
|
| 65 |
|
/** |
| 66 |
|
* @expectedException \Mes\Security\CryptoBundle\Exception\CryptoException |
|
@@ 85-95 (lines=11) @@
|
| 82 |
|
/** |
| 83 |
|
* @throws \Mes\Security\CryptoBundle\Exception\CryptoException |
| 84 |
|
*/ |
| 85 |
|
public function testDecryptWithKeyDecryptsCiphertext() |
| 86 |
|
{ |
| 87 |
|
$this->encryption->expects($this->once()) |
| 88 |
|
->method('decryptWithKey') |
| 89 |
|
->with('ThisIsACipherText', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock()) |
| 90 |
|
->will($this->returnValue('The quick brown fox jumps over the lazy dog')); |
| 91 |
|
|
| 92 |
|
$decryptedText = $this->wrapper->decryptWithKey('ThisIsACipherText', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock()); |
| 93 |
|
|
| 94 |
|
$this->assertSame('The quick brown fox jumps over the lazy dog', $decryptedText); |
| 95 |
|
} |
| 96 |
|
|
| 97 |
|
/** |
| 98 |
|
* @expectedException \Mes\Security\CryptoBundle\Exception\CryptoException |