Skip to content

Commit

Permalink
Converted unittest to pytest.
Browse files Browse the repository at this point in the history
While we were at it we did a little bit of refactoring.
  • Loading branch information
waynew committed Nov 10, 2022
1 parent 3ff0b1f commit fbe301e
Show file tree
Hide file tree
Showing 2 changed files with 820 additions and 730 deletions.
23 changes: 13 additions & 10 deletions salt/modules/tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ def _microtime():
return "{:f}{}".format(val1, val2)


def _context_or_config(key):
"""
Return the value corresponding to the key in __context__ or if not present,
fallback to config.option.
"""
return __context__.get(key, __salt__["config.option"](key))


def cert_base_path(cacert_path=None):
"""
Return the base path for certs from CLI or from options
Expand All @@ -185,16 +193,11 @@ def cert_base_path(cacert_path=None):
salt '*' tls.cert_base_path
"""
if not cacert_path:
cacert_path = __context__.get(
"ca.contextual_cert_base_path",
__salt__["config.option"]("ca.contextual_cert_base_path"),
)
if not cacert_path:
cacert_path = __context__.get(
"ca.cert_base_path", __salt__["config.option"]("ca.cert_base_path")
)
return cacert_path
return (
cacert_path
or _context_or_config("ca.contextual_cert_base_path")
or _context_or_config("ca.cert_base_path")
)


def _cert_base_path(cacert_path=None):
Expand Down
Loading

0 comments on commit fbe301e

Please sign in to comment.