@@ -129,23 +129,23 @@ discard block |
||
129 | 129 | |
130 | 130 | // Reads encoded key from configuration file if key is not external. |
131 | 131 | $rawKeyDefinition->setClass($defuseKey) |
132 | - ->setFactory(array( |
|
133 | - $defuseKey, |
|
134 | - 'loadFromAsciiSafeString', |
|
135 | - )); |
|
132 | + ->setFactory(array( |
|
133 | + $defuseKey, |
|
134 | + 'loadFromAsciiSafeString', |
|
135 | + )); |
|
136 | 136 | $rawKeyDefinition->setArguments(array( |
137 | 137 | $keyIsExternal ? $loadKey : $key, |
138 | 138 | )); |
139 | 139 | } else { |
140 | 140 | $rawKeyDefinition->setClass($defuseKey) |
141 | - ->setArguments($secretExists ? array($secretIsExternal ? $loadSecret : $secret) : array()) |
|
142 | - ->setFactory($secretExists ? array( |
|
143 | - 'Defuse\Crypto\KeyProtectedByPassword', |
|
144 | - 'createRandomPasswordProtectedKey', |
|
145 | - ) : array( |
|
146 | - 'Defuse\Crypto\Key', |
|
147 | - 'createNewRandomKey', |
|
148 | - )); |
|
141 | + ->setArguments($secretExists ? array($secretIsExternal ? $loadSecret : $secret) : array()) |
|
142 | + ->setFactory($secretExists ? array( |
|
143 | + 'Defuse\Crypto\KeyProtectedByPassword', |
|
144 | + 'createRandomPasswordProtectedKey', |
|
145 | + ) : array( |
|
146 | + 'Defuse\Crypto\Key', |
|
147 | + 'createNewRandomKey', |
|
148 | + )); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | if ($createRandomKey || (!$createRandomKey && !$keyIsExternal)) { |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | } |
154 | 154 | |
155 | 155 | $container->setDefinition('mes_crypto.raw_key', $rawKeyDefinition) |
156 | - ->setPublic(false); |
|
156 | + ->setPublic(false); |
|
157 | 157 | |
158 | 158 | // Key |
159 | 159 | $keyDefinition = new Definition('Mes\Security\CryptoBundle\Model\Key', array( |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | 'create', |
166 | 166 | )); |
167 | 167 | $container->setDefinition('mes_crypto.key', $keyDefinition) |
168 | - ->setPublic(false); |
|
168 | + ->setPublic(false); |
|
169 | 169 | |
170 | 170 | $keyManagerDefinition = $container->getDefinition('mes_crypto.key_manager_wrapper'); |
171 | 171 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | private function setCryptoLoaderResource(ContainerBuilder $container, $resource) |
201 | 201 | { |
202 | 202 | $container->getDefinition('mes_crypto.crypto_loader') |
203 | - ->replaceArgument(0, $resource); |
|
203 | + ->replaceArgument(0, $resource); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | protected function setUp() |
37 | 37 | { |
38 | 38 | $this->keyManager = $this->getMockBuilder('\Mes\Security\CryptoBundle\KeyManagerInterface') |
39 | - ->getMock(); |
|
39 | + ->getMock(); |
|
40 | 40 | $this->wrapper = new KeyManagerWrapper($this->keyManager); |
41 | 41 | } |
42 | 42 | |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | public function testGenerateCreatesKey() |
49 | 49 | { |
50 | 50 | $this->keyManager->expects($this->once()) |
51 | - ->method('generate') |
|
52 | - ->with(null) |
|
53 | - ->will($this->returnValue($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface'))); |
|
51 | + ->method('generate') |
|
52 | + ->with(null) |
|
53 | + ->will($this->returnValue($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface'))); |
|
54 | 54 | |
55 | 55 | $key = $this->wrapper->generate(); |
56 | 56 | |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | { |
65 | 65 | try { |
66 | 66 | $this->keyManager->expects($this->once()) |
67 | - ->method('generate') |
|
68 | - ->with(null) |
|
69 | - ->will($this->throwException(new EnvironmentIsBrokenException())); |
|
67 | + ->method('generate') |
|
68 | + ->with(null) |
|
69 | + ->will($this->throwException(new EnvironmentIsBrokenException())); |
|
70 | 70 | } catch (EnvironmentIsBrokenException $ex) { |
71 | 71 | $this->throwException(new CryptoException()); |
72 | 72 | } |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | $secret = 'ThisIsASecretPassword'; |
81 | 81 | |
82 | 82 | $this->keyManager->expects($this->once()) |
83 | - ->method('generateFromAscii') |
|
84 | - ->with($key_encoded, $secret) |
|
85 | - ->will($this->returnValue($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface'))); |
|
83 | + ->method('generateFromAscii') |
|
84 | + ->with($key_encoded, $secret) |
|
85 | + ->will($this->returnValue($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface'))); |
|
86 | 86 | |
87 | 87 | $key = $this->wrapper->generateFromAscii($key_encoded, $secret); |
88 | 88 | |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | |
100 | 100 | try { |
101 | 101 | $this->keyManager->expects($this->once()) |
102 | - ->method('generateFromAscii') |
|
103 | - ->with($key_encoded, $secret) |
|
104 | - ->will($this->throwException(new BaseCryptoException())); |
|
102 | + ->method('generateFromAscii') |
|
103 | + ->with($key_encoded, $secret) |
|
104 | + ->will($this->throwException(new BaseCryptoException())); |
|
105 | 105 | } catch (CryptoException $ex) { |
106 | 106 | $this->throwException(new CryptoException()); |
107 | 107 | } |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | public function testGetKeyReadsKey() |
113 | 113 | { |
114 | 114 | $this->keyManager->expects($this->once()) |
115 | - ->method('getKey') |
|
116 | - ->will($this->returnValue($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface'))); |
|
115 | + ->method('getKey') |
|
116 | + ->will($this->returnValue($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface'))); |
|
117 | 117 | |
118 | 118 | $key = $this->wrapper->getKey(); |
119 | 119 | |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | public function testSetKeyStoresKey() |
124 | 124 | { |
125 | 125 | $this->keyManager->expects($this->once()) |
126 | - ->method('setKey') |
|
127 | - ->with($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')); |
|
126 | + ->method('setKey') |
|
127 | + ->with($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')); |
|
128 | 128 | |
129 | 129 | $this->wrapper->setKey($this->getMock('Mes\Security\CryptoBundle\Model\KeyInterface')); |
130 | 130 | } |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | public function testSetSecretStoresSecret() |
133 | 133 | { |
134 | 134 | $this->keyManager->expects($this->once()) |
135 | - ->method('setSecret') |
|
136 | - ->with('ThisIsASecret'); |
|
135 | + ->method('setSecret') |
|
136 | + ->with('ThisIsASecret'); |
|
137 | 137 | |
138 | 138 | $this->wrapper->setSecret('ThisIsASecret'); |
139 | 139 | } |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | public function testGetSecretReadsSecret() |
142 | 142 | { |
143 | 143 | $this->keyManager->expects($this->once()) |
144 | - ->method('getSecret') |
|
145 | - ->will($this->returnValue('ThisIsYourSecret')); |
|
144 | + ->method('getSecret') |
|
145 | + ->will($this->returnValue('ThisIsYourSecret')); |
|
146 | 146 | |
147 | 147 | $secret = $this->wrapper->getSecret(); |
148 | 148 |
@@ -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 |
@@ -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 |