diff --git a/ranger_tempest_plugin/config.py b/ranger_tempest_plugin/config.py index ac248bc..d1bd16f 100755 --- a/ranger_tempest_plugin/config.py +++ b/ranger_tempest_plugin/config.py @@ -54,9 +54,6 @@ ORM_GROUP_OPTIONS = [ cfg.StrOpt("catalog_type", default='ranger', help="ranger catalog type"), - cfg.StrOpt("domain", - default='Default', - help="Domain used for Ranger tempest testing"), cfg.StrOpt("alt_region_available", default=False, help="Alt region for ranger tempest testing"), @@ -64,4 +61,7 @@ ORM_GROUP_OPTIONS = [ default='', help="Provide alternate region for creating" "resources with multiple regions"), + cfg.StrOpt("test_rbac", + default=False, + help="Determines if rbac tests should be ran") ] diff --git a/ranger_tempest_plugin/schemas/regions_schema.py b/ranger_tempest_plugin/schemas/regions_schema.py index 0838e63..29e11d5 100644 --- a/ranger_tempest_plugin/schemas/regions_schema.py +++ b/ranger_tempest_plugin/schemas/regions_schema.py @@ -43,6 +43,7 @@ _region = { 'description': {'type': 'string'}, 'designType': {'type': 'string'}, 'locationType': {'type': 'string'}, + 'domainName': {'type': 'string'}, 'vlcpName': {'type': 'string'}, 'address': { 'type': 'object', @@ -150,7 +151,8 @@ list_region_v1 = { 'OS_version': {'type': 'string'}, 'keystone_EP': {'type': 'string'}, 'zone_name': {'type': 'string'}, - 'location_type': {'type': 'string'} + 'location_type': {'type': 'string'}, + 'domain_name': {'type': 'string'} } } } diff --git a/ranger_tempest_plugin/services/base_client.py b/ranger_tempest_plugin/services/base_client.py index 977fcf9..e9832fd 100755 --- a/ranger_tempest_plugin/services/base_client.py +++ b/ranger_tempest_plugin/services/base_client.py @@ -103,6 +103,7 @@ class RangerClientBase(rest_client.RestClient): if not CONF.ranger.auth_enabled: return None + # Only used for ConnectionError message region = self.auth_region keystone_ep = self.get_keystone_ep() diff --git a/ranger_tempest_plugin/tests/api/base.py b/ranger_tempest_plugin/tests/api/base.py index c98d082..37e3b51 100755 --- a/ranger_tempest_plugin/tests/api/base.py +++ b/ranger_tempest_plugin/tests/api/base.py @@ -31,10 +31,14 @@ class BaseOrmTest(test.BaseTestCase): build_timeout = 120 build_interval = 10 + @classmethod + def setup_credentials(cls): + cls.set_network_resources() + super(BaseOrmTest, cls).setup_credentials() + @classmethod def setup_clients(cls): - super(BaseOrmTest, cls).setup_clients() - cls.identity_client = cls.os_admin.projects_client + cls.project_client = cls.os_admin.projects_client cls.region_client = cls.os_admin.rms_client # Get regions in ranger deployment @@ -42,6 +46,8 @@ class BaseOrmTest(test.BaseTestCase): region_names = [x['name'] for x in regions_list['regions']] # Check if region and alt region exist. If not, create those regions. + # NOTE: These region creation statements will be removed when + # ranger-agent has been modified to create regions at deployment if (CONF.identity.region not in region_names): cls.region_client.create_region( CONF.identity.region, @@ -57,9 +63,10 @@ class BaseOrmTest(test.BaseTestCase): 'zip': 'purposes'}, 'metadata': {'meta1': ['region']}, 'designType': 'large', + 'domainName': CONF.auth.admin_domain_name, 'endpoints': [{ 'publicURL': - 'https://dashboard-ranger.%s.cci.att.com' + 'https://dashboard-nc.%s.cci.att.com' % CONF.identity.region, 'type': 'dashboard' }, { @@ -88,9 +95,10 @@ class BaseOrmTest(test.BaseTestCase): 'zip': 'purposes'}, 'metadata': {'meta1': ['alt_region']}, 'designType': 'large', + 'domainName': CONF.auth.admin_domain_name, 'endpoints': [{ 'publicURL': - 'https://dashboard-ranger.%s.cci.att.com' + 'https://dashboard-nc.%s.cci.att.com' % CONF.ranger.alt_region, 'type': 'dashboard' }, { @@ -103,6 +111,7 @@ class BaseOrmTest(test.BaseTestCase): % CONF.ranger.alt_region, 'type': 'ord' }]}) + super(BaseOrmTest, cls).setup_clients() @classmethod def skip_checks(cls): diff --git a/ranger_tempest_plugin/tests/api/cms_base.py b/ranger_tempest_plugin/tests/api/cms_base.py index 3d58f25..15c3d19 100755 --- a/ranger_tempest_plugin/tests/api/cms_base.py +++ b/ranger_tempest_plugin/tests/api/cms_base.py @@ -239,7 +239,7 @@ class CmsBaseOrmTest(base.BaseOrmTest): default_users_req.append(user["id"]) expected_users_count = len(region_users_req) + len(default_users_req) actual_users_count = 0 - lcp_body = cls.identity_client.list_tenant_users(cust_id) + lcp_body = cls.project_client.list_tenant_users(cust_id) for user in lcp_body["users"]: users_lcp.append(user["id"]) dcp_body = cls.client.get_customer(cust_id) @@ -313,7 +313,7 @@ class CmsBaseOrmTest(base.BaseOrmTest): @classmethod def _validate_customer_deletion_on_lcp(cls, customer_id): - body = cls.identity_client.list_projects()["projects"] + body = cls.project_client.list_projects()["projects"] customer_ids = [customer["id"] for customer in body if customer["id"] == customer_id] diff --git a/ranger_tempest_plugin/tests/api/fms_base.py b/ranger_tempest_plugin/tests/api/fms_base.py index 555388a..319dc63 100755 --- a/ranger_tempest_plugin/tests/api/fms_base.py +++ b/ranger_tempest_plugin/tests/api/fms_base.py @@ -228,7 +228,7 @@ class FmsBaseOrmTest(base.BaseOrmTest): @classmethod def _get_project_id(cls, project_name): - body = cls.identity_client.list_projects() + body = cls.project_client.list_projects() for project in body["projects"]: if(project["name"] == project_name): return project["id"] diff --git a/ranger_tempest_plugin/tests/api/ims_base.py b/ranger_tempest_plugin/tests/api/ims_base.py index 8b0921f..648971f 100755 --- a/ranger_tempest_plugin/tests/api/ims_base.py +++ b/ranger_tempest_plugin/tests/api/ims_base.py @@ -86,7 +86,7 @@ class ImsBaseOrmTest(base.BaseOrmTest): @classmethod def _get_project_id(cls, project_name): - body = cls.identity_client.list_projects() + body = cls.project_client.list_projects() for project in body["projects"]: if(project["name"] == project_name): return project["id"] diff --git a/ranger_tempest_plugin/tests/api/test_customers_negative.py b/ranger_tempest_plugin/tests/api/test_customers_negative.py index e4cdb8f..e4065a8 100755 --- a/ranger_tempest_plugin/tests/api/test_customers_negative.py +++ b/ranger_tempest_plugin/tests/api/test_customers_negative.py @@ -18,11 +18,6 @@ from ranger_tempest_plugin.tests.api import base class TestTempestCmsNegative(base.BaseOrmTest): - @classmethod - def setup_credentials(cls): - cls.set_network_resources() - super(TestTempestCmsNegative, cls).setup_credentials() - @classmethod def setup_clients(cls): super(TestTempestCmsNegative, cls).setup_clients() diff --git a/ranger_tempest_plugin/tests/api/test_flavors.py b/ranger_tempest_plugin/tests/api/test_flavors.py index 1e552b3..3330cda 100755 --- a/ranger_tempest_plugin/tests/api/test_flavors.py +++ b/ranger_tempest_plugin/tests/api/test_flavors.py @@ -37,11 +37,6 @@ class TestTempestFms(fms_base.FmsBaseOrmTest): region = CONF.identity.region region_alt = CONF.ranger.alt_region - @classmethod - def setup_credentials(cls): - cls.set_network_resources() - super(TestTempestFms, cls).setup_credentials() - @classmethod def setup_clients(cls): super(TestTempestFms, cls).setup_clients() diff --git a/ranger_tempest_plugin/tests/api/test_flavors_negative.py b/ranger_tempest_plugin/tests/api/test_flavors_negative.py index 74dffd0..9135771 100755 --- a/ranger_tempest_plugin/tests/api/test_flavors_negative.py +++ b/ranger_tempest_plugin/tests/api/test_flavors_negative.py @@ -18,11 +18,6 @@ from ranger_tempest_plugin.tests.api import base class TestTempestFmsNegative(base.BaseOrmTest): - @classmethod - def setup_credentials(cls): - cls.set_network_resources() - super(TestTempestFmsNegative, cls).setup_credentials() - @classmethod def setup_clients(cls): super(TestTempestFmsNegative, cls).setup_clients() diff --git a/ranger_tempest_plugin/tests/api/test_images.py b/ranger_tempest_plugin/tests/api/test_images.py index dbf42c5..e8ae5c2 100644 --- a/ranger_tempest_plugin/tests/api/test_images.py +++ b/ranger_tempest_plugin/tests/api/test_images.py @@ -25,11 +25,6 @@ CONF = config.CONF class TestTempestIms(ims_base.ImsBaseOrmTest): - @classmethod - def setup_credentials(cls): - cls.set_network_resources() - super(TestTempestIms, cls).setup_credentials() - @classmethod def setup_clients(cls): super(TestTempestIms, cls).setup_clients() diff --git a/ranger_tempest_plugin/tests/api/test_images_negative.py b/ranger_tempest_plugin/tests/api/test_images_negative.py index 17e98cd..8d65b56 100755 --- a/ranger_tempest_plugin/tests/api/test_images_negative.py +++ b/ranger_tempest_plugin/tests/api/test_images_negative.py @@ -18,11 +18,6 @@ from ranger_tempest_plugin.tests.api import base class TestTempestImsNegative(base.BaseOrmTest): - @classmethod - def setup_credentials(cls): - cls.set_network_resources() - super(TestTempestImsNegative, cls).setup_credentials() - @classmethod def setup_clients(cls): super(TestTempestImsNegative, cls).setup_clients() diff --git a/ranger_tempest_plugin/tests/api/test_region_groups.py b/ranger_tempest_plugin/tests/api/test_region_groups.py index e87dd27..48a53c9 100755 --- a/ranger_tempest_plugin/tests/api/test_region_groups.py +++ b/ranger_tempest_plugin/tests/api/test_region_groups.py @@ -24,16 +24,6 @@ from tempest.lib.common.utils import data_utils class TestTempestRegionGroup(base.BaseOrmTest): - @classmethod - def setup_credentials(cls): - cls.set_network_resources() - super(TestTempestRegionGroup, cls).setup_credentials() - - @classmethod - def setup_clients(cls): - super(TestTempestRegionGroup, cls).setup_clients() - cls.client = cls.os_primary.rms_client - @classmethod def resource_setup(cls): cls.setup_ids = [] diff --git a/ranger_tempest_plugin/tests/api/test_regiongroups_negative.py b/ranger_tempest_plugin/tests/api/test_regiongroups_negative.py index d878f27..d5bd13d 100755 --- a/ranger_tempest_plugin/tests/api/test_regiongroups_negative.py +++ b/ranger_tempest_plugin/tests/api/test_regiongroups_negative.py @@ -18,11 +18,6 @@ from ranger_tempest_plugin.tests.api import base class TestTempestRegGroupNegative(base.BaseOrmTest): - @classmethod - def setup_credentials(cls): - cls.set_network_resources() - super(TestTempestRegGroupNegative, cls).setup_credentials() - @classmethod def setup_clients(cls): super(TestTempestRegGroupNegative, cls).setup_clients() diff --git a/ranger_tempest_plugin/tests/api/test_regions_negative.py b/ranger_tempest_plugin/tests/api/test_regions_negative.py index ea8ef59..de821b2 100755 --- a/ranger_tempest_plugin/tests/api/test_regions_negative.py +++ b/ranger_tempest_plugin/tests/api/test_regions_negative.py @@ -18,11 +18,6 @@ from ranger_tempest_plugin.tests.api import base class TestTempestRegionsNegative(base.BaseOrmTest): - @classmethod - def setup_credentials(cls): - cls.set_network_resources() - super(TestTempestRegionsNegative, cls).setup_credentials() - @classmethod def setup_clients(cls): super(TestTempestRegionsNegative, cls).setup_clients() diff --git a/ranger_tempest_plugin/tests/rbac/test_customers.py b/ranger_tempest_plugin/tests/rbac/test_customers.py index 5f74af4..cc77ab5 100644 --- a/ranger_tempest_plugin/tests/rbac/test_customers.py +++ b/ranger_tempest_plugin/tests/rbac/test_customers.py @@ -33,6 +33,14 @@ class TestCustomer(rbac_utils.RbacUtilsMixin, cms_base.CmsBaseOrmTest): super(TestCustomer, cls).setup_clients() cls.client = cls.os_primary.cms_rbac_client + @classmethod + def skip_checks(cls): + super(TestCustomer, cls).skip_checks() + if not CONF.ranger.test_rbac: + skip_msg = ("%s skipped as this is not an rbac test run" + % cls.__name__) + raise cls.skipException(skip_msg) + @rbac_rule_validation.action(service="ranger", rules=['customers:get_one'], expected_error_codes=[403]) diff --git a/ranger_tempest_plugin/tests/rbac/test_regions.py b/ranger_tempest_plugin/tests/rbac/test_regions.py index 47ba820..70f5992 100644 --- a/ranger_tempest_plugin/tests/rbac/test_regions.py +++ b/ranger_tempest_plugin/tests/rbac/test_regions.py @@ -15,12 +15,17 @@ from patrole_tempest_plugin import rbac_rule_validation from patrole_tempest_plugin import rbac_utils -from tempest.lib import decorators -from tempest.lib.common.utils import data_utils - from ranger_tempest_plugin import data_utils as orm_data_utils from ranger_tempest_plugin.tests.api import rms_base +from tempest import config +from tempest.lib import decorators + +from tempest.lib.common.utils import data_utils + + +CONF = config.CONF + class TestRegion(rbac_utils.RbacUtilsMixin, rms_base.RmsBaseOrmTest): @@ -29,6 +34,14 @@ class TestRegion(rbac_utils.RbacUtilsMixin, rms_base.RmsBaseOrmTest): super(TestRegion, cls).setup_clients() cls.client = cls.os_primary.rms_rbac_client + @classmethod + def skip_checks(cls): + super(TestRegion, cls).skip_checks() + if not CONF.ranger.test_rbac: + skip_msg = ("%s skipped as this is not an rbac test run" + % cls.__name__) + raise cls.skipException(skip_msg) + @rbac_rule_validation.action(service='ranger', rules=['region:get_all'], expected_error_codes=[403]) @@ -62,10 +75,10 @@ class TestRegion(rbac_utils.RbacUtilsMixin, rms_base.RmsBaseOrmTest): expected_error_codes=[403]) @decorators.idempotent_id('cbb32c8f-f183-42c4-a9d9-61e93d066c5f') def test_update_region(self): - id = self.setup_ids[-1] - region = orm_data_utils.rand_region(id) + region_id = self.setup_ids[-1] + region = orm_data_utils.rand_region(region_id) with self.override_role(): - self.client.update_region(id, **region) + self.client.update_region(region_id, **region) @rbac_rule_validation.action(service='ranger', rules=['region:delete'],