def new_eyaml_keys(tmp_path_factory): """Creates temporary keys for encryption/decryption tests.""" new_key_path_name = "new-keys" new_key_dir = tmp_path_factory.mktemp(new_key_path_name) new_private_key_file = new_key_dir / EYAML_PRIVATE_KEY_FILENAME new_public_key_file = new_key_dir / EYAML_PUBLIC_KEY_FILENAME run("{} createkeys --pkcs7-private-key={} --pkcs7-public-key={}".format( EYAMLProcessor.get_eyaml_executable("eyaml"), new_private_key_file, new_public_key_file).split(), check=True) return (new_private_key_file, new_public_key_file)
def test_non_executable(self, old_eyaml_keys, force_no_access): assert EYAMLProcessor.get_eyaml_executable(str(old_eyaml_keys[0])) is None
def test_impossible_eyaml_exe(self, exe): assert None == EYAMLProcessor.get_eyaml_executable(exe)
import tempfile from subprocess import run from types import SimpleNamespace import pytest from yamlpath.wrappers import ConsolePrinter from yamlpath.eyaml import EYAMLProcessor # Implied constants EYAML_PRIVATE_KEY_FILENAME = "private_key.pkcs7.pem" EYAML_PUBLIC_KEY_FILENAME = "public_key.pkcs7.pem" # pylint: disable=locally-disabled,invalid-name requireseyaml = pytest.mark.skipif( EYAMLProcessor.get_eyaml_executable("eyaml") is None, reason="The 'eyaml' command must be installed and accessible on the PATH" + " to test and use EYAML features. Try: 'gem install hiera-eyaml'" + " after intalling ruby and rubygems.") @pytest.fixture def quiet_logger(): """Returns a quiet ConsolePrinter.""" args = SimpleNamespace(verbose=False, quiet=True, debug=False) return ConsolePrinter(args) @pytest.fixture def info_warn_logger(): """Returns a quiet ConsolePrinter."""