Skip to content

Commit

Permalink
fix: disable verify in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoVoges committed Oct 5, 2023
1 parent c590206 commit ca8ef90
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 27 deletions.
31 changes: 4 additions & 27 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,6 @@
os.environ["GNUPGHOME"] = GNUPGHOME


@contextlib.contextmanager
def set_env(**environ):
"""
Temporarily set the process environment variables.
>>> with set_env(PLUGINS_DIR='test/plugins'):
... "PLUGINS_DIR" in os.environ
True
>>> "PLUGINS_DIR" in os.environ
False
:type environ: dict[str, unicode]
:param environ: Environment variables to set
"""
old_environ = dict(os.environ)
os.environ.update(environ)
try:
yield
finally:
os.environ.clear()
os.environ.update(old_environ)


class CliFuncsTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
Expand Down Expand Up @@ -720,8 +696,9 @@ def test_cli_secret_write_vault(self, mock_reveal):
"--vault-key",
"testkey",
]
with set_env(VAULT_ADDR=self.server.vault_url):
main()
env = {"VAULT_ADDR": self.server.vault_url, "VAULT_SKIP_VERIFY": "True"}
os.environ.update(**env)
main()

test_tag_content = "revealing: ?{vaultkv:test_secret}"
test_tag_file = tempfile.mktemp()
Expand All @@ -733,7 +710,7 @@ def test_cli_secret_write_vault(self, mock_reveal):

# set stdout as string
stdout = io.StringIO()
with contextlib.redirect_stdout(stdout), set_env(VAULT_ADDR=self.server.vault_url):
with contextlib.redirect_stdout(stdout):
main()
self.assertEqual("revealing: {value}".format(value=test_secret_content), stdout.getvalue())

Expand Down
3 changes: 3 additions & 0 deletions tests/vault_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ def __init__(self):
self.vault_container = self.setup_container()
self.setup_vault()

# disable tls verify for all clients
self.parameters["VAULT_SKIP_VERIFY"] = True

def setup_container(self):
env = {
"VAULT_LOCAL_CONFIG": '{"backend": {"file": {"path": "/vault/file"}}, "listener":{"tcp":{"address":"0.0.0.0:8200","tls_disable":"true"}}}'
Expand Down

0 comments on commit ca8ef90

Please sign in to comment.