Skip to content

Commit

Permalink
Merge pull request #30 from wwkimball/development
Browse files Browse the repository at this point in the history
Release 2.0.2
  • Loading branch information
wwkimball authored May 30, 2019
2 parents a97b836 + b2871a0 commit 4ec376f
Show file tree
Hide file tree
Showing 17 changed files with 1,171 additions and 255 deletions.
11 changes: 7 additions & 4 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,13 @@ confidence=
# --disable=W".

# WWK-2019-05-24: Disable R0401 because I cannot get pylint to throw it on my
# OSX box yet Travis throws it on every run. Until OSX and Travis can agree on
# when an R0401 occurs, I cannot troubleshoot what otherwise appear to be
# false-positives.
disable=R0401
# OSX box yet Travis throws it on every run. Until OSX and Travis can agree
# on when an R0401 occurs, I cannot troubleshoot what otherwise appear to be
# false-positives.
# WWK-2019-05-30: Disable R0801 because similar command-line tools necessarily
# share duplicate code. This is by design so each can stand-alone.
disable=R0401,
R0801

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ python:
- 3.6

install:
- pip install --upgrade ruamel.yaml mypy pytest pytest-cov pylint coveralls
- pip install --upgrade ruamel.yaml mypy pytest pytest-cov pytest-console-scripts pylint coveralls
- gem install hiera-eyaml

script:
Expand Down
12 changes: 12 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
2.0.2:
Bug Fixes:
* eyaml-rotate-keys was broken by the refactoring for 2.0.0. eyaml-rotate-keys
v1.0.2 restores functionality.

Enhancements:
* Command-line tools are now managed via pip as entry_points/console_scripts
rather than external binaries. This enables superior cross-platform
compatibility as well as unit testing. As such, all of the CLI tools have
been updated pursuant to (generally trivial, excepting eyaml-rotate-keys)
issues discovered during their newfound CI tests.

2.0.1:
Bug Fixes:
* yaml-set v1.0.4 lost track of EYAML block formatting between read and write,
Expand Down
15 changes: 9 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="yamlpath",
version="2.0.1",
version="2.0.2",
description="Read and change YAML/Compatible data using powerful, intuitive, command-line friendly syntax",
long_description=long_description,
long_description_content_type="text/markdown",
Expand All @@ -22,18 +22,21 @@
license="ISC",
keywords="yaml eyaml yaml-path",
packages=setuptools.find_packages(),
scripts=[
"bin/eyaml-rotate-keys",
"bin/yaml-get",
"bin/yaml-set",
],
entry_points={
"console_scripts": [
"eyaml-rotate-keys = yamlpath.commands.eyaml_rotate_keys:main",
"yaml-get = yamlpath.commands.yaml_get:main",
"yaml-set = yamlpath.commands.yaml_set:main",
]
},
python_requires=">3.6.0",
install_requires=[
"ruamel.yaml>=0.15.96",
],
tests_require=[
"pytest",
"pytest-cov",
"pytest-console-scripts",
],
include_package_data=True,
zip_safe=False
Expand Down
152 changes: 152 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
"""Define reusable pytest fixtures."""
import tempfile
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(scope="session")
def old_eyaml_keys(tmp_path_factory):
"""Creates temporary keys for encryption/decryption tests."""
old_key_path_name = "old-keys"
old_key_dir = tmp_path_factory.mktemp(old_key_path_name)
old_private_key_file = old_key_dir / EYAML_PRIVATE_KE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TGpmZSdvossL41KBCYJGjP+lIL/UpDJHBeiuqVQoDl4/UZqb5xF9SC2p2Of21
fmZmj4uUAT5FPtKMKCspmLWQeUEfiwIDAQABo1wwWjAPBgNVHRMBAf8EBTADAQH/
MB0GA1UdDgQWBBTUHb3HX8dBfYFL1J1sCv+uCum5AzAoBgNVHSMEITAfgBTUHb3H
X8dBfYFL1J1sCv+uCum5A6EEpAIwAIIBATANBgkqhkiG9w0BAQsFAAOCAQEAcw+0
dfHSLNAZD95G2pDnT2qShjmdLdbrDQhAXWhLeoWpXsKvC0iUyQaOF9ckl++tHM2g
ejm1vEOrZ+1uXK3qnMXPF99Wet686OhyoDt262Mt3wzGHNijAHEvQtjap8ZIwfOM
zFTvjmOlUScqF/Yg+htcGnJdQhWIrsD+exiY5Kz2IMtuW+yWLLP8bY5vPg6qfrp2
4VVJ3Md1gdSownd1Au5tqPXm6VfSgLiCm9iDPVsjDII9h8ydate1d2TBHPup+4tN
JZ5/muctimydC+S2oCn7ucsilxZD89N7rJjKXNfoUOGHjOEVQMa8RtZLzH2sUEaS
FktE6rH8a+8SwO+TGw==
-----END CERTIFICATE-----
"""

with open(old_private_key_file, 'w') as key_file:
key_file.write(old_private_key)

with open(old_public_key_file, 'w') as key_file:
key_file.write(old_public_key)

return (old_private_key_file, old_public_key_file)

@requireseyaml
@pytest.fixture(scope="session")
def new_eyaml_keys(tmp_path_factory):
"""Creates temporary keys for encryption/decryption tests."""
from subprocess import run

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()
)

return (new_private_key_file, new_public_key_file)

def create_temp_yaml_file(tmp_path_factory, content):
"""Creates a test YAML input file."""
fhnd = tempfile.NamedTemporaryFile(mode='w',
dir=tmp_path_factory.getbasetemp(),
suffix='.yaml',
delete=False)
fhnd.write(content)
return fhnd.name

@pytest.fixture(scope="session")
def imparsible_yaml_file(tmp_path_factory):
"""
Creates a YAML file that causes a ParserError when read by ruamel.yaml.
"""
content = '''{"json": "is YAML", "but_bad_json": "isn't anything!"'''
return create_temp_yaml_file(tmp_path_factory, content)

@pytest.fixture(scope="session")
def badsyntax_yaml_file(tmp_path_factory):
"""
Creates a YAML file that causes a ScannerError when read by ruamel.yaml.
"""
content = """---
# This YAML content contains a critical syntax error
& bad_anchor: is bad
"""
return create_temp_yaml_file(tmp_path_factory, content)

@pytest.fixture(scope="session")
def badcmp_yaml_file(tmp_path_factory):
"""
Creates a YAML file that causes a ComposerError when read by ruamel.yaml.
"""
content = """---
# This YAML file is improperly composed
this is a parsing error: *no such capability
"""
return create_temp_yaml_file(tmp_path_factory, content)
Loading

0 comments on commit 4ec376f

Please sign in to comment.