@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | protected function setUp() |
38 | 38 | { |
39 | 39 | $this->encryption = $this->getMockBuilder('Mes\Security\CryptoBundle\EncryptionInterface') |
40 | - ->getMock(); |
|
40 | + ->getMock(); |
|
41 | 41 | $this->wrapper = new EncryptionWrapper($this->encryption); |
42 | 42 | } |
43 | 43 | |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | public function testEncryptWithKeyEncryptsPlaintext() |
54 | 54 | { |
55 | 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')); |
|
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 | 59 | |
60 | 60 | $ciphertext = $this->wrapper->encryptWithKey('The quick brown fox jumps over the lazy dog', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock()); |
61 | 61 | |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | { |
70 | 70 | try { |
71 | 71 | $this->encryption->expects($this->once()) |
72 | - ->method('encryptWithKey') |
|
73 | - ->with('The quick brown fox jumps over the lazy dog', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock()) |
|
74 | - ->will($this->throwException(new EnvironmentIsBrokenException())); |
|
72 | + ->method('encryptWithKey') |
|
73 | + ->with('The quick brown fox jumps over the lazy dog', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock()) |
|
74 | + ->will($this->throwException(new EnvironmentIsBrokenException())); |
|
75 | 75 | } catch (EnvironmentIsBrokenException $e) { |
76 | 76 | $this->throwException(new CryptoException()); |
77 | 77 | } |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | public function testDecryptWithKeyDecryptsCiphertext() |
86 | 86 | { |
87 | 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')); |
|
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 | 91 | |
92 | 92 | $decryptedText = $this->wrapper->decryptWithKey('ThisIsACipherText', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock()); |
93 | 93 | |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | { |
102 | 102 | try { |
103 | 103 | $this->encryption->expects($this->once()) |
104 | - ->method('decryptWithKey') |
|
105 | - ->with('ThisIsACipherText', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock()) |
|
106 | - ->will($this->throwException(new BaseCryptoException())); |
|
104 | + ->method('decryptWithKey') |
|
105 | + ->with('ThisIsACipherText', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock()) |
|
106 | + ->will($this->throwException(new BaseCryptoException())); |
|
107 | 107 | } catch (BaseCryptoException $e) { |
108 | 108 | $this->throwException(new CryptoException()); |
109 | 109 | } |
@@ -117,11 +117,11 @@ discard block |
||
117 | 117 | public function testEncryptWithKeyFileEncryptsFile() |
118 | 118 | { |
119 | 119 | $this->encryption->expects($this->once()) |
120 | - ->method('encryptFileWithKey') |
|
121 | - ->will($this->returnCallback(function ($input, $output) { |
|
122 | - $fs = new Filesystem(); |
|
123 | - $fs->dumpFile($output, ''); |
|
124 | - })); |
|
120 | + ->method('encryptFileWithKey') |
|
121 | + ->will($this->returnCallback(function ($input, $output) { |
|
122 | + $fs = new Filesystem(); |
|
123 | + $fs->dumpFile($output, ''); |
|
124 | + })); |
|
125 | 125 | |
126 | 126 | $this->wrapper->encryptFileWithKey(__DIR__.'/file.txt', __DIR__.'/file.crypto', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock()); |
127 | 127 | |
@@ -136,11 +136,11 @@ discard block |
||
136 | 136 | public function testDecryptWithKeyFileDecryptsEncryptedFile() |
137 | 137 | { |
138 | 138 | $this->encryption->expects($this->once()) |
139 | - ->method('decryptFileWithKey') |
|
140 | - ->will($this->returnCallback(function ($input, $output) { |
|
141 | - $fs = new Filesystem(); |
|
142 | - $fs->dumpFile($output, 'Plain text'); |
|
143 | - })); |
|
139 | + ->method('decryptFileWithKey') |
|
140 | + ->will($this->returnCallback(function ($input, $output) { |
|
141 | + $fs = new Filesystem(); |
|
142 | + $fs->dumpFile($output, 'Plain text'); |
|
143 | + })); |
|
144 | 144 | |
145 | 145 | $this->wrapper->decryptFileWithKey(__DIR__.'/file.crypto', __DIR__.'/file.txt', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock()); |
146 | 146 | |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | { |
158 | 158 | try { |
159 | 159 | $this->encryption->expects($this->once()) |
160 | - ->method('encryptFileWithKey') |
|
161 | - ->will($this->throwException(new BaseCryptoException())); |
|
160 | + ->method('encryptFileWithKey') |
|
161 | + ->will($this->throwException(new BaseCryptoException())); |
|
162 | 162 | } catch (BaseCryptoException $e) { |
163 | 163 | $this->throwException(new CryptoException()); |
164 | 164 | } |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | { |
174 | 174 | try { |
175 | 175 | $this->encryption->expects($this->once()) |
176 | - ->method('decryptFileWithKey') |
|
177 | - ->will($this->throwException(new BaseCryptoException())); |
|
176 | + ->method('decryptFileWithKey') |
|
177 | + ->will($this->throwException(new BaseCryptoException())); |
|
178 | 178 | } catch (BaseCryptoException $e) { |
179 | 179 | $this->throwException(new CryptoException()); |
180 | 180 | } |
@@ -185,9 +185,9 @@ discard block |
||
185 | 185 | public function testEncryptWithPasswordEncryptsPlaintext() |
186 | 186 | { |
187 | 187 | $this->encryption->expects($this->once()) |
188 | - ->method('encryptWithPassword') |
|
189 | - ->with('The quick brown fox jumps over the lazy dog', 'SuperSecretPa$$word') |
|
190 | - ->will($this->returnValue('ThisIsACipherText')); |
|
188 | + ->method('encryptWithPassword') |
|
189 | + ->with('The quick brown fox jumps over the lazy dog', 'SuperSecretPa$$word') |
|
190 | + ->will($this->returnValue('ThisIsACipherText')); |
|
191 | 191 | |
192 | 192 | $ciphertext = $this->wrapper->encryptWithPassword('The quick brown fox jumps over the lazy dog', 'SuperSecretPa$$word'); |
193 | 193 | |
@@ -201,9 +201,9 @@ discard block |
||
201 | 201 | { |
202 | 202 | try { |
203 | 203 | $this->encryption->expects($this->once()) |
204 | - ->method('encryptWithPassword') |
|
205 | - ->with('The quick brown fox jumps over the lazy dog', 'SuperSecretPa$$word') |
|
206 | - ->will($this->throwException(new EnvironmentIsBrokenException())); |
|
204 | + ->method('encryptWithPassword') |
|
205 | + ->with('The quick brown fox jumps over the lazy dog', 'SuperSecretPa$$word') |
|
206 | + ->will($this->throwException(new EnvironmentIsBrokenException())); |
|
207 | 207 | } catch (EnvironmentIsBrokenException $e) { |
208 | 208 | $this->throwException(new CryptoException()); |
209 | 209 | } |
@@ -214,9 +214,9 @@ discard block |
||
214 | 214 | public function testDecryptWithPasswordDecryptsCiphertext() |
215 | 215 | { |
216 | 216 | $this->encryption->expects($this->once()) |
217 | - ->method('decryptWithPassword') |
|
218 | - ->with('ThisIsACipherText', 'SuperSecretPa$$word') |
|
219 | - ->will($this->returnValue('The quick brown fox jumps over the lazy dog')); |
|
217 | + ->method('decryptWithPassword') |
|
218 | + ->with('ThisIsACipherText', 'SuperSecretPa$$word') |
|
219 | + ->will($this->returnValue('The quick brown fox jumps over the lazy dog')); |
|
220 | 220 | |
221 | 221 | $decryptedText = $this->wrapper->decryptWithPassword('ThisIsACipherText', 'SuperSecretPa$$word'); |
222 | 222 | |
@@ -230,9 +230,9 @@ discard block |
||
230 | 230 | { |
231 | 231 | try { |
232 | 232 | $this->encryption->expects($this->once()) |
233 | - ->method('decryptWithPassword') |
|
234 | - ->with('ThisIsACipherText', 'SuperSecretPa$$word') |
|
235 | - ->will($this->throwException(new WrongKeyOrModifiedCiphertextException())); |
|
233 | + ->method('decryptWithPassword') |
|
234 | + ->with('ThisIsACipherText', 'SuperSecretPa$$word') |
|
235 | + ->will($this->throwException(new WrongKeyOrModifiedCiphertextException())); |
|
236 | 236 | } catch (BaseCryptoException $e) { |
237 | 237 | $this->throwException(new CryptoException()); |
238 | 238 | } |
@@ -243,11 +243,11 @@ discard block |
||
243 | 243 | public function testEncryptFileWithPasswordEncryptsFile() |
244 | 244 | { |
245 | 245 | $this->encryption->expects($this->once()) |
246 | - ->method('encryptFileWithPassword') |
|
247 | - ->will($this->returnCallback(function ($input, $output, $password) { |
|
248 | - $fs = new Filesystem(); |
|
249 | - $fs->dumpFile($output, ''); |
|
250 | - })); |
|
246 | + ->method('encryptFileWithPassword') |
|
247 | + ->will($this->returnCallback(function ($input, $output, $password) { |
|
248 | + $fs = new Filesystem(); |
|
249 | + $fs->dumpFile($output, ''); |
|
250 | + })); |
|
251 | 251 | |
252 | 252 | $this->wrapper->encryptFileWithPassword(__DIR__.'/file.txt', __DIR__.'/file.crypto', 'SuperSecretPa$$word'); |
253 | 253 | |
@@ -263,8 +263,8 @@ discard block |
||
263 | 263 | { |
264 | 264 | try { |
265 | 265 | $this->encryption->expects($this->once()) |
266 | - ->method('encryptFileWithPassword') |
|
267 | - ->will($this->throwException(new EnvironmentIsBrokenException())); |
|
266 | + ->method('encryptFileWithPassword') |
|
267 | + ->will($this->throwException(new EnvironmentIsBrokenException())); |
|
268 | 268 | } catch (EnvironmentIsBrokenException $e) { |
269 | 269 | $this->throwException(new CryptoException()); |
270 | 270 | } |
@@ -275,11 +275,11 @@ discard block |
||
275 | 275 | public function testDecryptFileWithPasswordDecryptsEncryptedFile() |
276 | 276 | { |
277 | 277 | $this->encryption->expects($this->once()) |
278 | - ->method('decryptFileWithPassword') |
|
279 | - ->will($this->returnCallback(function ($input, $output, $password) { |
|
280 | - $fs = new Filesystem(); |
|
281 | - $fs->dumpFile($output, 'Plain text'); |
|
282 | - })); |
|
278 | + ->method('decryptFileWithPassword') |
|
279 | + ->will($this->returnCallback(function ($input, $output, $password) { |
|
280 | + $fs = new Filesystem(); |
|
281 | + $fs->dumpFile($output, 'Plain text'); |
|
282 | + })); |
|
283 | 283 | |
284 | 284 | $this->wrapper->decryptFileWithPassword(__DIR__.'/file.crypto', __DIR__.'/file.txt', 'SuperSecretPa$$word'); |
285 | 285 | |
@@ -296,8 +296,8 @@ discard block |
||
296 | 296 | { |
297 | 297 | try { |
298 | 298 | $this->encryption->expects($this->once()) |
299 | - ->method('decryptFileWithPassword') |
|
300 | - ->will($this->throwException(new WrongKeyOrModifiedCiphertextException())); |
|
299 | + ->method('decryptFileWithPassword') |
|
300 | + ->will($this->throwException(new WrongKeyOrModifiedCiphertextException())); |
|
301 | 301 | } catch (BaseCryptoException $e) { |
302 | 302 | $this->throwException(new CryptoException()); |
303 | 303 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | { |
119 | 119 | $this->encryption->expects($this->once()) |
120 | 120 | ->method('encryptFileWithKey') |
121 | - ->will($this->returnCallback(function ($input, $output) { |
|
121 | + ->will($this->returnCallback(function($input, $output) { |
|
122 | 122 | $fs = new Filesystem(); |
123 | 123 | $fs->dumpFile($output, ''); |
124 | 124 | })); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | { |
138 | 138 | $this->encryption->expects($this->once()) |
139 | 139 | ->method('decryptFileWithKey') |
140 | - ->will($this->returnCallback(function ($input, $output) { |
|
140 | + ->will($this->returnCallback(function($input, $output) { |
|
141 | 141 | $fs = new Filesystem(); |
142 | 142 | $fs->dumpFile($output, 'Plain text'); |
143 | 143 | })); |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | { |
245 | 245 | $this->encryption->expects($this->once()) |
246 | 246 | ->method('encryptFileWithPassword') |
247 | - ->will($this->returnCallback(function ($input, $output, $password) { |
|
247 | + ->will($this->returnCallback(function($input, $output, $password) { |
|
248 | 248 | $fs = new Filesystem(); |
249 | 249 | $fs->dumpFile($output, ''); |
250 | 250 | })); |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | { |
277 | 277 | $this->encryption->expects($this->once()) |
278 | 278 | ->method('decryptFileWithPassword') |
279 | - ->will($this->returnCallback(function ($input, $output, $password) { |
|
279 | + ->will($this->returnCallback(function($input, $output, $password) { |
|
280 | 280 | $fs = new Filesystem(); |
281 | 281 | $fs->dumpFile($output, 'Plain text'); |
282 | 282 | })); |