def test_cmdline_decrypt_file(self, filedir, mock_pass): """Check if the decrypted file is actually there and the content is as expected.""" filedir.makedir('directory') path = os.path.join(filedir.path, 'directory', 'output.file') mock_pass.return_value = pgp_data.PGP_PASSPHRASE run(['decrypt', '--sk', self._sk, '-i', self._crypted, '-o', path]) result = filedir.read(('directory', 'output.file')) self.assertEqual(pgp_data.ORG_FILE, result) filedir.cleanup()
def test_cmdline_reencrypt_file(self, filedir, mock_pass): """Check if the reencrypted file is actually there and the header is crypt4gh.""" filedir.makedir('directory') path = os.path.join(filedir.path, 'directory', 'output.file') mock_pass.return_value = pgp_data.PGP_PASSPHRASE run([ 'reencrypt', '--sk', self._sk, '--pk', self._pk, '-i', self._crypted, '-o', path ]) result = filedir.read(('directory', 'output.file')) self.assertEqual(b'crypt4gh', result[:8]) filedir.cleanup()
def test_cmdline_run_reencrypt_pubring(self, mock_reencrypt, mock_pass): """Reencrypt from the command line should call the reencrypt function.""" mock_pass.return_value = pgp_data.PGP_PASSPHRASE run(['reencrypt', '--sk', self._sk, '--pk', self._pk]) mock_reencrypt.assert_called()
def test_cmdline_run_encrypt_pubring(self, mock_encrypt): """Encrypt from the command line should call the encrypt function.""" run(['encrypt', '--pk', self._pk]) mock_encrypt.assert_called()
def test_cmdline_run_list_pubring(self, mock_ring): """Listing with specific pubring should call the Pubring.""" run(['list', '--pubring', self._path]) mock_ring.assert_called()
def test_cmdline_encrypt_key_notfound(self): """Raise error if key not found in default pubring.""" with self.assertRaises(ValueError): run(['encrypt', '-r', 'Denmark', '--pubring', self._path])
def test_cmdline_server_notimplemented(self): """Trying to access server keys should raise NotImplementedError.""" with self.assertRaises(NotImplementedError): run(['list', '--server', 'someserver.com'])