Skip to content

Commit

Permalink
Pytest verifies and logs in into vault
Browse files Browse the repository at this point in the history
  • Loading branch information
jyejare committed Aug 30, 2023
1 parent 7b06777 commit e2db134
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
"""Global Configurations for py.test runner"""
import pytest


pytest_plugins = [
# Plugins
'pytest_plugins.auto_vault',
'pytest_plugins.disable_rp_params',
'pytest_plugins.external_logging',
'pytest_plugins.fixture_markers',
Expand Down
20 changes: 20 additions & 0 deletions pytest_plugins/auto_vault.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""Plugin enables pytest to notify and update the requirements"""
import os
import re
import subprocess
from pathlib import Path
from robottelo.logging import robottelo_root_dir


def pytest_addoption(parser):
"""Options to allow user to update the requirements"""
envpath = robottelo_root_dir.joinpath('.env')
# check if this is being executed by a user and not automation/CI
if (
re.search(r'\s*#.*VAULT_SECRET_ID_FOR_DYNACONF', envpath.read_text())
and 'VAULT_SECRET_ID_FOR_DYNACONF' not in os.environ
):
vstatus = subprocess.run("make vault-status", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).returncode
if vstatus != 0:
print('Vault token is expired, Browser opening to logging you in ...')
subprocess.run('make vault-login', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

0 comments on commit e2db134

Please sign in to comment.