コード例 #1
0
 def test_gpg_encrypt_file_passphrase(self):
     """
     Test encrypt/decrypt with passphrase
     """
     cmd_encrypt = gpg_encrypt_file_passphrase(EncryptionTest.test_file,
                                               "12345")
     print(cmd_encrypt)
     self.assertEqual(7, len(cmd_encrypt))
     expected_cmd_list = [
         'gpg', '--yes', '--batch', '--passphrase', '12345', '-c',
         EncryptionTest.test_file
     ]
     self.assertTrue(cmd_encrypt == expected_cmd_list)
     out = subprocess.call(cmd_encrypt, cwd=EncryptionTest.tmp_dir)
     self.assertEqual(0, out)
     cli_commands = CliCommands()
     cli_command = CliCommand(
         "gpg_passphrase_decrypt_file",
         cli_commands.get_command_template("gpg_passphrase_decrypt_file"))
     cmd_decrypt = cli_command.get_command({
         'encrypted_file':
         "%s.gpg" % EncryptionTest.test_file,
         'decrypted_file':
         "test_decrypted.txt",
         'passphrase':
         "12345"
     })
     out = subprocess.call(cmd_decrypt, cwd=EncryptionTest.tmp_dir)
     self.assertEqual(0, out)
     self.assertEqual(
         "test",
         read_file_content(
             os.path.join(EncryptionTest.tmp_dir, "test_decrypted.txt")))
コード例 #2
0
ファイル: test_cli.py プロジェクト: MatteoRomiti/eatb
 def test_cli_commands(self):
     cli_commands = CliCommands()
     cli_command = CliCommand("echo",
                              cli_commands.get_command_template("echo"))
     command = cli_command.get_command({'input': "test"})
     self.assertIsNotNone(command)
     self.assertEqual(2, len(command))
     self.assertEqual('echo', command[0])
     self.assertEqual('test', command[1])
コード例 #3
0
ファイル: encryption.py プロジェクト: MatteoRomiti/eatb
def gpg_encrypt_file_passphrase(file, passphrase):
    """
    Encrypt file using passphrase
    :param file: file
    :param passphrase: passphrase
    :return: CLI command string
    """
    cli_commands = CliCommands()
    cli_command = CliCommand(
        "gpg_passphrase_encrypt_file",
        cli_commands.get_command_template("gpg_passphrase_encrypt_file"))
    command = cli_command.get_command({'file': file, 'passphrase': passphrase})
    return command