예제 #1
0
 def test_key_loaded(self):
     with open(self.key_file, 'wb') as f:
         f.write(base64.b64encode(os.urandom(16)))
     with open(self.key_file) as f:
         with mock.patch.object(six.moves.builtins, 'open') as mock_open:
             mock_open.return_value = f
             local.encrypt(b'abc')
             mock_open.assert_called_with(self.key_file, 'rb')
예제 #2
0
 def test_encrypt_decrypt(self):
     plaintext = b'myplaintext'
     ciphertext, decrypt_params = local.encrypt(plaintext)
     self.assertEqual(plaintext, local.decrypt(ciphertext, **decrypt_params))
예제 #3
0
 def test_key_created(self, os_makedirs):
     local.encrypt(b'abc')
     os_makedirs.assert_called_with(self.tmpdir)
     self.assertTrue(os.path.isfile(self.key_file))