Exemple #1
0
def handle_decryption(args):
    source_path = Path(args.source)
    destination_path = Path(args.destination) if args.destination else None

    threads = args.threads if args.threads else 1
    decrypt_existing_archive(source_path,
                             destination_path,
                             args.remove,
                             args.force,
                             threads=threads)
def test_decrypt_regular_archive_error_existing(tmp_path, setup_gpg):
    folder_name = "test-folder"
    archive_path = helpers.get_directory_with_name("encrypted-archive")
    destination_path = tmp_path / folder_name
    destination_path.mkdir()

    with pytest.raises(SystemExit) as error:
        decrypt_existing_archive(archive_path, destination_path)

        assert error.type == SystemExit
def test_decrypt_regular_archive_to_destination(tmp_path, setup_gpg):
    folder_name = "test-folder"
    archive_path = helpers.get_directory_with_name("encrypted-archive")
    destination_path = tmp_path / folder_name

    decrypt_existing_archive(archive_path, destination_path)
    assert_successful_action_to_destination(destination_path,
                                            archive_path,
                                            folder_name,
                                            encrypted=False)
def test_decrypt_archive_split_to_destination(tmp_path):
    folder_name = "large-folder"
    archive_path = helpers.get_directory_with_name("split-encrypted-archive")
    destination_path = tmp_path / folder_name

    decrypt_existing_archive(archive_path, destination_path)
    assert_successful_action_to_destination(destination_path,
                                            archive_path,
                                            folder_name,
                                            encrypted=False,
                                            split=3)
def test_decrypt_regular_archive_remove_unencrypted(tmp_path, setup_gpg):
    folder_name = "test-folder"
    archive_path = helpers.get_directory_with_name("encrypted-archive")
    copied_archive_path = tmp_path / folder_name
    shutil.copytree(archive_path, copied_archive_path)

    decrypt_existing_archive(copied_archive_path, remove_unencrypted=True)
    assert_successful_archive_creation(copied_archive_path,
                                       archive_path,
                                       folder_name,
                                       encrypted="hash",
                                       unencrypted="all")
def test_decrypt_regular_file(tmp_path, setup_gpg):
    folder_name = "test-folder"
    archive_path = helpers.get_directory_with_name("encrypted-archive")
    copied_archive_path = tmp_path / folder_name
    archive_file = copied_archive_path / f"{folder_name}.tar.lz.gpg"
    shutil.copytree(archive_path, copied_archive_path)

    decrypt_existing_archive(archive_file)
    assert_successful_archive_creation(copied_archive_path,
                                       archive_path,
                                       folder_name,
                                       encrypted="all",
                                       unencrypted="all")
def test_decrypt_archive_split(tmp_path, setup_gpg):
    folder_name = "large-folder"
    archive_path = helpers.get_directory_with_name("split-encrypted-archive")
    copied_archive_path = tmp_path / folder_name
    shutil.copytree(archive_path, copied_archive_path)

    decrypt_existing_archive(copied_archive_path)
    assert_successful_archive_creation(copied_archive_path,
                                       archive_path,
                                       folder_name,
                                       encrypted="all",
                                       unencrypted="all",
                                       split=3)
Exemple #8
0
def handle_encryption(args):
    source_path = Path(args.source)
    destination_path = Path(args.destination) if args.destination else None

    remove_unencrypted = args.remove

    threads = args.threads if args.threads else 1

    if args.reencrypt:
        # Always remove the unencrypted archive when --reencrypt is used since there was no unencrypted archive present
        remove_unencrypted = True
        # Encrypted archive will be removed in any case, since new one will be created
        decrypt_existing_archive(source_path,
                                 remove_unencrypted=True,
                                 threads=threads)

    encrypt_existing_archive(source_path,
                             args.key,
                             destination_path,
                             remove_unencrypted,
                             args.force,
                             threads=threads)