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

[1LP][RFR] Automate test to verify key pair visibility in child tenants #9768

Merged
merged 10 commits into from
Jan 17, 2020

Conversation

nachandr
Copy link
Contributor

@nachandr nachandr commented Dec 13, 2019

Purpose or Intent

1.Automated test to verify key pair visibility in child tenants
2.Moved fixtures related to multi tenancy to a separate file
3.Added set_ownership method and SetOwnership view to cloud key pair page

PRT Run

{{ pytest: cfme/tests/cloud/test_keypairs.py::test_keypair_visibility_in_tenants cfme/tests/configure/test_access_control.py::test_tenantadmin_user_crud }}

PRT results:
510 - PASS
511- PASS

@nachandr nachandr changed the title [WIP] Automate test to view key pair as tenant admin [RFR] Automate test to view key pair as tenant admin Dec 17, 2019
@dajoRH dajoRH removed the WIP label Dec 17, 2019
Copy link
Contributor

@john-dupuy john-dupuy left a comment

Choose a reason for hiding this comment

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

Looking good! I have some small questions

@@ -184,6 +185,41 @@ def download_private_key(self):
view.toolbar.configuration.item_select('Download private key')
view.flash.assert_no_error()

def set_ownership(self, owner=None, group=None, click_cancel=False, click_reset=False):
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional

Suggested change
def set_ownership(self, owner=None, group=None, click_cancel=False, click_reset=False):
def set_ownership(self, owner=None, group=None, cancel=False, reset=False):

Copy link
Member

Choose a reason for hiding this comment

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

Required

Entity/collection methods need to be consistent with their kwargs.

Copy link
Member

Choose a reason for hiding this comment

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

I see that common/vm has these kwargs - but its inconsistent with the rest of the framework kwargs for these methods.

cfme/cloud/keypairs.py Outdated Show resolved Hide resolved
view = navigate_to(appliance.collections.cloud_keypairs, 'All')
key_pair = view.entities.get_first_entity().data['name']
key_pair_obj = appliance.collections.cloud_keypairs.instantiate(key_pair)
key_pair_obj.set_ownership("", new_tenant_admin.groups[0].description)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the empty string here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm just setting group ownership and not user ownership, so updated the statement so that it's done the right way.

from cfme.utils.update import update


