Skip to content

Commit

Permalink
Added '--es-encrypted' option to require encrypted vault file
Browse files Browse the repository at this point in the history
Details:

* Added a pytest option '--es-encrypted' to the plugin that requires that the
  vault file (if specified) is encrypted. This is a safeguard against checking
  in decrypted vault files by mistake. (issue #44)

* Because this functionality requires easy-server 0.7.0, the minimum version
  has been increased accordingly.

Signed-off-by: Andreas Maier <andreas.r.maier@gmx.de>
  • Loading branch information
andy-maier committed Apr 5, 2021
1 parent ff1f186 commit 3cf96b8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
6 changes: 6 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ Released: not yet

* Increased development status to Beta. (issue #34)

* Added a pytest option '--es-encrypted' to the plugin that requires that the
vault file (if specified) is encrypted. This is a safeguard against checking
in decrypted vault files by mistake. (issue #44)

* Increased the minimum version of easy-server to 0.7.0. (related to issue #44)

**Cleanup:**

**Known issues:**
Expand Down
4 changes: 2 additions & 2 deletions minimum-constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ wheel==0.36.0; python_version >= '3.9'

# Direct dependencies for installation (must be consistent with requirements.txt)

easy-server==0.6.0
easy-server==0.7.0

# pytest
pytest==4.3.1; python_version <= '3.6'
Expand All @@ -100,7 +100,7 @@ pytest==4.4.0; python_version >= '3.7'

# Indirect dependencies for installation (must be consistent with requirements.txt, if present)

easy_vault==0.6.1
easy-vault==0.7.0

# PyYAML is also pulled in by dparse and python-coveralls
PyYAML==5.3.1; python_version == '2.7'
Expand Down
16 changes: 16 additions & 0 deletions pytest_easy_server/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ def pytest_addoption(parser):
Default: The default from the easy-server file.
""")

group.addoption(
'--es-encrypted',
dest='es_encrypted',
action='store_true',
default=False,
help="""\
Require that the vault file (if specified) is encrypted and error out otherwise.
Default: Tolerate unencrypted vault file
""")


def fixtureid_es_server(fixture_value):
"""
Expand Down Expand Up @@ -123,6 +133,12 @@ def pytest_generate_tests(metafunc):
if exit_message:
pytest.exit(exit_message)

if config.getvalue('es_encrypted'):
if esf_obj.is_vault_file_encrypted() is False:
pytest.exit("Vault file is required to be encrypted but is "
"not encrypted: {vfn}".
format(vfn=esf_obj.vault_file))

exit_message = None
try:
es_obj_list = esf_obj.list_default_servers() \
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# Direct dependencies (except pip, setuptools, wheel):

# git+https://github.com/andy-maier/easy-server.git@master#egg=easy-server
easy-server>=0.6.0
easy-server>=0.7.0

# pytest
# pytest 5.0.0 has removed support for Python < 3.5
Expand All @@ -28,7 +28,7 @@ pytest>=4.4.0; python_version >= '3.7'

# Indirect dependencies are not specified in this file, except when needed:

easy_vault>=0.6.1
easy-vault>=0.7.0

# PyYAML 5.3 removed support for Python 3.4
# PyYAML 5.3 fixed narrow build error on Python 2.7
Expand Down

0 comments on commit 3cf96b8

Please sign in to comment.