Merge "Extra hypervisor rbac tests"
diff --git a/patrole_tempest_plugin/plugin.py b/patrole_tempest_plugin/plugin.py
index 3abf4aa..cfe5c0a 100644
--- a/patrole_tempest_plugin/plugin.py
+++ b/patrole_tempest_plugin/plugin.py
@@ -25,7 +25,7 @@
def load_tests(self):
base_path = os.path.split(os.path.dirname(
os.path.abspath(__file__)))[0]
- test_dir = "patrole_tempest_plugin/tests"
+ test_dir = "patrole_tempest_plugin/tests/api"
full_test_dir = os.path.join(base_path, test_dir)
return full_test_dir, base_path
diff --git a/patrole_tempest_plugin/rbac_policy_parser.py b/patrole_tempest_plugin/rbac_policy_parser.py
index d4e989b..1047d37 100644
--- a/patrole_tempest_plugin/rbac_policy_parser.py
+++ b/patrole_tempest_plugin/rbac_policy_parser.py
@@ -81,7 +81,7 @@
path = getattr(CONF.rbac, '%s_policy_file' % str(service), None)
if not path:
LOG.info("No config option found for %s,"
- " using default path" % str(service))
+ " using default path", str(service))
path = os.path.join('/etc', service, 'policy.json')
self.path = path
self.rules = policy.Rules.load(self._get_policy_data(service),
diff --git a/patrole_tempest_plugin/rbac_rule_validation.py b/patrole_tempest_plugin/rbac_rule_validation.py
index d77b2d6..60a0f10 100644
--- a/patrole_tempest_plugin/rbac_rule_validation.py
+++ b/patrole_tempest_plugin/rbac_rule_validation.py
@@ -104,7 +104,7 @@
(role, rule))
LOG.error(msg)
raise exceptions.Forbidden(
- "%s exception was: %s" % (msg, e))
+ "%s Exception was: %s" % (msg, e))
except Exception as e:
exc_info = sys.exc_info()
error_details = exc_info[1].__str__()
@@ -115,7 +115,7 @@
six.reraise(exc_info[0], exc_info[0](msg), exc_info[2])
else:
if not allowed:
- LOG.error("Role %s was allowed to perform %s" %
+ LOG.error("Role %s was allowed to perform %s",
(role, rule))
raise rbac_exceptions.RbacOverPermission(
"OverPermission: Role %s was allowed to perform %s" %
diff --git a/patrole_tempest_plugin/tests/api/compute/rbac_base.py b/patrole_tempest_plugin/tests/api/compute/rbac_base.py
index bc02dbf..457d08d 100644
--- a/patrole_tempest_plugin/tests/api/compute/rbac_base.py
+++ b/patrole_tempest_plugin/tests/api/compute/rbac_base.py
@@ -58,7 +58,7 @@
@classmethod
def _create_flavor(cls, **kwargs):
flavor_kwargs = {
- "name": data_utils.rand_name('flavor'),
+ "name": data_utils.rand_name(cls.__name__ + '-flavor'),
"ram": data_utils.rand_int_id(1, 10),
"vcpus": data_utils.rand_int_id(1, 10),
"disk": data_utils.rand_int_id(1, 10),
diff --git a/patrole_tempest_plugin/tests/api/compute/test_aggregates_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_aggregates_rbac.py
index db504c0..eec4030 100644
--- a/patrole_tempest_plugin/tests/api/compute/test_aggregates_rbac.py
+++ b/patrole_tempest_plugin/tests/api/compute/test_aggregates_rbac.py
@@ -37,7 +37,7 @@
cls.hosts_client = cls.os_primary.hosts_client
def _create_aggregate(self):
- agg_name = data_utils.rand_name('aggregate')
+ agg_name = data_utils.rand_name(self.__class__.__name__ + '-aggregate')
aggregate = self.aggregates_client.create_aggregate(name=agg_name)
aggregate_id = aggregate['aggregate']['id']
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
@@ -82,7 +82,7 @@
def test_update_aggregate_rbac(self):
aggregate_id = self._create_aggregate()
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
- new_name = data_utils.rand_name('aggregate')
+ new_name = data_utils.rand_name(self.__class__.__name__ + '-aggregate')
self.aggregates_client.update_aggregate(aggregate_id, name=new_name)
@rbac_rule_validation.action(
@@ -115,8 +115,8 @@
@decorators.idempotent_id('ed6f3849-065c-4ae9-a81e-6ad7ed0d3d9d')
def test_set_metadata_on_aggregate_rbac(self):
aggregate_id = self._create_aggregate()
- rand_key = data_utils.rand_name('key')
- rand_val = data_utils.rand_name('val')
+ rand_key = data_utils.rand_name(self.__class__.__name__ + '-key')
+ rand_val = data_utils.rand_name(self.__class__.__name__ + '-val')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.aggregates_client.set_metadata(
aggregate_id,
diff --git a/patrole_tempest_plugin/tests/api/compute/test_flavor_extra_specs_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_flavor_extra_specs_rbac.py
index 0ee8d9a..10e27a8 100644
--- a/patrole_tempest_plugin/tests/api/compute/test_flavor_extra_specs_rbac.py
+++ b/patrole_tempest_plugin/tests/api/compute/test_flavor_extra_specs_rbac.py
@@ -48,8 +48,8 @@
super(FlavorExtraSpecsRbacTest, cls).resource_cleanup()
def _set_flavor_extra_spec(self):
- rand_key = data_utils.rand_name('key')
- rand_val = data_utils.rand_name('val')
+ rand_key = data_utils.rand_name(self.__class__.__name__ + '-key')
+ rand_val = data_utils.rand_name(self.__class__.__name__ + '-val')
specs = {rand_key: rand_val}
self.client.set_flavor_extra_spec(self.flavor['id'],
**specs)['extra_specs']
@@ -82,7 +82,7 @@
def test_update_flavor_extra_spec(self):
key = self._set_flavor_extra_spec()
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
- update_val = data_utils.rand_name('val')
+ update_val = data_utils.rand_name(self.__class__.__name__ + '-val')
self.client.update_flavor_extra_spec(self.flavor['id'], key,
**{key: update_val})[key]
diff --git a/patrole_tempest_plugin/tests/api/compute/test_images_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_images_rbac.py
index b848509..d546911 100644
--- a/patrole_tempest_plugin/tests/api/compute/test_images_rbac.py
+++ b/patrole_tempest_plugin/tests/api/compute/test_images_rbac.py
@@ -54,7 +54,7 @@
def resource_setup(cls):
super(ImagesV235RbacTest, cls).resource_setup()
cls.image = cls.glance_image_client.create_image(
- name=data_utils.rand_name('image'))
+ name=data_utils.rand_name(cls.__name__ + '-image'))
@classmethod
def resource_cleanup(cls):
@@ -111,7 +111,7 @@
rule="delete_image")
def test_delete_image(self):
image = self.glance_image_client.create_image(
- name=data_utils.rand_name('image'))
+ name=data_utils.rand_name(self.__class__.__name__ + '-image'))
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.glance_image_client.delete_image, image['id'])
diff --git a/patrole_tempest_plugin/tests/api/compute/test_keypairs_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_keypairs_rbac.py
index f7b2ace..a93d807 100644
--- a/patrole_tempest_plugin/tests/api/compute/test_keypairs_rbac.py
+++ b/patrole_tempest_plugin/tests/api/compute/test_keypairs_rbac.py
@@ -29,7 +29,7 @@
cls.client = cls.keypairs_client
def _create_keypair(self):
- key_name = data_utils.rand_name('key')
+ key_name = data_utils.rand_name(self.__class__.__name__ + '-key')
keypair = self.client.create_keypair(name=key_name)
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.client.delete_keypair,
diff --git a/patrole_tempest_plugin/tests/api/compute/test_quota_sets_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_quota_sets_rbac.py
index f6706a7..8e90880 100644
--- a/patrole_tempest_plugin/tests/api/compute/test_quota_sets_rbac.py
+++ b/patrole_tempest_plugin/tests/api/compute/test_quota_sets_rbac.py
@@ -88,7 +88,8 @@
service="nova",
rule="os_compute_api:os-quota-sets:delete")
def test_delete_quota_set(self):
- project_name = data_utils.rand_name('project')
+ project_name = data_utils.rand_name(
+ self.__class__.__name__ + '-project')
project = self.projects_client.create_project(name=project_name)
project_id = project['project']['id']
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
diff --git a/patrole_tempest_plugin/tests/api/compute/test_server_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_server_rbac.py
index b71887c..7d715ca 100644
--- a/patrole_tempest_plugin/tests/api/compute/test_server_rbac.py
+++ b/patrole_tempest_plugin/tests/api/compute/test_server_rbac.py
@@ -174,7 +174,7 @@
@decorators.idempotent_id('077b17cb-5621-43b9-8adf-5725f0d7a863')
def test_update_server(self):
server = self.create_test_server(wait_until='ACTIVE')
- new_name = data_utils.rand_name('server')
+ new_name = data_utils.rand_name(self.__class__.__name__ + '-server')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
try:
self.client.update_server(server['id'], name=new_name)
diff --git a/patrole_tempest_plugin/tests/api/compute/test_server_tags_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_server_tags_rbac.py
index 4de63ce..19aa36a 100644
--- a/patrole_tempest_plugin/tests/api/compute/test_server_tags_rbac.py
+++ b/patrole_tempest_plugin/tests/api/compute/test_server_tags_rbac.py
@@ -44,7 +44,7 @@
cls.server = cls.create_test_server(wait_until='ACTIVE')
def _add_tag_to_server(self):
- tag_name = data_utils.rand_name('tag')
+ tag_name = data_utils.rand_name(self.__class__.__name__ + '-tag')
self.client.update_tag(self.server['id'], tag_name)
self.addCleanup(self.client.delete_all_tags, self.server['id'])
return tag_name
@@ -89,7 +89,7 @@
rule="os_compute_api:os-server-tags:update_all")
def test_update_all_tags(self):
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
- new_tag_name = data_utils.rand_name('tag')
+ new_tag_name = data_utils.rand_name(self.__class__.__name__ + '-tag')
self.client.update_all_tags(self.server['id'], [new_tag_name])['tags']
@decorators.idempotent_id('89d51936-e333-42f9-a045-132a4865ba1a')
diff --git a/patrole_tempest_plugin/tests/api/identity/rbac_base.py b/patrole_tempest_plugin/tests/api/identity/rbac_base.py
index 6504844..8fef487 100644
--- a/patrole_tempest_plugin/tests/api/identity/rbac_base.py
+++ b/patrole_tempest_plugin/tests/api/identity/rbac_base.py
@@ -78,7 +78,8 @@
"""Creates a service and an endpoint for test."""
interface = 'public'
url = data_utils.rand_url()
- region_name = data_utils.rand_name('region')
+ region_name = data_utils.rand_name(
+ cls.__name__ + '-region')
# Endpoint creation requires a service
if service is None:
service = cls.setup_test_service()
@@ -104,7 +105,7 @@
@classmethod
def setup_test_role(cls):
"""Set up a test role."""
- name = data_utils.rand_name('test_role')
+ name = data_utils.rand_name(cls.__name__ + '-test_role')
role = cls.roles_client.create_role(name=name)['role']
cls.roles.append(role)
@@ -113,9 +114,9 @@
@classmethod
def setup_test_service(cls):
"""Setup a test service."""
- name = data_utils.rand_name('service')
+ name = data_utils.rand_name(cls.__name__ + '-service')
serv_type = data_utils.rand_name('type')
- desc = data_utils.rand_name('description')
+ desc = data_utils.rand_name(cls.__name__ + '-description')
service = cls.services_client.create_service(
name=name,
@@ -138,7 +139,7 @@
@classmethod
def setup_test_user(cls, password=None, **kwargs):
"""Set up a test user."""
- username = data_utils.rand_name('test_user')
+ username = data_utils.rand_name(cls.__name__ + '-test_user')
email = username + '@testmail.tm'
user = cls.users_client.create_user(
@@ -196,10 +197,11 @@
@classmethod
def setup_test_tenant(cls):
"""Set up a test tenant."""
- name = data_utils.rand_name('test_tenant')
+ name = data_utils.rand_name(cls.__name__ + '-test_tenant')
tenant = cls.tenants_client.create_tenant(
name=name,
- description=data_utils.rand_name('desc'))['tenant']
+ description=data_utils.rand_name(
+ cls.__name__ + '-desc'))['tenant']
cls.tenants.append(tenant)
return tenant
@@ -294,8 +296,9 @@
def setup_test_domain(cls):
"""Set up a test domain."""
domain = cls.domains_client.create_domain(
- name=data_utils.rand_name('test_domain'),
- description=data_utils.rand_name('desc'))['domain']
+ name=data_utils.rand_name(cls.__name__ + '-test_domain'),
+ description=data_utils.rand_name(
+ cls.__name__ + '-desc'))['domain']
cls.domains.append(domain)
return domain
@@ -303,7 +306,7 @@
@classmethod
def setup_test_group(cls):
"""Creates a group for test."""
- name = data_utils.rand_name('test_group')
+ name = data_utils.rand_name(cls.__name__ + '-test_group')
group = cls.groups_client.create_group(name=name)['group']
cls.groups.append(group)
@@ -312,8 +315,9 @@
@classmethod
def setup_test_policy(cls):
"""Creates a policy for test."""
- blob = data_utils.rand_name('test_blob')
- policy_type = data_utils.rand_name('policy_type')
+ blob = data_utils.rand_name(cls.__name__ + '-test_blob')
+ policy_type = data_utils.rand_name(
+ cls.__name__ + '-policy_type')
policy = cls.policies_client.create_policy(
blob=blob,
@@ -327,8 +331,10 @@
def setup_test_project(cls):
"""Set up a test project."""
project = cls.projects_client.create_project(
- name=data_utils.rand_name('test_project'),
- description=data_utils.rand_name('desc'))['project']
+ name=data_utils.rand_name(
+ cls.__name__ + '-testproject'),
+ description=data_utils.rand_name(
+ cls.__name__ + '-desc'))['project']
cls.projects.append(project)
return project
@@ -336,7 +342,8 @@
@classmethod
def setup_test_region(cls):
"""Creates a region for test."""
- description = data_utils.rand_name('test_region_desc')
+ description = data_utils.rand_name(
+ cls.__name__ + '-test_region_desc')
region = cls.regions_client.create_region(
description=description)['region']
diff --git a/patrole_tempest_plugin/tests/api/identity/v3/test_domains_rbac.py b/patrole_tempest_plugin/tests/api/identity/v3/test_domains_rbac.py
index b45c091..a8cd022 100644
--- a/patrole_tempest_plugin/tests/api/identity/v3/test_domains_rbac.py
+++ b/patrole_tempest_plugin/tests/api/identity/v3/test_domains_rbac.py
@@ -34,7 +34,8 @@
@decorators.idempotent_id('6bdaecd4-0843-4ed6-ab64-3a57ab0cd111')
def test_update_domain(self):
domain = self.setup_test_domain()
- new_domain_name = data_utils.rand_name('test_update_domain')
+ new_domain_name = data_utils.rand_name(
+ self.__class__.__name__ + '-test_update_domain')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.domains_client.update_domain(domain['id'],
domain=domain,
diff --git a/patrole_tempest_plugin/tests/api/identity/v3/test_groups_rbac.py b/patrole_tempest_plugin/tests/api/identity/v3/test_groups_rbac.py
index 74402d5..0fc29b7 100644
--- a/patrole_tempest_plugin/tests/api/identity/v3/test_groups_rbac.py
+++ b/patrole_tempest_plugin/tests/api/identity/v3/test_groups_rbac.py
@@ -41,7 +41,8 @@
@decorators.idempotent_id('790fb7be-a657-4a64-9b83-c43425cf180b')
def test_update_group(self):
group = self.setup_test_group()
- new_group_name = data_utils.rand_name('group')
+ new_group_name = data_utils.rand_name(
+ self.__class__.__name__ + '-group')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.groups_client.update_group(group['id'],
diff --git a/patrole_tempest_plugin/tests/api/identity/v3/test_oauth_consumers_rbac.py b/patrole_tempest_plugin/tests/api/identity/v3/test_oauth_consumers_rbac.py
index fab5a6e..5e21338 100644
--- a/patrole_tempest_plugin/tests/api/identity/v3/test_oauth_consumers_rbac.py
+++ b/patrole_tempest_plugin/tests/api/identity/v3/test_oauth_consumers_rbac.py
@@ -24,7 +24,8 @@
class IdentityConsumersV3RbacTest(rbac_base.BaseIdentityV3RbacTest):
def _create_consumer(self):
- description = data_utils.rand_name('test_create_consumer')
+ description = data_utils.rand_name(
+ self.__class__.__name__ + '-test_consumer')
consumer = self.consumers_client.create_consumer(
description)['consumer']
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
@@ -53,7 +54,8 @@
@decorators.idempotent_id('0f148510-63bf-11e6-4522-080044d0d972')
def test_update_consumer(self):
consumer = self._create_consumer()
- new_description = data_utils.rand_name('test_update_consumer')
+ new_description = data_utils.rand_name(
+ self.__class__.__name__ + '-test_consumer')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.consumers_client.update_consumer(consumer['id'],
diff --git a/patrole_tempest_plugin/tests/api/identity/v3/test_policies_rbac.py b/patrole_tempest_plugin/tests/api/identity/v3/test_policies_rbac.py
index da587d9..3e03ac0 100644
--- a/patrole_tempest_plugin/tests/api/identity/v3/test_policies_rbac.py
+++ b/patrole_tempest_plugin/tests/api/identity/v3/test_policies_rbac.py
@@ -34,7 +34,8 @@
@decorators.idempotent_id('9cfed3c6-0b27-4d15-be67-e06e0cfb01b9')
def test_update_policy(self):
policy = self.setup_test_policy()
- updated_policy_type = data_utils.rand_name('policy_type')
+ updated_policy_type = data_utils.rand_name(
+ self.__class__.__name__ + '-policy_type')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.policies_client.update_policy(policy['id'],
diff --git a/patrole_tempest_plugin/tests/api/identity/v3/test_projects_rbac.py b/patrole_tempest_plugin/tests/api/identity/v3/test_projects_rbac.py
index 0c65602..51086ae 100644
--- a/patrole_tempest_plugin/tests/api/identity/v3/test_projects_rbac.py
+++ b/patrole_tempest_plugin/tests/api/identity/v3/test_projects_rbac.py
@@ -34,7 +34,8 @@
@decorators.idempotent_id('0f148510-63bf-11e6-1564-080044d0d905')
def test_update_project(self):
project = self.setup_test_project()
- new_desc = data_utils.rand_name('description')
+ new_desc = data_utils.rand_name(
+ self.__class__.__name__ + '-description')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.projects_client.update_project(project['id'],
diff --git a/patrole_tempest_plugin/tests/api/identity/v3/test_regions_rbac.py b/patrole_tempest_plugin/tests/api/identity/v3/test_regions_rbac.py
index 541e8af..55a2f77 100644
--- a/patrole_tempest_plugin/tests/api/identity/v3/test_regions_rbac.py
+++ b/patrole_tempest_plugin/tests/api/identity/v3/test_regions_rbac.py
@@ -34,7 +34,8 @@
@decorators.idempotent_id('6bdaecd4-0843-4ed6-ab64-3a57ab0cd120')
def test_update_region(self):
region = self.setup_test_region()
- new_description = data_utils.rand_name('test_update_region')
+ new_description = data_utils.rand_name(
+ self.__class__.__name__ + '-test_update_region')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.regions_client.update_region(region['id'],
diff --git a/patrole_tempest_plugin/tests/api/identity/v3/test_roles_rbac.py b/patrole_tempest_plugin/tests/api/identity/v3/test_roles_rbac.py
index 0458e16..22b03f5 100644
--- a/patrole_tempest_plugin/tests/api/identity/v3/test_roles_rbac.py
+++ b/patrole_tempest_plugin/tests/api/identity/v3/test_roles_rbac.py
@@ -44,7 +44,8 @@
rule="identity:update_role")
@decorators.idempotent_id('0f148510-63bf-11e6-1395-080044d0d905')
def test_update_role(self):
- new_role_name = data_utils.rand_name('test_update_role')
+ new_role_name = data_utils.rand_name(
+ self.__class__.__name__ + '-test_update_role')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.roles_client.update_role(self.role['id'],
diff --git a/patrole_tempest_plugin/tests/api/identity/v3/test_services_rbac.py b/patrole_tempest_plugin/tests/api/identity/v3/test_services_rbac.py
index 2f0d1ac..44ce1a1 100644
--- a/patrole_tempest_plugin/tests/api/identity/v3/test_services_rbac.py
+++ b/patrole_tempest_plugin/tests/api/identity/v3/test_services_rbac.py
@@ -34,7 +34,7 @@
@decorators.idempotent_id('b39447d1-2cf6-40e5-a899-46f287f2ecf0')
def test_update_service(self):
service = self.setup_test_service()
- new_name = data_utils.rand_name('service')
+ new_name = data_utils.rand_name(self.__class__.__name__ + '-service')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.services_client.update_service(service['id'],
diff --git a/patrole_tempest_plugin/tests/api/identity/v3/test_users_rbac.py b/patrole_tempest_plugin/tests/api/identity/v3/test_users_rbac.py
index d3b3e4c..723455e 100644
--- a/patrole_tempest_plugin/tests/api/identity/v3/test_users_rbac.py
+++ b/patrole_tempest_plugin/tests/api/identity/v3/test_users_rbac.py
@@ -39,7 +39,8 @@
@decorators.idempotent_id('0f148510-63bf-11e6-4522-080044d0d905')
def test_update_user(self):
user = self.setup_test_user()
- new_email = data_utils.rand_name('user_email')
+ new_email = data_utils.rand_name(
+ self.__class__.__name__ + '-user_email')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.users_client.update_user(user['id'],
diff --git a/patrole_tempest_plugin/tests/api/image/v1/test_images_rbac.py b/patrole_tempest_plugin/tests/api/image/v1/test_images_rbac.py
index ae4e4d2..7010baa 100644
--- a/patrole_tempest_plugin/tests/api/image/v1/test_images_rbac.py
+++ b/patrole_tempest_plugin/tests/api/image/v1/test_images_rbac.py
@@ -35,7 +35,7 @@
RBAC test for the glance add_image policy.
"""
properties = {'prop1': 'val1'}
- image_name = data_utils.rand_name('image')
+ image_name = data_utils.rand_name(self.__class__.__name__ + '-Image')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.create_image(name=image_name,
container_format='bare',
@@ -50,7 +50,7 @@
RBAC test for the glance delete_image policy.
"""
- image_name = data_utils.rand_name('image')
+ image_name = data_utils.rand_name(self.__class__.__name__ + '-Image')
properties = {'prop1': 'val1'}
body = self.create_image(name=image_name,
container_format='bare',
@@ -68,7 +68,7 @@
RBAC test for the glance download_image policy.
"""
- image_name = data_utils.rand_name('image')
+ image_name = data_utils.rand_name(self.__class__.__name__ + '-Image')
properties = {'prop1': 'val1'}
body = self.create_image(name=image_name,
container_format='bare',
@@ -90,7 +90,7 @@
RBAC test for the glance get_image policy.
"""
- image_name = data_utils.rand_name('image')
+ image_name = data_utils.rand_name(self.__class__.__name__ + '-Image')
properties = {'prop1': 'val1'}
body = self.create_image(name=image_name,
container_format='bare',
@@ -122,7 +122,7 @@
RBAC test for the glance modify_image policy.
"""
- image_name = data_utils.rand_name('image')
+ image_name = data_utils.rand_name(self.__class__.__name__ + '-Image')
properties = {'prop1': 'val1'}
body = self.create_image(name=image_name,
container_format='bare',
@@ -141,7 +141,7 @@
RBAC test for the glance publicize_image policy.
"""
- image_name = data_utils.rand_name('image')
+ image_name = data_utils.rand_name(self.__class__.__name__ + '-Image')
properties = {'prop1': 'val1'}
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.create_image(name=image_name,
diff --git a/patrole_tempest_plugin/tests/api/image/v2/test_image_namespace_objects_rbac.py b/patrole_tempest_plugin/tests/api/image/v2/test_image_namespace_objects_rbac.py
index 1c937b0..74c64e1 100644
--- a/patrole_tempest_plugin/tests/api/image/v2/test_image_namespace_objects_rbac.py
+++ b/patrole_tempest_plugin/tests/api/image/v2/test_image_namespace_objects_rbac.py
@@ -35,7 +35,8 @@
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
# create a md object, it will be cleaned automatically after
# cleanup of namespace
- object_name = data_utils.rand_name('test-object')
+ object_name = data_utils.rand_name(
+ self.__class__.__name__ + '-test-object')
self.namespace_objects_client.create_namespace_object(
namespace['namespace'],
name=object_name)
@@ -66,7 +67,8 @@
RBAC test for the glance modify_metadef_object policy
"""
namespace = self.create_namespace()
- object_name = data_utils.rand_name('test-object')
+ object_name = data_utils.rand_name(
+ self.__class__.__name__ + '-test-object')
self.namespace_objects_client.create_namespace_object(
namespace['namespace'],
name=object_name)
@@ -89,7 +91,8 @@
RBAC test for the glance get_metadef_object policy
"""
namespace = self.create_namespace()
- object_name = data_utils.rand_name('test-object')
+ object_name = data_utils.rand_name(
+ self.__class__.__name__ + '-test-object')
self.namespace_objects_client.create_namespace_object(
namespace['namespace'],
name=object_name)
diff --git a/patrole_tempest_plugin/tests/api/image/v2/test_image_namespace_property_rbac.py b/patrole_tempest_plugin/tests/api/image/v2/test_image_namespace_property_rbac.py
index 0d194b7..93c50c4 100644
--- a/patrole_tempest_plugin/tests/api/image/v2/test_image_namespace_property_rbac.py
+++ b/patrole_tempest_plugin/tests/api/image/v2/test_image_namespace_property_rbac.py
@@ -38,7 +38,8 @@
"""
namespace = self.create_namespace()
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
- property_name = data_utils.rand_name('test-ns-property')
+ property_name = data_utils.rand_name(
+ self.__class__.__name__ + '-test-ns-property')
self.namespace_properties_client.create_namespace_property(
namespace=namespace['namespace'], type="string",
title=property_name, name=self.resource_name)
@@ -65,7 +66,8 @@
RBAC test for the glance get_metadef_property policy
"""
namespace = self.create_namespace()
- property_name = data_utils.rand_name('test-ns-property')
+ property_name = data_utils.rand_name(
+ self.__class__.__name__ + '-test-ns-property')
self.namespace_properties_client.create_namespace_property(
namespace=namespace['namespace'], type="string",
title=property_name, name=self.resource_name)
@@ -83,7 +85,8 @@
RBAC test for the glance modify_metadef_property policy
"""
namespace = self.create_namespace()
- property_name = data_utils.rand_name('test-ns-property')
+ property_name = data_utils.rand_name(
+ self.__class__.__name__ + '-test-ns-property')
self.namespace_properties_client.create_namespace_property(
namespace=namespace['namespace'], type="string",
title=property_name, name=self.resource_name)
diff --git a/patrole_tempest_plugin/tests/api/image/v2/test_image_namespace_rbac.py b/patrole_tempest_plugin/tests/api/image/v2/test_image_namespace_rbac.py
index fb4a599..c6bd60e 100644
--- a/patrole_tempest_plugin/tests/api/image/v2/test_image_namespace_rbac.py
+++ b/patrole_tempest_plugin/tests/api/image/v2/test_image_namespace_rbac.py
@@ -31,7 +31,8 @@
RBAC test for the glance add_metadef_namespace policy
"""
- namespace_name = data_utils.rand_name('test-ns')
+ namespace_name = data_utils.rand_name(
+ self.__class__.__name__ + '-test-ns')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.namespaces_client.create_namespace(
namespace=namespace_name,
@@ -60,7 +61,8 @@
RBAC test for the glance modify_metadef_namespace policy
"""
- namespace_name = data_utils.rand_name('test-ns')
+ namespace_name = data_utils.rand_name(
+ self.__class__.__name__ + '-test-ns')
body = self.namespaces_client.create_namespace(
namespace=namespace_name,
protected=False)
diff --git a/patrole_tempest_plugin/tests/api/image/v2/test_image_namespace_tags_rbac.py b/patrole_tempest_plugin/tests/api/image/v2/test_image_namespace_tags_rbac.py
index cfd544c..7750a19 100644
--- a/patrole_tempest_plugin/tests/api/image/v2/test_image_namespace_tags_rbac.py
+++ b/patrole_tempest_plugin/tests/api/image/v2/test_image_namespace_tags_rbac.py
@@ -42,7 +42,8 @@
def resource_setup(cls):
super(NamespaceTagsRbacTest, cls).resource_setup()
cls.namespace = cls.namespaces_client.create_namespace(
- namespace=data_utils.rand_name('namespace'))['namespace']
+ namespace=data_utils.rand_name(
+ cls.__name__ + '-namespace'))['namespace']
@classmethod
def resource_cleanup(cls):
@@ -54,7 +55,7 @@
namespace_tag_names = []
for i in range(tag_count):
- tag_name = data_utils.rand_name('tag')
+ tag_name = data_utils.rand_name(self.__class__.__name__ + '-tag')
namespace_tag_names.append({'name': tag_name})
if multiple:
@@ -91,7 +92,8 @@
rule="modify_metadef_tag")
def test_update_namespace_tag(self):
tag_name = self._create_namespace_tag()
- updated_tag_name = data_utils.rand_name('tag')
+ updated_tag_name = data_utils.rand_name(
+ self.__class__.__name__ + '-tag')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.client.update_namespace_tag(self.namespace, tag_name,
diff --git a/patrole_tempest_plugin/tests/api/image/v2/test_image_resource_types_rbac.py b/patrole_tempest_plugin/tests/api/image/v2/test_image_resource_types_rbac.py
index 552a137..6727cc8 100644
--- a/patrole_tempest_plugin/tests/api/image/v2/test_image_resource_types_rbac.py
+++ b/patrole_tempest_plugin/tests/api/image/v2/test_image_resource_types_rbac.py
@@ -26,7 +26,8 @@
@classmethod
def resource_setup(cls):
super(ImageResourceTypesRbacTest, cls).resource_setup()
- cls.namespace_name = data_utils.rand_name('test-ns')
+ cls.namespace_name = data_utils.rand_name(
+ cls.__name__ + '-test-ns')
cls.namespaces_client.create_namespace(
namespace=cls.namespace_name,
protected=False)
diff --git a/patrole_tempest_plugin/tests/api/image/v2/test_images_rbac.py b/patrole_tempest_plugin/tests/api/image/v2/test_images_rbac.py
index 880f892..5b7c823 100644
--- a/patrole_tempest_plugin/tests/api/image/v2/test_images_rbac.py
+++ b/patrole_tempest_plugin/tests/api/image/v2/test_images_rbac.py
@@ -30,7 +30,7 @@
cls.client = cls.os_primary.image_client_v2
def _create_image(self, **kwargs):
- image_name = data_utils.rand_name('image')
+ image_name = data_utils.rand_name(self.__class__.__name__ + '-Image')
image = self.create_image(name=image_name,
container_format='bare',
disk_format='raw',
@@ -135,7 +135,8 @@
image = self._create_image()
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
- updated_image_name = data_utils.rand_name('image')
+ updated_image_name = data_utils.rand_name(
+ self.__class__.__name__ + '-image')
self.client.update_image(image['id'], [
dict(replace='/name', value=updated_image_name)])
@@ -151,7 +152,9 @@
image = self._create_image()
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
- self.client.add_image_tag(image['id'], data_utils.rand_name('tag'))
+ self.client.add_image_tag(
+ image['id'],
+ data_utils.rand_name(self.__class__.__name__ + '-tag'))
@decorators.idempotent_id('c4a0bf9c-b78b-48c6-a31f-72c95f943c6e')
@rbac_rule_validation.action(service="glance",
@@ -163,7 +166,7 @@
RBAC test for the glance delete_image_tag endpoint
"""
image = self._create_image()
- tag_name = data_utils.rand_name('tag')
+ tag_name = data_utils.rand_name(self.__class__.__name__ + '-tag')
self.client.add_image_tag(image['id'], tag_name)
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
diff --git a/patrole_tempest_plugin/tests/api/network/test_networks_rbac.py b/patrole_tempest_plugin/tests/api/network/test_networks_rbac.py
index 133ea74..8208fde 100644
--- a/patrole_tempest_plugin/tests/api/network/test_networks_rbac.py
+++ b/patrole_tempest_plugin/tests/api/network/test_networks_rbac.py
@@ -33,7 +33,8 @@
def resource_setup(cls):
super(RbacNetworksTest, cls).resource_setup()
- network_name = data_utils.rand_name('rbac-admin-network-')
+ network_name = data_utils.rand_name(
+ cls.__name__ + '-rbac-admin-network-')
post_body = {'name': network_name}
body = cls.networks_client.create_network(**post_body)
@@ -65,7 +66,8 @@
provider_physical_network=None,
provider_segmentation_id=None):
- network_name = data_utils.rand_name('test-network-')
+ network_name = data_utils.rand_name(
+ self.__class__.__name__ + '-test-network-')
post_body = {'name': network_name}
if shared is not None:
diff --git a/patrole_tempest_plugin/tests/api/network/test_routers_rbac.py b/patrole_tempest_plugin/tests/api/network/test_routers_rbac.py
index 5ea1180..1be46ab 100644
--- a/patrole_tempest_plugin/tests/api/network/test_routers_rbac.py
+++ b/patrole_tempest_plugin/tests/api/network/test_routers_rbac.py
@@ -74,7 +74,7 @@
RBAC test for the neutron
create_router:external_gateway_info:enable_snat policy
"""
- name = data_utils.rand_name('snat-router')
+ name = data_utils.rand_name(self.__class__.__name__ + '-snat-router')
external_gateway_info = {'network_id': self.network['id'],
'enable_snat': True}
@@ -94,7 +94,7 @@
RBAC test for the neutron
create_router:external_gateway_info:external_fixed_ips policy
"""
- name = data_utils.rand_name('snat-router')
+ name = data_utils.rand_name(self.__class__.__name__ + '-snat-router')
# Pick an unused IP address.
ip_list = net_utils.get_unused_ip_addresses(self.ports_client,
@@ -134,7 +134,8 @@
RBAC test for the neutron update_router policy
"""
- new_name = data_utils.rand_name('new-router-name')
+ new_name = data_utils.rand_name(self.__class__.__name__ +
+ '-new-router-name')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.routers_client.update_router(self.router['id'],
name=new_name)
diff --git a/patrole_tempest_plugin/tests/api/network/test_security_groups_rbac.py b/patrole_tempest_plugin/tests/api/network/test_security_groups_rbac.py
index e04600e..20f4bea 100644
--- a/patrole_tempest_plugin/tests/api/network/test_security_groups_rbac.py
+++ b/patrole_tempest_plugin/tests/api/network/test_security_groups_rbac.py
@@ -30,7 +30,7 @@
@classmethod
def resource_setup(cls):
super(SecGroupRbacTest, cls).resource_setup()
- secgroup_name = data_utils.rand_name('secgroup')
+ secgroup_name = data_utils.rand_name(cls.__name__ + '-secgroup')
cls.secgroup = cls.security_groups_client.create_security_group(
name=secgroup_name)['security_group']
@@ -44,7 +44,7 @@
def _create_security_group(self):
# Create a security group
- name = data_utils.rand_name('secgroup')
+ name = data_utils.rand_name(self.__class__.__name__ + '-secgroup')
security_group =\
self.security_groups_client.create_security_group(
name=name)['security_group']
diff --git a/patrole_tempest_plugin/tests/api/volume/test_user_messages_rbac.py b/patrole_tempest_plugin/tests/api/volume/test_user_messages_rbac.py
index 60484f1..219acb4 100644
--- a/patrole_tempest_plugin/tests/api/volume/test_user_messages_rbac.py
+++ b/patrole_tempest_plugin/tests/api/volume/test_user_messages_rbac.py
@@ -36,8 +36,10 @@
def _create_user_message(self):
"""Trigger a 'no valid host' situation to generate a message."""
- bad_protocol = data_utils.rand_name('storage_protocol')
- bad_vendor = data_utils.rand_name('vendor_name')
+ bad_protocol = data_utils.rand_name(
+ self.__class__.__name__ + '-storage_protocol')
+ bad_vendor = data_utils.rand_name(
+ self.__class__.__name__ + '-vendor_name')
extra_specs = {'storage_protocol': bad_protocol,
'vendor_name': bad_vendor}
vol_type_name = data_utils.rand_name(
diff --git a/patrole_tempest_plugin/tests/api/volume/test_volume_basic_crud_rbac.py b/patrole_tempest_plugin/tests/api/volume/test_volume_basic_crud_rbac.py
index 4be10cb..d780de7 100644
--- a/patrole_tempest_plugin/tests/api/volume/test_volume_basic_crud_rbac.py
+++ b/patrole_tempest_plugin/tests/api/volume/test_volume_basic_crud_rbac.py
@@ -58,7 +58,7 @@
@rbac_rule_validation.action(service="cinder", rule="volume:update")
@decorators.idempotent_id('b751b889-9a9b-40d8-ae7d-4b0f65e71ac7')
def test_update_volume(self):
- update_name = data_utils.rand_name('volume')
+ update_name = data_utils.rand_name(self.__class__.__name__ + 'volume')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.volumes_client.update_volume(self.volume['id'],
name=update_name)
diff --git a/patrole_tempest_plugin/tests/api/volume/test_volumes_backup_rbac.py b/patrole_tempest_plugin/tests/api/volume/test_volumes_backup_rbac.py
index 8c04a8d..c39a376 100644
--- a/patrole_tempest_plugin/tests/api/volume/test_volumes_backup_rbac.py
+++ b/patrole_tempest_plugin/tests/api/volume/test_volumes_backup_rbac.py
@@ -43,7 +43,7 @@
cls.volume = cls.create_volume()
def _create_backup(self, volume_id):
- backup_name = data_utils.rand_name('backup')
+ backup_name = data_utils.rand_name(self.__class__.__name__ + 'backup')
backup = self.backups_client.create_backup(
volume_id=volume_id, name=backup_name)['backup']
self.addCleanup(
diff --git a/patrole_tempest_plugin/tests/unit/test_rbac_rule_validation.py b/patrole_tempest_plugin/tests/unit/test_rbac_rule_validation.py
index 41af3b2..9d34a15 100644
--- a/patrole_tempest_plugin/tests/unit/test_rbac_rule_validation.py
+++ b/patrole_tempest_plugin/tests/unit/test_rbac_rule_validation.py
@@ -37,8 +37,7 @@
self.mock_args.auth_provider.credentials.user_id = \
mock.sentinel.user_id
- CONF.set_override('rbac_test_role', 'Member', group='rbac',
- enforce_type=True)
+ CONF.set_override('rbac_test_role', 'Member', group='rbac')
self.addCleanup(CONF.clear_override, 'rbac_test_role', group='rbac')
@mock.patch.object(rbac_rv, 'LOG', autospec=True)
@@ -255,14 +254,14 @@
"sentinel.action"), e.__str__())
mock_log.error.assert_called_once_with(
- "Role Member was allowed to perform sentinel.action")
+ 'Role %s was allowed to perform %s', ('Member',
+ mock.sentinel.action))
@mock.patch.object(rbac_rv, 'rbac_policy_parser', autospec=True)
def test_invalid_policy_rule_throws_parsing_exception(
self, mock_rbac_policy_parser):
"""Test that invalid policy action causes test to be skipped."""
- CONF.set_override('strict_policy_check', True, group='rbac',
- enforce_type=True)
+ CONF.set_override('strict_policy_check', True, group='rbac')
self.addCleanup(CONF.clear_override, 'strict_policy_check',
group='rbac')
diff --git a/patrole_tempest_plugin/tests/unit/test_rbac_utils.py b/patrole_tempest_plugin/tests/unit/test_rbac_utils.py
index a2917cf..b7f6ba8 100644
--- a/patrole_tempest_plugin/tests/unit/test_rbac_utils.py
+++ b/patrole_tempest_plugin/tests/unit/test_rbac_utils.py
@@ -51,12 +51,9 @@
self.mock_test_obj.os_admin = mock.Mock(
**{'roles_v3_client.list_roles.return_value': available_roles})
- CONF.set_override('admin_role', 'admin', group='identity',
- enforce_type=True)
- CONF.set_override('auth_version', 'v3', group='identity',
- enforce_type=True)
- CONF.set_override('rbac_test_role', 'Member', group='rbac',
- enforce_type=True)
+ CONF.set_override('admin_role', 'admin', group='identity')
+ CONF.set_override('auth_version', 'v3', group='identity')
+ CONF.set_override('rbac_test_role', 'Member', group='rbac')
self.addCleanup(CONF.clear_override, 'rbac_test_role', group='rbac')
self.addCleanup(CONF.clear_override, 'admin_role', group='identity')
diff --git a/tox.ini b/tox.ini
index be35509..d2e83e9 100644
--- a/tox.ini
+++ b/tox.ini
@@ -53,9 +53,9 @@
commands = oslo_debug_helper -t patrole_tempest_plugin/tests {posargs}
[flake8]
-# E123, E125 skipped as they are invalid PEP-8.
-
+enable-extensions = H106,H203,H904
show-source = True
+# E123, E125 skipped as they are invalid PEP-8.
ignore = E123,E125
builtins = _
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build