Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

Commit

Permalink
Fix product features for role used in v2v migration test for 511
Browse files Browse the repository at this point in the history
  • Loading branch information
nachandr committed Feb 4, 2020
1 parent 08dd9e1 commit d53569c
Showing 1 changed file with 31 additions and 9 deletions.
40 changes: 31 additions & 9 deletions cfme/tests/v2v/test_v2v_migrations_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,29 @@ def _cleanup():
pass


@pytest.fixture
def setup_user_for_v2v_migration(appliance, new_credential):
"""
Fixture to set up user for v2v migration.
A new role is also created that initially has access to all product features. The newly created
user has this role.
As part of the test, the role is updated so that the Migration tab is unavailable in the UI to
users with this role.
"""
role = new_role(appliance=appliance,
product_features=[(['Everything'], True)])
group = new_group(appliance=appliance, role=role.name)
user = new_user(appliance=appliance, group=group, credential=new_credential)

yield user, role

user.delete_if_exists()
group.delete_if_exists()
role.delete_if_exists()


@pytest.mark.provider(
classes=[RHEVMProvider],
selector=ONE_PER_VERSION,
Expand All @@ -335,9 +358,10 @@ def _cleanup():
required_flags=["v2v"],
scope="module",
)
def test_v2v_rbac(appliance, new_credential):
def test_v2v_rbac(appliance, setup_user_for_v2v_migration):
"""
Test migration with role-based access control
Test to verify that the Migration tab is available/unavailable in the UI with
role-based access control
Polarion:
assignee: sshveta
Expand All @@ -348,11 +372,7 @@ def test_v2v_rbac(appliance, new_credential):
startsin: 5.10
casecomponent: V2V
"""
role = new_role(appliance=appliance,
product_features=[(['Everything'], True)])
group = new_group(appliance=appliance, role=role.name)
user = new_user(appliance=appliance, group=group, credential=new_credential)
pytest.set_trace()
user, role = setup_user_for_v2v_migration
product_features = (
[(['Everything', 'Compute', 'Migration'], False)]
if appliance.version < "5.11"
Expand All @@ -362,17 +382,19 @@ def test_v2v_rbac(appliance, new_credential):
with user:
view = navigate_to(appliance.server, 'Dashboard')
nav_tree = view.navigation.nav_item_tree()
nav_tree_for_migration = nav_tree['Compute'] if appliance.version < "5.11" else nav_tree
# Checks migration option is disabled in navigation
assert 'Migration' not in nav_tree['Compute'], ('Migration found in nav tree, '
assert 'Migration' not in nav_tree_for_migration, ('Migration found in nav tree, '
'rbac should not allow this')

product_features = [(['Everything'], True)]
role.update({'product_features': product_features})
with user:
view = navigate_to(appliance.server, 'Dashboard', wait_for_view=15)
nav_tree = view.navigation.nav_item_tree()
nav_tree_for_migration = nav_tree['Compute'] if appliance.version < "5.11" else nav_tree
# Checks migration option is enabled in navigation
assert 'Migration' in nav_tree['Compute'], ('Migration not found in nav tree, '
assert 'Migration' in nav_tree_for_migration, ('Migration not found in nav tree, '
'rbac should allow this')


Expand Down

0 comments on commit d53569c

Please sign in to comment.