def new_user(appliance, groups, name=None, credential=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

Q I would expect this to be a fixture, is there a reason it isn't?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated it to be a fixture.

Copy link
Member

Choose a reason for hiding this comment

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

We have so many of these fixtures defined in multiple test modules, it would be great to consolidate them, as many of them repeat the same kwargs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it would be nice to consolidate the fixtures. I will work on it in a follow up PR.

@john-dupuy john-dupuy added enhancement test-cleanup Test removal, collection changes, re-organization labels Dec 19, 2019
@mshriver mshriver self-assigned this Dec 19, 2019
@@ -184,6 +185,41 @@ def download_private_key(self):
view.toolbar.configuration.item_select('Download private key')
view.flash.assert_no_error()

def set_ownership(self, owner=None, group=None, click_cancel=False, click_reset=False):
"""Set instance ownership
Copy link
Member

Choose a reason for hiding this comment

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

keypair, not instance :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated :)

else:
# save the form
view.form.save_button.click()
view = self.create_view(navigator.get_class(self, 'Details').VIEW)
Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -184,6 +185,41 @@ def download_private_key(self):
view.toolbar.configuration.item_select('Download private key')
view.flash.assert_no_error()

def set_ownership(self, owner=None, group=None, click_cancel=False, click_reset=False):
Copy link
Member

Choose a reason for hiding this comment

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

This looks like something that a mixin implementation would be appropriate for, like with the Tagging classes.

We have multiple entities that can have ownership set, and they use a common form and form data. We can define an ownership class that can be inherited by any entity classes that support ownership.

I'd call it out of scope for this PR, but would be a good enhancement so we don't continue to re-implement this method on multiple entities.



@pytest.fixture(scope='module')
def child_tenant(appliance):
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for moving these out to a separate fixture file!

@nachandr nachandr changed the title [RFR] Automate test to view key pair as tenant admin [WIP] Automate test to view key pair as tenant admin Dec 19, 2019
@pytest.fixture(scope='module')
def tenant_role(appliance, request):
role = appliance.collections.roles.instantiate(name='EvmRole-tenant_administrator')
tenant_role = role.copy()
Copy link
Member

Choose a reason for hiding this comment

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

👍



@pytest.fixture(scope='module')
def new_tenant_admin(appliance, request, child_tenant, tenant_role):
Copy link
Member

Choose a reason for hiding this comment

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

Consider using a name like child_tenant_admin_user so its more obvious that its producing a user entity. With the current name I was kind of expecting a tenant entity.

Docblocks for these fixtures would be very helpful :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@dajoRH dajoRH added the WIP label Dec 19, 2019

@pytest.mark.meta(automates=[1741635, 1747179])
@test_requirements.multi_tenancy
def test_tenantadmin_view_keypair(appliance, new_tenant_admin):
Copy link
Member

Choose a reason for hiding this comment

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

Consider a test function name that better indicates that its an ownership test - test_tenant_keypair_ownership?

The assertion scope for the test case could be expanded, to do more assertion around the setting of ownership for a keypair (flash message asserts), as well as adding some parametrization to cover both a tenant that should not have visibility and one that does.

Copy link
Contributor Author

@nachandr nachandr Dec 20, 2019

Choose a reason for hiding this comment

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

I have changed the test name to test_keypair_visibility_in_tenants since this is more of a keypair visibility test based on key pair ownership.

I will add parametrization to cover a tenant that doesn't have visibility in a follow up PR.

@nachandr nachandr changed the title [WIP] Automate test to view key pair as tenant admin [RFR] Automate test to view key pair as tenant admin Dec 20, 2019
@dajoRH dajoRH removed the WIP label Dec 20, 2019
@nachandr nachandr changed the title [RFR] Automate test to view key pair as tenant admin [RFR] Automate test to verify key pair visibility in child tenants Dec 20, 2019
cfme/fixtures/multi_tenancy.py Show resolved Hide resolved
@@ -29,7 +30,6 @@ def keypair(appliance, provider):

@pytest.mark.meta(blockers=[BZ(1718833, forced_streams=["5.10", "5.11"],
unblock=lambda provider: provider.one_of(OpenStackProvider))])
Copy link
Member

Choose a reason for hiding this comment

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

This BZ is closed.

In [1]: BZ(1718833, forced_streams=["5.10", "5.11"]).blocks                                                                                                                  
.....
....
...
Found matching bug for 1718833 by release - #1718833
Out[1]: False
  • Can we remove the blockers marker?

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree, we should remove this @nachandr, and include it as automates or docblock metadata.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


Steps:
1. Copy the EvmRole_tenant_admin role to a new role (Since this role does not have the
Auth Key Pairs feature enabled)
Copy link
Member

Choose a reason for hiding this comment

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

please add steps under polarion data under tag - testSteps:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -1574,7 +1532,8 @@ def test_superadmin_tenant_admin_crud(appliance):

@pytest.mark.tier(2)
@test_requirements.multi_tenancy
def test_tenantadmin_group_crud(new_tenant_admin, tenant_role, child_tenant, request, appliance):
def test_tenantadmin_group_crud(child_tenant_admin_user, tenant_role, child_tenant, request,
appliance):
"""
Copy link
Member

Choose a reason for hiding this comment

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

Please improve formatting.

@@ -1641,7 +1600,8 @@ def test_tenant_unique_catalog(appliance, request, catalog_obj):

@pytest.mark.ignore_stream("upstream")
@test_requirements.multi_tenancy
def test_tenantadmin_user_crud(new_tenant_admin, tenant_role, child_tenant, request, appliance):
def test_tenantadmin_user_crud(child_tenant_admin_user, tenant_role, child_tenant, request,
appliance):
Copy link
Member

Choose a reason for hiding this comment

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

same here

@ganeshhubale ganeshhubale changed the title [RFR] Automate test to verify key pair visibility in child tenants [WIPTEST] Automate test to verify key pair visibility in child tenants Dec 24, 2019
@nachandr nachandr changed the title [WIPTEST] Automate test to verify key pair visibility in child tenants [RFR] Automate test to verify key pair visibility in child tenants Jan 14, 2020
Copy link
Contributor

@john-dupuy john-dupuy left a comment

Choose a reason for hiding this comment

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

Two small comments, please address @ganeshhubale's comments as well. Thanks for your work on this @nachandr

cfme/cloud/keypairs.py Outdated Show resolved Hide resolved
@@ -29,7 +30,6 @@ def keypair(appliance, provider):

@pytest.mark.meta(blockers=[BZ(1718833, forced_streams=["5.10", "5.11"],
unblock=lambda provider: provider.one_of(OpenStackProvider))])
Copy link
Contributor

Choose a reason for hiding this comment

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

Agree, we should remove this @nachandr, and include it as automates or docblock metadata.

@john-dupuy john-dupuy changed the title [RFR] Automate test to verify key pair visibility in child tenants [WIPTEST] Automate test to verify key pair visibility in child tenants Jan 16, 2020
@dajoRH
Copy link
Contributor

dajoRH commented Jan 16, 2020

I detected some fixture changes in commit a8d6b60

The global fixture child_tenant is used in the following files:

  • cfme/tests/configure/test_access_control.py
    • test_tenantadmin_group_crud
    • test_tenantadmin_user_crud

The global fixture tenant_role is used in the following files:

  • cfme/tests/configure/test_access_control.py
    • test_tenantadmin_group_crud
    • test_tenantadmin_user_crud

The global fixture child_tenant_admin_user is used in the following files:

  • cfme/tests/cloud/test_keypairs.py
    • test_keypair_visibility_in_tenants
  • cfme/tests/configure/test_access_control.py
    • test_tenantadmin_group_crud
    • test_tenantadmin_user_crud

Please, consider creating a PRT run to make sure your fixture changes do not break existing usage 😃

@nachandr nachandr changed the title [WIPTEST] Automate test to verify key pair visibility in child tenants [RFR] Automate test to verify key pair visibility in child tenants Jan 16, 2020
Copy link
Contributor

@john-dupuy john-dupuy left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks @nachandr!

@john-dupuy john-dupuy changed the title [RFR] Automate test to verify key pair visibility in child tenants [1LP][RFR] Automate test to verify key pair visibility in child tenants Jan 17, 2020
@mshriver mshriver merged commit 9aeff84 into ManageIQ:master Jan 17, 2020
spusateri pushed a commit to spusateri/integration_tests that referenced this pull request Jan 27, 2020
…ts (ManageIQ#9768)

* Automate test to view key pair as tenant admin

* Automate test to view key pair as tenant admin

* Automate test to view key pair as tenant admin

* Automate test to view key pair as tenant admin

* Automate test to view key pair as tenant admin

* Automate test to view key pair as tenant admin

* Automate test to view key pair as tenant admin

* Automate test to view key pair as tenant admin

* Automate test to verify key pair visibility in child tenants

* Automate test to verify key pair visibility in child tenants
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement lint-ok test-cleanup Test removal, collection changes, re-organization
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants