diff --git a/cfme/configure/access_control/__init__.py b/cfme/configure/access_control/__init__.py index cf3f30a8f4..7a178413ff 100644 --- a/cfme/configure/access_control/__init__.py +++ b/cfme/configure/access_control/__init__.py @@ -1008,7 +1008,7 @@ class Role(Updateable, Pretty, BaseEntity): pretty_attrs = ['name', 'product_features'] - name = attr.ib(default=None) + name = attr.ib() vm_restriction = attr.ib(default=None) product_features = attr.ib(default=None) @@ -1135,7 +1135,7 @@ def set_role_product_features(view, product_features): class RoleCollection(BaseCollection): ENTITY = Role - def create(self, name=None, vm_restriction=None, product_features=None, cancel=False): + def create(self, name, vm_restriction=None, product_features=None, cancel=False): """ Create role method Args: @@ -1151,7 +1151,6 @@ def create(self, name=None, vm_restriction=None, product_features=None, cancel=F for currently selected role """ flash_blocked_msg = "Name has already been taken" - role = self.instantiate( name=name, vm_restriction=vm_restriction, product_features=product_features ) diff --git a/cfme/fixtures/tag.py b/cfme/fixtures/tag.py index 19e4b98280..a4c7d7be7b 100644 --- a/cfme/fixtures/tag.py +++ b/cfme/fixtures/tag.py @@ -21,11 +21,12 @@ def category(appliance): display_name=fauxfactory.gen_alphanumeric(length=32) ) yield cg + appliance.server.login_admin() cg.delete_if_exists() @pytest.fixture(scope="session") -def tag(category): +def tag(category, appliance): """ Returns random created tag object Object can be used in all test run session @@ -35,6 +36,7 @@ def tag(category): display_name=fauxfactory.gen_alphanumeric(length=32) ) yield tag + appliance.server.login_admin() tag.delete_if_exists() @@ -47,6 +49,7 @@ def role(appliance): name='role{}'.format(fauxfactory.gen_alphanumeric()), vm_restriction='None') yield role + appliance.server.login_admin() role.delete_if_exists() @@ -61,6 +64,7 @@ def group_with_tag(appliance, role, category, tag): tag=([category.display_name, tag.display_name], True) ) yield group + appliance.server.login_admin() group.delete_if_exists() @@ -78,6 +82,7 @@ def user_restricted(appliance, group_with_tag, new_credential): cost_center='Workload', value_assign='Database') yield user + appliance.server.login_admin() user.delete_if_exists() @@ -86,9 +91,8 @@ def new_credential(): """ Returns credentials object used for new user in test module """ - # Todo remove .lower() for principal after 1486041 fix return Credential( - principal='uid{}'.format(fauxfactory.gen_alphanumeric().lower()), secret='redhat') + principal='uid{}'.format(fauxfactory.gen_alphanumeric()), secret='redhat') @pytest.fixture(scope='function') diff --git a/cfme/tests/configure/test_access_control.py b/cfme/tests/configure/test_access_control.py index 393378d0a3..4c72910c46 100644 --- a/cfme/tests/configure/test_access_control.py +++ b/cfme/tests/configure/test_access_control.py @@ -760,11 +760,13 @@ def test_rolename_required_error_validation(appliance): # When trying to create a role with no name, the Add button is disabled. # We are waiting for an Exception saying that there are no success # or fail messages, because the Add button cannot be clicked. - with pytest.raises(Exception, match=r"Available messages: \[\]"): - appliance.collections.roles.create( - name=None, - vm_restriction='Only User Owned' - ) + view = navigate_to(appliance.collections.roles, 'Add') + view.fill({'name_txt': '', + 'vm_restriction_select': 'Only User Owned'}) + assert view.add_button.disabled + view.fill({'name_txt': 'test-required-name'}) + assert not view.add_button.disabled + view.cancel_button.click() @pytest.mark.tier(3) @@ -777,13 +779,13 @@ def test_rolename_duplicate_validation(appliance): tags: rbac """ name = 'rol{}'.format(fauxfactory.gen_alphanumeric()) - role = new_role(appliance, name=name) - with pytest.raises(RBACOperationBlocked): - new_role(appliance, name=name) - - # Navigating away from this page will create an "Abandon Changes" alert - # Since group creation failed we need to reset the state of the page - navigate_to(role.appliance.server, 'Dashboard') + role = appliance.collections.roles.create(name=name) + assert role.exists + view = navigate_to(appliance.collections.roles, 'Add') + view.fill({'name_txt': name}) + view.add_button.click() + view.flash.assert_message('Name has already been taken', 'error') + view.cancel_button.click() @pytest.mark.tier(3) diff --git a/cfme/utils/appliance/implementations/common.py b/cfme/utils/appliance/implementations/common.py index 61eeff880e..f1fa7e555d 100644 --- a/cfme/utils/appliance/implementations/common.py +++ b/cfme/utils/appliance/implementations/common.py @@ -71,12 +71,14 @@ def handle_alert(self, cancel=False, wait=30.0, squash=False, prompt=None, check # throws timeout exception if not found try: if wait: - alert = wait_for(self.get_alert, num_sec=wait, fail_condition=None).out - if isinstance(alert, Modal) and BZ(1713399): + popup = wait_for(self.get_alert, num_sec=wait, fail_condition=None).out + if isinstance(popup, Modal) and BZ(1713399).blocks: # infinispinner if accept button is clicked too quick in modal sleep(1) - - popup = self.get_alert() + else: + popup = self.get_alert() + if popup is None: + raise TimedOutError('Pretending to timeout, no wait') # same logging self.logger.info('handling alert: %r', popup.text) if prompt is not None: self.logger.info(' answering prompt: %r', prompt) @@ -94,9 +96,12 @@ def handle_alert(self, cancel=False, wait=30.0, squash=False, prompt=None, check self.dismiss_any_alerts() return True except TimedOutError: + # we waited (or didn't), and there was no alert if check_present: + self.logger.error('handle_alert timed out with wait of %s, raising', wait) raise else: + self.logger.info('handle_alert found no alert with wait of %s', wait) return None except Exception: if squash: