-
Notifications
You must be signed in to change notification settings - Fork 45
[Enabler][2097]Add_template_for_test_with_privilege_escalation #2118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
f41f8fd
54a1b67
8954828
498e325
a99088d
f8537b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,7 @@ def pytest_addoption(parser): | |
| Add CLI options and modify options for pytest-ansible where needed. | ||
| Note: Set the default to to None, otherwise when evaluating with `request.config.getoption("--zinventory"):` | ||
| will always return true because a default will be returned. | ||
| New option have been added to the execution of the command to allow the become method. | ||
| """ | ||
| parser.addoption( | ||
| "--zinventory", | ||
|
|
@@ -54,6 +55,36 @@ def pytest_addoption(parser): | |
| default=None, | ||
| help="Str - dictionary with values {'host': 'ibm.com', 'user': 'root', 'zoau': '/usr/lpp/zoau', 'pyz': '/usr/lpp/IBM/pyz'}", | ||
| ) | ||
| parser.addoption( | ||
| "--user_adm", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this one could also be |
||
| action="store", | ||
| default=None, | ||
| help="Str " | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't forget to add the rest of the help mesasage for all the new options |
||
| ) | ||
| parser.addoption( | ||
| "--user_method", | ||
| action="store", | ||
| default=None, | ||
| help="Str " | ||
| ) | ||
| parser.addoption( | ||
| "--ansible_promp", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would change this one to |
||
| action="store", | ||
| default=None, | ||
| help="Str " | ||
| ) | ||
| parser.addoption( | ||
| "--password", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need both |
||
| action="store", | ||
| default=None, | ||
| help="Str " | ||
| ) | ||
| parser.addoption( | ||
| "--ssh_key", | ||
| action="store", | ||
| default=None, | ||
| help="Str " | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture(scope="session") | ||
|
|
@@ -204,3 +235,21 @@ def get_config(request): | |
| """ Call the pytest-ansible plugin to check volumes on the system and work properly a list by session.""" | ||
| path = request.config.getoption("--zinventory") | ||
| yield path | ||
|
|
||
| @pytest.fixture(scope="function") | ||
| def get_config_raw(request): | ||
| """ Call the pytest-ansible plugin to check the options on user manager test cases.""" | ||
| path = request.config.getoption("--zinventory-raw") | ||
| yield path | ||
|
|
||
| @pytest.fixture(scope='session') | ||
| def get_config_for_become(request): | ||
| """ Return as a dict the values to be used on the test cases for become method""" | ||
| become_config = { | ||
| "user" : request.config.option.user_adm, | ||
| "method" : request.config.option.user_method, | ||
| "promp" : request.config.option.ansible_promp, | ||
| "key" : request.config.option.password, | ||
| "ssh_key" : request.config.option.ssh_key | ||
| } | ||
| return become_config | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New option has been added (not have) to allow the become method to apply to the command.