From 34943c3a0de19f700a23cef50e9a21f96c6828c0 Mon Sep 17 00:00:00 2001 From: Andrii Balakhtar Date: Tue, 18 Jul 2017 18:04:31 +0300 Subject: [PATCH 1/2] Implemented test for BZ1390833 --- robottelo/ui/locators/base.py | 3 +- tests/foreman/ui/test_usergroup.py | 45 +++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/robottelo/ui/locators/base.py b/robottelo/ui/locators/base.py index f47ec9a0194..c9c75af79bc 100644 --- a/robottelo/ui/locators/base.py +++ b/robottelo/ui/locators/base.py @@ -1047,7 +1047,8 @@ "users.current_password": (By.ID, "user_current_password"), "users.password": (By.ID, "user_password"), "users.password_confirmation": (By.ID, "user_password_confirmation"), - "users.user": (By.XPATH, "//a[contains(., '%s')]"), + "users.user": ( + By.XPATH, "//a[contains(., '%s')][contains(@href, 'edit')]"), "users.table_value": (By.XPATH, "//td[contains(., '%s')]"), "users.default_org": ( By.XPATH, diff --git a/tests/foreman/ui/test_usergroup.py b/tests/foreman/ui/test_usergroup.py index b1ab58081cc..a0ff4a3c9cd 100644 --- a/tests/foreman/ui/test_usergroup.py +++ b/tests/foreman/ui/test_usergroup.py @@ -21,7 +21,7 @@ from robottelo.decorators import tier1, tier2 from robottelo.test import UITestCase from robottelo.ui.factory import make_usergroup -from robottelo.ui.locators import common_locators +from robottelo.ui.locators import common_locators, tab_locators from robottelo.ui.session import Session @@ -189,3 +189,46 @@ def test_positive_update_user(self): self.assertIsNotNone(self.usergroup.search(name)) self.usergroup.update(name, users=[user_name]) self.assertIsNotNone(self.usergroup.search(name)) + + @tier1 + def test_positive_update_org_with_admin_perms(self): + """Add non-admin user to a usergroup with administrative privileges and + make sure user can update his organizations + + :id: 13d50901-d94a-4ede-a134-d7b5e84c9a2c + + :BZ: 1390833 + + :expectedresults: user can update his assigned organizations + """ + new_org = entities.Organization().create() + password = gen_string('alpha') + user = entities.User( + admin=False, + default_organization=self.organization, + password=password, + organization=[self.organization], + ).create() + group_name = gen_string('alpha') + # Create a usergroup with admin permissions and associate the user + with Session(self.browser) as session: + make_usergroup( + session, name=group_name, org=self.organization.name) + self.assertIsNotNone(self.usergroup.search(group_name)) + self.usergroup.update( + group_name, users=[user.login], roles=['admin']) + self.assertIsNotNone(self.usergroup.search(group_name)) + # Login as the user and assign new organization + with Session(self.browser, user=user.login, password=password): + self.user.update( + user.login, + new_organizations=[new_org.name], + ) + # Make sure both organizations are assigned + self.user.click(self.user.search(user.login)) + self.user.click(tab_locators['users.tab_organizations']) + for org in (self.organization.name, new_org.name): + self.assertIsNotNone( + self.user.wait_until_element( + common_locators['entity_deselect'] % org) + ) From 5c78c0ab61dd7afc23baaf667224f243a0f1bd1f Mon Sep 17 00:00:00 2001 From: Andrii Balakhtar Date: Wed, 19 Jul 2017 16:01:47 +0300 Subject: [PATCH 2/2] Added similar test for updating location --- tests/foreman/ui/test_usergroup.py | 45 ++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/foreman/ui/test_usergroup.py b/tests/foreman/ui/test_usergroup.py index a0ff4a3c9cd..e77cc220366 100644 --- a/tests/foreman/ui/test_usergroup.py +++ b/tests/foreman/ui/test_usergroup.py @@ -232,3 +232,48 @@ def test_positive_update_org_with_admin_perms(self): self.user.wait_until_element( common_locators['entity_deselect'] % org) ) + + @tier1 + def test_positive_update_loc_with_admin_perms(self): + """Add non-admin user to a usergroup with administrative privileges and + make sure user can update his locations + + :id: 03fb44cb-1a15-4eca-93d5-346837055bd0 + + :BZ: 1390833 + + :expectedresults: user can update his assigned locations + """ + loc1 = entities.Location().create() + loc2 = entities.Location().create() + password = gen_string('alpha') + user = entities.User( + admin=False, + default_organization=self.organization, + location=[loc1], + organization=[self.organization], + password=password, + ).create() + group_name = gen_string('alpha') + # Create a usergroup with admin permissions and associate the user + with Session(self.browser) as session: + make_usergroup( + session, name=group_name, org=self.organization.name) + self.assertIsNotNone(self.usergroup.search(group_name)) + self.usergroup.update( + group_name, users=[user.login], roles=['admin']) + self.assertIsNotNone(self.usergroup.search(group_name)) + # Login as the user and assign new location + with Session(self.browser, user=user.login, password=password): + self.user.update( + user.login, + new_locations=[loc2.name], + ) + # Make sure both locations are assigned + self.user.click(self.user.search(user.login)) + self.user.click(tab_locators['users.tab_locations']) + for loc in (loc1.name, loc2.name): + self.assertIsNotNone( + self.user.wait_until_element( + common_locators['entity_deselect'] % loc) + )