-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pytest verifies and logs in into vault
- Loading branch information
Showing
2 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |