diff --git a/cfme/fixtures/ansible_tower.py b/cfme/fixtures/ansible_tower.py index d56d089058..7026ad74ff 100644 --- a/cfme/fixtures/ansible_tower.py +++ b/cfme/fixtures/ansible_tower.py @@ -1,8 +1,11 @@ +from urllib.parse import urlparse + import fauxfactory import pytest from cfme.rest.gen_data import _creating_skeleton from cfme.utils.blockers import GH +from cfme.utils.update import update def ansible_tower_dialog_rest(request, appliance): @@ -124,3 +127,30 @@ def ansible_tower_dialog(request, appliance): if appliance.version < '5.11' or not GH(8836).blocks: service_dialog.delete_if_exists() + + +@pytest.fixture +def ansible_api_version_change(provider, ansible_api_version): + """ + Fixture to update Tower url to /api/vx in the UI so that all supported versions of API + can be tested. + + API version defaults to v1. So, if no version is specified, v1 is used except for things + which don't exist on v1. + If v2 is specified, v2 is used for everything. + + Ansible Tower 3.4, 3.5 support both API v1 and v2. + API v1 has been fully deprecated in Ansible Tower 3.6 and Tower 3.6 supports API v2 only. + + """ + original_url = provider.url + parsed = urlparse(provider.url) + + updated_url = f'{parsed.scheme}://{parsed.netloc}/api/{ansible_api_version}' + with update(provider, validate_credentials=True): + provider.url = updated_url + + yield + + with update(provider, validate_credentials=True): + provider.url = original_url diff --git a/cfme/infrastructure/config_management/__init__.py b/cfme/infrastructure/config_management/__init__.py index 08c0024f77..ef300c7f1e 100644 --- a/cfme/infrastructure/config_management/__init__.py +++ b/cfme/infrastructure/config_management/__init__.py @@ -369,13 +369,14 @@ def update(self, updates, cancel=False, validate_credentials=False): if validate_credentials: view.entities.form.validate.click() view.flash.assert_success_message('Credential validation was successful') - if cancel: + if cancel or view.entities.save.disabled: view.entities.cancel.click() view.flash.assert_success_message('Edit of Provider was cancelled by the user') else: view.entities.save.click() view.flash.assert_success_message( - '{} Provider "{}" was updated'.format(self.ui_type, updates['name'] or self.name)) + '{} Provider "{}" was updated'.format(self.ui_type, + updates.get('name') or self.name)) self.__dict__.update(**updates) def delete(self, cancel=False, wait_deleted=True, force=False): diff --git a/cfme/tests/services/test_ansible_workflow_servicecatalogs.py b/cfme/tests/services/test_ansible_workflow_servicecatalogs.py index c71ca6773e..4042554460 100644 --- a/cfme/tests/services/test_ansible_workflow_servicecatalogs.py +++ b/cfme/tests/services/test_ansible_workflow_servicecatalogs.py @@ -13,9 +13,7 @@ pytest.mark.tier(2), pytest.mark.provider([AnsibleTowerProvider], scope='module'), pytest.mark.usefixtures('setup_provider'), - pytest.mark.parametrize('workflow_type', ['multiple_job_workflow', 'inventory_sync_workflow'], - ids=['multiple_job_workflow', 'inventory_sync_workflow'], - scope='module'), + pytest.mark.parametrize('ansible_api_version', ['v1', 'v2']), pytest.mark.ignore_stream('upstream') ] @@ -41,8 +39,11 @@ def ansible_workflow_catitem(appliance, provider, dialog, catalog, workflow_type catalog_item.delete_if_exists() +@pytest.mark.parametrize('workflow_type', ['multiple_job_workflow', 'inventory_sync_workflow'], + ids=['multiple_job_workflow', 'inventory_sync_workflow'], scope='module') @pytest.mark.meta(automates=[BZ(1719051)]) -def test_tower_workflow_item(appliance, ansible_workflow_catitem): +def test_tower_workflow_item(appliance, ansible_workflow_catitem, workflow_type, + ansible_api_version_change): """Tests ordering of catalog items for Ansible Workflow templates Metadata: test_flag: provision @@ -68,7 +69,9 @@ def test_tower_workflow_item(appliance, ansible_workflow_catitem): ) -def test_retire_ansible_workflow(appliance, ansible_workflow_catitem): +@pytest.mark.parametrize('workflow_type', ['multiple_job_workflow'], ids=['multiple_job_workflow']) +def test_retire_ansible_workflow(appliance, ansible_workflow_catitem, workflow_type, + ansible_api_version_change): """Tests retiring of catalog items for Ansible Workflow templates Metadata: test_flag: provision diff --git a/cfme/tests/services/test_config_provider_servicecatalogs.py b/cfme/tests/services/test_config_provider_servicecatalogs.py index 1471d533e5..1024af4ed0 100644 --- a/cfme/tests/services/test_config_provider_servicecatalogs.py +++ b/cfme/tests/services/test_config_provider_servicecatalogs.py @@ -13,11 +13,8 @@ pytest.mark.provider([AnsibleTowerProvider], scope='module'), pytest.mark.usefixtures('setup_provider'), pytest.mark.tier(2), - pytest.mark.parametrize('job_type', ['template', 'template_limit', 'template_survey', - 'textarea_survey'], - ids=['template_job', 'template_limit_job', 'template_survey_job', 'textarea_survey_job'], - scope='module'), - pytest.mark.ignore_stream('upstream'), + pytest.mark.parametrize('ansible_api_version', ['v1', 'v2']), + pytest.mark.ignore_stream('upstream') ] @@ -39,9 +36,14 @@ def catalog_item(appliance, request, provider, ansible_tower_dialog, catalog, jo return catalog_item +@pytest.mark.parametrize('job_type', ['template', 'template_limit', 'template_survey', + 'textarea_survey'], + ids=['template_job', 'template_limit_job', 'template_survey_job', 'textarea_survey_job'], + scope='module') @pytest.mark.meta(automates=[BZ(1717500)]) # The 'textarea_survey' job type automates BZ 1717500 -def test_order_tower_catalog_item(appliance, provider, catalog_item, request, job_type): +def test_order_tower_catalog_item(appliance, provider, catalog_item, request, job_type, + ansible_api_version_change): """Tests ordering of catalog items for Ansible Template and Workflow jobs Metadata: test_flag: provision @@ -74,7 +76,9 @@ def test_order_tower_catalog_item(appliance, provider, catalog_item, request, jo 'List View') -def test_retire_ansible_service(appliance, catalog_item, request, job_type): +@pytest.mark.parametrize('job_type', ['template'], ids=['template_job']) +def test_retire_ansible_service(appliance, catalog_item, request, job_type, + ansible_api_version_change): """Tests retiring of catalog items for Ansible Template and Workflow jobs Metadata: test_flag: provision