@@ -36,10 +36,10 @@ discard block |
||
| 36 | 36 | protected function setUp() |
| 37 | 37 | { |
| 38 | 38 | $this->keyStorage = $this->getMockBuilder('Mes\Security\CryptoBundle\KeyStorage\KeyStorageInterface') |
| 39 | - ->getMock(); |
|
| 39 | + ->getMock(); |
|
| 40 | 40 | |
| 41 | 41 | $this->keyGenerator = $this->getMockBuilder('Mes\Security\CryptoBundle\KeyGenerator\KeyGeneratorInterface') |
| 42 | - ->getMock(); |
|
| 42 | + ->getMock(); |
|
| 43 | 43 | |
| 44 | 44 | $this->keyManager = new KeyManager($this->keyStorage, $this->keyGenerator); |
| 45 | 45 | } |
@@ -54,9 +54,9 @@ discard block |
||
| 54 | 54 | public function testGenerateCreatesKey() |
| 55 | 55 | { |
| 56 | 56 | $this->keyGenerator->expects($this->once()) |
| 57 | - ->method('generate') |
|
| 58 | - ->with(null) |
|
| 59 | - ->will($this->returnValue($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface'))); |
|
| 57 | + ->method('generate') |
|
| 58 | + ->with(null) |
|
| 59 | + ->will($this->returnValue($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface'))); |
|
| 60 | 60 | |
| 61 | 61 | $key = $this->keyManager->generate(); |
| 62 | 62 | |
@@ -69,9 +69,9 @@ discard block |
||
| 69 | 69 | $secret = 'ThisIsASecretPassword'; |
| 70 | 70 | |
| 71 | 71 | $this->keyGenerator->expects($this->once()) |
| 72 | - ->method('generateFromAscii') |
|
| 73 | - ->with($key_encoded, $secret) |
|
| 74 | - ->will($this->returnValue($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface'))); |
|
| 72 | + ->method('generateFromAscii') |
|
| 73 | + ->with($key_encoded, $secret) |
|
| 74 | + ->will($this->returnValue($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface'))); |
|
| 75 | 75 | |
| 76 | 76 | $key = $this->keyManager->generateFromAscii($key_encoded, $secret); |
| 77 | 77 | |
@@ -81,16 +81,16 @@ discard block |
||
| 81 | 81 | public function testGetKeyReadsNotExistingKey() |
| 82 | 82 | { |
| 83 | 83 | $this->keyStorage->expects($this->once()) |
| 84 | - ->method('getKey') |
|
| 85 | - ->will($this->returnValue(null)); |
|
| 84 | + ->method('getKey') |
|
| 85 | + ->will($this->returnValue(null)); |
|
| 86 | 86 | |
| 87 | 87 | $this->keyGenerator->expects($this->once()) |
| 88 | - ->method('generate') |
|
| 89 | - ->with(null) |
|
| 90 | - ->will($this->returnValue($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface'))); |
|
| 88 | + ->method('generate') |
|
| 89 | + ->with(null) |
|
| 90 | + ->will($this->returnValue($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface'))); |
|
| 91 | 91 | |
| 92 | 92 | $this->keyStorage->expects($this->once()) |
| 93 | - ->method('setKey'); |
|
| 93 | + ->method('setKey'); |
|
| 94 | 94 | |
| 95 | 95 | $key = $this->keyManager->getKey(); |
| 96 | 96 | |
@@ -100,14 +100,14 @@ discard block |
||
| 100 | 100 | public function testGetKeyReadsExistingKey() |
| 101 | 101 | { |
| 102 | 102 | $this->keyStorage->expects($this->never()) |
| 103 | - ->method('setKey'); |
|
| 103 | + ->method('setKey'); |
|
| 104 | 104 | |
| 105 | 105 | $this->keyGenerator->expects($this->never()) |
| 106 | - ->method('generate'); |
|
| 106 | + ->method('generate'); |
|
| 107 | 107 | |
| 108 | 108 | $this->keyStorage->expects($this->once()) |
| 109 | - ->method('getKey') |
|
| 110 | - ->will($this->returnValue($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface'))); |
|
| 109 | + ->method('getKey') |
|
| 110 | + ->will($this->returnValue($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface'))); |
|
| 111 | 111 | |
| 112 | 112 | $key = $this->keyManager->getKey(); |
| 113 | 113 | |
@@ -117,8 +117,8 @@ discard block |
||
| 117 | 117 | public function testSetKeyStoresKey() |
| 118 | 118 | { |
| 119 | 119 | $this->keyStorage->expects($this->once()) |
| 120 | - ->method('setKey') |
|
| 121 | - ->with($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')); |
|
| 120 | + ->method('setKey') |
|
| 121 | + ->with($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')); |
|
| 122 | 122 | |
| 123 | 123 | $this->keyManager->setKey($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')); |
| 124 | 124 | } |
@@ -35,9 +35,9 @@ discard block |
||
| 35 | 35 | public function testEncryptEncryptsPlaintext() |
| 36 | 36 | { |
| 37 | 37 | $this->encryption->expects($this->once()) |
| 38 | - ->method('encrypt') |
|
| 39 | - ->with('The quick brown fox jumps over the lazy dog', $this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')) |
|
| 40 | - ->will($this->returnValue('ThisIsACipherText')); |
|
| 38 | + ->method('encrypt') |
|
| 39 | + ->with('The quick brown fox jumps over the lazy dog', $this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')) |
|
| 40 | + ->will($this->returnValue('ThisIsACipherText')); |
|
| 41 | 41 | |
| 42 | 42 | $ciphertext = $this->wrapper->encrypt('The quick brown fox jumps over the lazy dog', $this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')); |
| 43 | 43 | |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | { |
| 52 | 52 | try { |
| 53 | 53 | $this->encryption->expects($this->once()) |
| 54 | - ->method('encrypt') |
|
| 55 | - ->with('The quick brown fox jumps over the lazy dog', $this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')) |
|
| 56 | - ->will($this->throwException(new EnvironmentIsBrokenException())); |
|
| 54 | + ->method('encrypt') |
|
| 55 | + ->with('The quick brown fox jumps over the lazy dog', $this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')) |
|
| 56 | + ->will($this->throwException(new EnvironmentIsBrokenException())); |
|
| 57 | 57 | } catch (EnvironmentIsBrokenException $e) { |
| 58 | 58 | $this->throwException(new CryptoException()); |
| 59 | 59 | } |
@@ -64,9 +64,9 @@ discard block |
||
| 64 | 64 | public function testDecryptDecryptsCiphertext() |
| 65 | 65 | { |
| 66 | 66 | $this->encryption->expects($this->once()) |
| 67 | - ->method('decrypt') |
|
| 68 | - ->with('ThisIsACipherText', $this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')) |
|
| 69 | - ->will($this->returnValue('The quick brown fox jumps over the lazy dog')); |
|
| 67 | + ->method('decrypt') |
|
| 68 | + ->with('ThisIsACipherText', $this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')) |
|
| 69 | + ->will($this->returnValue('The quick brown fox jumps over the lazy dog')); |
|
| 70 | 70 | |
| 71 | 71 | $decryptedText = $this->wrapper->decrypt('ThisIsACipherText', $this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')); |
| 72 | 72 | |
@@ -80,9 +80,9 @@ discard block |
||
| 80 | 80 | { |
| 81 | 81 | try { |
| 82 | 82 | $this->encryption->expects($this->once()) |
| 83 | - ->method('decrypt') |
|
| 84 | - ->with('ThisIsACipherText', $this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')) |
|
| 85 | - ->will($this->throwException(new BaseCryptoException())); |
|
| 83 | + ->method('decrypt') |
|
| 84 | + ->with('ThisIsACipherText', $this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')) |
|
| 85 | + ->will($this->throwException(new BaseCryptoException())); |
|
| 86 | 86 | } catch (BaseCryptoException $e) { |
| 87 | 87 | $this->throwException(new CryptoException()); |
| 88 | 88 | } |
@@ -93,11 +93,11 @@ discard block |
||
| 93 | 93 | public function testEncryptFileEncryptsFile() |
| 94 | 94 | { |
| 95 | 95 | $this->encryption->expects($this->once()) |
| 96 | - ->method('encryptFile') |
|
| 97 | - ->will($this->returnCallback(function ($input, $output) { |
|
| 98 | - $fs = new Filesystem(); |
|
| 99 | - $fs->dumpFile($output, ''); |
|
| 100 | - })); |
|
| 96 | + ->method('encryptFile') |
|
| 97 | + ->will($this->returnCallback(function ($input, $output) { |
|
| 98 | + $fs = new Filesystem(); |
|
| 99 | + $fs->dumpFile($output, ''); |
|
| 100 | + })); |
|
| 101 | 101 | |
| 102 | 102 | $this->wrapper->encryptFile(__DIR__.'/file.txt', __DIR__.'/file.crypto', $this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')); |
| 103 | 103 | |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | public function testDecryptFileDecryptsEncryptedFile() |
| 110 | 110 | { |
| 111 | 111 | $this->encryption->expects($this->once()) |
| 112 | - ->method('decryptFile') |
|
| 113 | - ->will($this->returnCallback(function ($input, $output) { |
|
| 114 | - $fs = new Filesystem(); |
|
| 115 | - $fs->dumpFile($output, 'Plain text'); |
|
| 116 | - })); |
|
| 112 | + ->method('decryptFile') |
|
| 113 | + ->will($this->returnCallback(function ($input, $output) { |
|
| 114 | + $fs = new Filesystem(); |
|
| 115 | + $fs->dumpFile($output, 'Plain text'); |
|
| 116 | + })); |
|
| 117 | 117 | |
| 118 | 118 | $this->wrapper->decryptFile(__DIR__.'/file.crypto', __DIR__.'/file.txt', $this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')); |
| 119 | 119 | |
@@ -130,8 +130,8 @@ discard block |
||
| 130 | 130 | { |
| 131 | 131 | try { |
| 132 | 132 | $this->encryption->expects($this->once()) |
| 133 | - ->method('encryptFile') |
|
| 134 | - ->will($this->throwException(new BaseCryptoException())); |
|
| 133 | + ->method('encryptFile') |
|
| 134 | + ->will($this->throwException(new BaseCryptoException())); |
|
| 135 | 135 | } catch (BaseCryptoException $e) { |
| 136 | 136 | $this->throwException(new CryptoException()); |
| 137 | 137 | } |
@@ -146,8 +146,8 @@ discard block |
||
| 146 | 146 | { |
| 147 | 147 | try { |
| 148 | 148 | $this->encryption->expects($this->once()) |
| 149 | - ->method('decryptFile') |
|
| 150 | - ->will($this->throwException(new BaseCryptoException())); |
|
| 149 | + ->method('decryptFile') |
|
| 150 | + ->will($this->throwException(new BaseCryptoException())); |
|
| 151 | 151 | } catch (BaseCryptoException $e) { |
| 152 | 152 | $this->throwException(new CryptoException()); |
| 153 | 153 | } |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | protected function setUp() |
| 159 | 159 | { |
| 160 | 160 | $this->encryption = $this->getMockBuilder('Mes\Security\CryptoBundle\EncryptionInterface') |
| 161 | - ->getMock(); |
|
| 161 | + ->getMock(); |
|
| 162 | 162 | $this->wrapper = new EncryptionWrapper($this->encryption); |
| 163 | 163 | } |
| 164 | 164 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | { |
| 95 | 95 | $this->encryption->expects($this->once()) |
| 96 | 96 | ->method('encryptFile') |
| 97 | - ->will($this->returnCallback(function ($input, $output) { |
|
| 97 | + ->will($this->returnCallback(function($input, $output) { |
|
| 98 | 98 | $fs = new Filesystem(); |
| 99 | 99 | $fs->dumpFile($output, ''); |
| 100 | 100 | })); |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | { |
| 111 | 111 | $this->encryption->expects($this->once()) |
| 112 | 112 | ->method('decryptFile') |
| 113 | - ->will($this->returnCallback(function ($input, $output) { |
|
| 113 | + ->will($this->returnCallback(function($input, $output) { |
|
| 114 | 114 | $fs = new Filesystem(); |
| 115 | 115 | $fs->dumpFile($output, 'Plain text'); |
| 116 | 116 | })); |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | $this->assertHasDefinition('mes_crypto.raw_key'); |
| 33 | 33 | $this->assertSame('Defuse\Crypto\Key', $this->configuration->findDefinition('mes_crypto.raw_key') |
| 34 | - ->getClass(), 'Defuse\Crypto\Key class is correct'); |
|
| 34 | + ->getClass(), 'Defuse\Crypto\Key class is correct'); |
|
| 35 | 35 | |
| 36 | 36 | $this->assertNotHasDefinition('mes_crypto.crypto_loader'); |
| 37 | 37 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | $this->assertHasDefinition('mes_crypto.raw_key'); |
| 46 | 46 | $this->assertSame('Defuse\Crypto\KeyProtectedByPassword', $this->configuration->findDefinition('mes_crypto.raw_key') |
| 47 | - ->getClass(), 'KeyProtectedByPassword class is correct'); |
|
| 47 | + ->getClass(), 'KeyProtectedByPassword class is correct'); |
|
| 48 | 48 | |
| 49 | 49 | $this->assertNotHasDefinition('mes_crypto.crypto_loader'); |
| 50 | 50 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | $this->assertHasDefinition('mes_crypto.raw_key'); |
| 59 | 59 | $this->assertSame('Defuse\Crypto\KeyProtectedByPassword', $this->configuration->findDefinition('mes_crypto.raw_key') |
| 60 | - ->getClass(), 'Defuse\Crypto\KeyProtectedByPassword class is correct'); |
|
| 60 | + ->getClass(), 'Defuse\Crypto\KeyProtectedByPassword class is correct'); |
|
| 61 | 61 | $this->assertNotHasDefinition('mes_crypto.crypto_loader'); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -69,11 +69,11 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | $this->assertHasDefinition('mes_crypto.raw_key'); |
| 71 | 71 | $this->assertSame('Defuse\Crypto\KeyProtectedByPassword', $this->configuration->findDefinition('mes_crypto.raw_key') |
| 72 | - ->getClass(), 'Defuse\Crypto\KeyProtectedByPassword class is correct'); |
|
| 72 | + ->getClass(), 'Defuse\Crypto\KeyProtectedByPassword class is correct'); |
|
| 73 | 73 | $this->assertHasDefinition('mes_crypto.crypto_loader'); |
| 74 | 74 | |
| 75 | 75 | $keyResource = $this->configuration->findDefinition('mes_crypto.crypto_loader') |
| 76 | - ->getArgument(0); |
|
| 76 | + ->getArgument(0); |
|
| 77 | 77 | |
| 78 | 78 | $this->assertContains('key.crypto', $keyResource, sprintf('crypto file is %s', 'key.crypto')); |
| 79 | 79 | } |
@@ -86,11 +86,11 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | $this->assertHasDefinition('mes_crypto.raw_key'); |
| 88 | 88 | $this->assertSame('Defuse\Crypto\KeyProtectedByPassword', $this->configuration->findDefinition('mes_crypto.raw_key') |
| 89 | - ->getClass(), 'Defuse\Crypto\KeyProtectedByPassword class is correct'); |
|
| 89 | + ->getClass(), 'Defuse\Crypto\KeyProtectedByPassword class is correct'); |
|
| 90 | 90 | $this->assertHasDefinition('mes_crypto.crypto_loader'); |
| 91 | 91 | |
| 92 | 92 | $keyResource = $this->configuration->findDefinition('mes_crypto.crypto_loader') |
| 93 | - ->getArgument(0); |
|
| 93 | + ->getArgument(0); |
|
| 94 | 94 | |
| 95 | 95 | $this->assertContains('key.crypto', $keyResource, sprintf('crypto file is %s', 'key.crypto')); |
| 96 | 96 | |