@@ 156-167 (lines=12) @@ | ||
153 | /** |
|
154 | * @expectedException \Mes\Security\CryptoBundle\Exception\CryptoException |
|
155 | */ |
|
156 | public function testEncryptWithKeyFileThrowsException() |
|
157 | { |
|
158 | try { |
|
159 | $this->encryption->expects($this->once()) |
|
160 | ->method('encryptFileWithKey') |
|
161 | ->will($this->throwException(new BaseCryptoException())); |
|
162 | } catch (BaseCryptoException $e) { |
|
163 | $this->throwException(new CryptoException()); |
|
164 | } |
|
165 | ||
166 | $this->wrapper->encryptFileWithKey(__DIR__.'/file.txt', __DIR__.'/file.crypto', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock()); |
|
167 | } |
|
168 | ||
169 | /** |
|
170 | * @expectedException \Mes\Security\CryptoBundle\Exception\CryptoException |
|
@@ 172-183 (lines=12) @@ | ||
169 | /** |
|
170 | * @expectedException \Mes\Security\CryptoBundle\Exception\CryptoException |
|
171 | */ |
|
172 | public function testDecryptWithKeyFileThrowsException() |
|
173 | { |
|
174 | try { |
|
175 | $this->encryption->expects($this->once()) |
|
176 | ->method('decryptFileWithKey') |
|
177 | ->will($this->throwException(new BaseCryptoException())); |
|
178 | } catch (BaseCryptoException $e) { |
|
179 | $this->throwException(new CryptoException()); |
|
180 | } |
|
181 | ||
182 | $this->wrapper->decryptFileWithKey(__DIR__.'/file.crypto', __DIR__.'/file.txt', $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock()); |
|
183 | } |
|
184 | ||
185 | public function testEncryptWithPasswordEncryptsPlaintext() |
|
186 | { |
|
@@ 200-212 (lines=13) @@ | ||
197 | /** |
|
198 | * @expectedException \Mes\Security\CryptoBundle\Exception\CryptoException |
|
199 | */ |
|
200 | public function testEncryptWithPasswordEncryptsPlaintextThrowsException() |
|
201 | { |
|
202 | try { |
|
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())); |
|
207 | } catch (EnvironmentIsBrokenException $e) { |
|
208 | $this->throwException(new CryptoException()); |
|
209 | } |
|
210 | ||
211 | $this->wrapper->encryptWithPassword('The quick brown fox jumps over the lazy dog', 'SuperSecretPa$$word'); |
|
212 | } |
|
213 | ||
214 | public function testDecryptWithPasswordDecryptsCiphertext() |
|
215 | { |
|
@@ 229-241 (lines=13) @@ | ||
226 | /** |
|
227 | * @expectedException \Mes\Security\CryptoBundle\Exception\CryptoException |
|
228 | */ |
|
229 | public function testDecryptWithPasswordDecryptsCiphertextThrowsException() |
|
230 | { |
|
231 | try { |
|
232 | $this->encryption->expects($this->once()) |
|
233 | ->method('decryptWithPassword') |
|
234 | ->with('ThisIsACipherText', 'SuperSecretPa$$word') |
|
235 | ->will($this->throwException(new WrongKeyOrModifiedCiphertextException())); |
|
236 | } catch (BaseCryptoException $e) { |
|
237 | $this->throwException(new CryptoException()); |
|
238 | } |
|
239 | ||
240 | $this->wrapper->decryptWithPassword('ThisIsACipherText', 'SuperSecretPa$$word'); |
|
241 | } |
|
242 | ||
243 | public function testEncryptFileWithPasswordEncryptsFile() |
|
244 | { |
|
@@ 262-273 (lines=12) @@ | ||
259 | /** |
|
260 | * @expectedException \Mes\Security\CryptoBundle\Exception\CryptoException |
|
261 | */ |
|
262 | public function testEncryptFileWithPasswordEncryptsFileThrowsException() |
|
263 | { |
|
264 | try { |
|
265 | $this->encryption->expects($this->once()) |
|
266 | ->method('encryptFileWithPassword') |
|
267 | ->will($this->throwException(new EnvironmentIsBrokenException())); |
|
268 | } catch (EnvironmentIsBrokenException $e) { |
|
269 | $this->throwException(new CryptoException()); |
|
270 | } |
|
271 | ||
272 | $this->wrapper->encryptFileWithPassword(__DIR__.'/file.txt', __DIR__.'/file.crypto', 'SuperSecretPa$$word'); |
|
273 | } |
|
274 | ||
275 | public function testDecryptFileWithPasswordDecryptsEncryptedFile() |
|
276 | { |
|
@@ 295-306 (lines=12) @@ | ||
292 | /** |
|
293 | * @expectedException \Mes\Security\CryptoBundle\Exception\CryptoException |
|
294 | */ |
|
295 | public function testDecryptFileWithPasswordDecryptsEncryptedFileThrowsException() |
|
296 | { |
|
297 | try { |
|
298 | $this->encryption->expects($this->once()) |
|
299 | ->method('decryptFileWithPassword') |
|
300 | ->will($this->throwException(new WrongKeyOrModifiedCiphertextException())); |
|
301 | } catch (BaseCryptoException $e) { |
|
302 | $this->throwException(new CryptoException()); |
|
303 | } |
|
304 | ||
305 | $this->wrapper->decryptFileWithPassword(__DIR__.'/file.crypto', __DIR__.'/file.txt', 'SuperSecretPa$$word'); |
|
306 | } |
|
307 | } |
|
308 |