Skip to content
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

Implemented test for BZ1390833 #4986

Merged
merged 2 commits into from
Jul 27, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion robottelo/ui/locators/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')]"),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the user tries to search for himself on users page - this locator will return 2 elements, the first one is username at top right corner (user's menu).

"users.user": (
By.XPATH, "//a[contains(., '%s')][contains(@href, 'edit')]"),
"users.table_value": (By.XPATH, "//td[contains(., '%s')]"),
"users.default_org": (
By.XPATH,
Expand Down
45 changes: 44 additions & 1 deletion tests/foreman/ui/test_usergroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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)
)