Merge "Compute API Aggregates Tests"
diff --git a/patrole_tempest_plugin/config.py b/patrole_tempest_plugin/config.py
index 6ee1528..94e6aef 100644
--- a/patrole_tempest_plugin/config.py
+++ b/patrole_tempest_plugin/config.py
@@ -25,5 +25,5 @@
" Patrole tests."),
cfg.BoolOpt('rbac_flag',
default=False,
- help="Enables RBAC tests."),
+ help="Enables RBAC tests.")
]
diff --git a/patrole_tempest_plugin/tests/api/compute/admin/__init__.py b/patrole_tempest_plugin/tests/api/compute/admin/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/compute/admin/__init__.py
diff --git a/patrole_tempest_plugin/tests/api/compute/admin/test_admin_password_rbac.py b/patrole_tempest_plugin/tests/api/compute/admin/test_admin_password_rbac.py
new file mode 100644
index 0000000..953f518
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/compute/admin/test_admin_password_rbac.py
@@ -0,0 +1,69 @@
+# Copyright 2017 AT&T Corporation.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import testtools
+
+from tempest import config
+from tempest.lib.common.utils import data_utils
+from tempest.lib import decorators
+
+from patrole_tempest_plugin import rbac_rule_validation
+from patrole_tempest_plugin.rbac_utils import rbac_utils
+from patrole_tempest_plugin.tests.api.compute import rbac_base
+
+
+CONF = config.CONF
+
+
+class PasswordAdminRbacTest(rbac_base.BaseV2ComputeAdminRbacTest):
+
+ def tearDown(self):
+ rbac_utils.switch_role(self, switchToRbacRole=False)
+ super(PasswordAdminRbacTest, self).tearDown()
+
+ @classmethod
+ def setup_clients(cls):
+ super(PasswordAdminRbacTest, cls).setup_clients()
+ cls.client = cls.servers_client
+
+ @classmethod
+ def skip_checks(cls):
+ super(PasswordAdminRbacTest, cls).skip_checks()
+ if not CONF.compute_feature_enabled.api_extensions:
+ raise cls.skipException(
+ '%s skipped as no compute extensions enabled' % cls.__name__)
+
+ @classmethod
+ def resource_setup(cls):
+ super(PasswordAdminRbacTest, cls).resource_setup()
+ cls.server_id = cls.create_test_server(wait_until='ACTIVE')['id']
+
+ @testtools.skipUnless(CONF.compute_feature_enabled.change_password,
+ 'Change password not available.')
+ @rbac_rule_validation.action(
+ service="nova", rule="os_compute_api:os-admin-password")
+ @decorators.idempotent_id('908a7d59-3a66-441c-94cf-38e57ed14956')
+ def test_change_server_password(self):
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.client.change_password(
+ self.server_id,
+ adminPass=data_utils.rand_password())
+
+ @rbac_rule_validation.action(
+ service="nova", rule="os_compute_api:os-admin-password:discoverable")
+ @decorators.idempotent_id('379fce8a-f1ff-11e6-bc64-92361f002671')
+ def test_admin_password_discoverable(self):
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.extensions_client.show_extension('os-admin-password')
diff --git a/patrole_tempest_plugin/tests/api/compute/admin/test_admin_server_actions_rbac.py b/patrole_tempest_plugin/tests/api/compute/admin/test_admin_server_actions_rbac.py
new file mode 100644
index 0000000..c49ba82
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/compute/admin/test_admin_server_actions_rbac.py
@@ -0,0 +1,83 @@
+# Copyright 2017 AT&T Corporation.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest import config
+from tempest.lib import decorators
+
+from patrole_tempest_plugin import rbac_rule_validation
+from patrole_tempest_plugin.rbac_utils import rbac_utils
+from patrole_tempest_plugin.tests.api.compute import rbac_base
+
+
+CONF = config.CONF
+
+
+class ServersAdminRbacTest(rbac_base.BaseV2ComputeAdminRbacTest):
+
+ def tearDown(self):
+ rbac_utils.switch_role(self, switchToRbacRole=False)
+ super(ServersAdminRbacTest, self).tearDown()
+
+ @classmethod
+ def setup_clients(cls):
+ super(ServersAdminRbacTest, cls).setup_clients()
+ cls.client = cls.servers_client
+
+ @classmethod
+ def skip_checks(cls):
+ super(ServersAdminRbacTest, cls).skip_checks()
+ if not CONF.compute_feature_enabled.api_extensions:
+ raise cls.skipException(
+ '%s skipped as no compute extensions enabled' % cls.__name__)
+
+ @classmethod
+ def resource_setup(cls):
+ super(ServersAdminRbacTest, cls).resource_setup()
+ cls.server_id = cls.create_test_server(wait_until='ACTIVE')['id']
+
+ @rbac_rule_validation.action(
+ service="nova",
+ rule="os_compute_api:os-admin-actions:reset_state")
+ @decorators.idempotent_id('ae84dd0b-f364-462e-b565-3457f9c019ef')
+ def test_reset_server_state(self):
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.client.reset_state(self.server_id, state='error')
+ self.addCleanup(self.client.reset_state,
+ self.server_id,
+ state='active')
+
+ @rbac_rule_validation.action(
+ service="nova",
+ rule="os_compute_api:os-admin-actions:inject_network_info")
+ @decorators.idempotent_id('ce48c340-51c1-4cff-9b6e-0cc5ef008630')
+ def test_inject_network_info(self):
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.client.inject_network_info(self.server_id)
+
+ @rbac_rule_validation.action(
+ service="nova",
+ rule="os_compute_api:os-admin-actions:reset_network")
+ @decorators.idempotent_id('2911a242-15c4-4fcb-80d5-80a8930661b0')
+ def test_reset_network(self):
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.client.reset_network(self.server_id)
+
+ @rbac_rule_validation.action(
+ service="nova",
+ rule="os_compute_api:os-admin-actions:discoverable")
+ @decorators.idempotent_id('e9d2991f-a05e-4116-881b-e2a82bb173cf')
+ def test_admin_actions_discoverable(self):
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.extensions_client.show_extension('os-admin-actions')
diff --git a/patrole_tempest_plugin/tests/api/compute/rbac_base.py b/patrole_tempest_plugin/tests/api/compute/rbac_base.py
index ca24204..6fd8f30 100644
--- a/patrole_tempest_plugin/tests/api/compute/rbac_base.py
+++ b/patrole_tempest_plugin/tests/api/compute/rbac_base.py
@@ -11,6 +11,9 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest.lib.common.utils import data_utils
+from tempest.lib.common.utils import test_utils
+
from tempest.api.compute import base as compute_base
from tempest import config
@@ -56,3 +59,34 @@
super(BaseV2ComputeAdminRbacTest, cls).setup_clients()
cls.admin_client = cls.os_admin.agents_client
cls.auth_provider = cls.os.auth_provider
+
+ @classmethod
+ def resource_setup(cls):
+ super(BaseV2ComputeAdminRbacTest, cls).resource_setup()
+ cls.flavors = []
+
+ @classmethod
+ def resource_cleanup(cls):
+ cls.clear_flavors()
+ super(BaseV2ComputeAdminRbacTest, cls).resource_cleanup()
+
+ @classmethod
+ def clear_flavors(cls):
+ for flavor in cls.flavors:
+ test_utils.call_and_ignore_notfound_exc(
+ cls.flavors_client.delete_flavor, flavor['id'])
+
+ @classmethod
+ def _create_flavor(cls, **kwargs):
+ flavor_kwargs = {
+ "name": data_utils.rand_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),
+ "id": data_utils.rand_uuid(),
+ }
+ if kwargs:
+ flavor_kwargs.update(kwargs)
+ flavor = cls.flavors_client.create_flavor(**flavor_kwargs)['flavor']
+ cls.flavors.append(flavor)
+ return flavor
diff --git a/patrole_tempest_plugin/tests/api/compute/test_access_ips_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_agents_rbac.py
similarity index 69%
rename from patrole_tempest_plugin/tests/api/compute/test_access_ips_rbac.py
rename to patrole_tempest_plugin/tests/api/compute/test_agents_rbac.py
index ffeebc9..356782c 100644
--- a/patrole_tempest_plugin/tests/api/compute/test_access_ips_rbac.py
+++ b/patrole_tempest_plugin/tests/api/compute/test_agents_rbac.py
@@ -23,23 +23,22 @@
CONF = config.CONF
-class AccessIpsRbacTest(rbac_base.BaseV2ComputeRbacTest):
+class AgentsRbacTest(rbac_base.BaseV2ComputeRbacTest):
def tearDown(self):
- rbac_utils.switch_role(self, switchToRbacRole=True)
- super(AccessIpsRbacTest, self).tearDown()
+ rbac_utils.switch_role(self, switchToRbacRole=False)
+ super(AgentsRbacTest, self).tearDown()
@classmethod
def skip_checks(cls):
- super(AccessIpsRbacTest, cls).skip_checks()
+ super(AgentsRbacTest, cls).skip_checks()
if not CONF.compute_feature_enabled.api_extensions:
raise cls.skipException(
'%s skipped as no compute extensions enabled' % cls.__name__)
- @rbac_rule_validation.action(service="nova",
- rule="os_compute_api:os-access-ips")
- @decorators.idempotent_id('f5811ed1-95d4-4085-a69e-87e6bd958738')
- def test_access_ip(self):
+ @rbac_rule_validation.action(
+ service="nova", rule="os_compute_api:os-agents")
+ @decorators.idempotent_id('d1bc6d97-07f5-4f45-ac29-1c619a6a7e27')
+ def test_list_agents_rbac(self):
rbac_utils.switch_role(self, switchToRbacRole=True)
- ipv4 = '127.0.0.1'
- self.create_test_server(accessIPv4=ipv4)
+ self.agents_client.list_agents()
diff --git a/patrole_tempest_plugin/tests/api/compute/test_attach_interfaces_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_attach_interfaces_rbac.py
new file mode 100644
index 0000000..6243c6a
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/compute/test_attach_interfaces_rbac.py
@@ -0,0 +1,98 @@
+# Copyright 2017 AT&T Corporation.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.common import waiters
+from tempest import config
+from tempest.lib.common.utils import test_utils
+from tempest.lib import decorators
+
+from patrole_tempest_plugin import rbac_rule_validation
+from patrole_tempest_plugin.rbac_utils import rbac_utils
+from patrole_tempest_plugin.tests.api.compute import rbac_base
+
+CONF = config.CONF
+
+
+class AttachInterfacesRbacTest(rbac_base.BaseV2ComputeRbacTest):
+
+ @classmethod
+ def setup_clients(cls):
+ super(AttachInterfacesRbacTest, cls).setup_clients()
+ cls.client = cls.interfaces_client
+
+ @classmethod
+ def skip_checks(cls):
+ super(AttachInterfacesRbacTest, cls).skip_checks()
+ if not CONF.compute_feature_enabled.api_extensions:
+ raise cls.skipException(
+ '%s skipped as no compute extensions enabled' % cls.__name__)
+ if not CONF.compute_feature_enabled.interface_attach:
+ raise cls.skipException(
+ "%s skipped as interface attachment is not available"
+ % cls.__name__)
+ if not CONF.service_available.neutron:
+ raise cls.skipException(
+ '%s skipped as Neutron is required' % cls.__name__)
+
+ @classmethod
+ def setup_credentials(cls):
+ cls.prepare_instance_network()
+ super(AttachInterfacesRbacTest, cls).setup_credentials()
+
+ @classmethod
+ def resource_setup(cls):
+ super(AttachInterfacesRbacTest, cls).resource_setup()
+ cls.server = cls.create_test_server(wait_until='ACTIVE')
+
+ def tearDown(self):
+ rbac_utils.switch_role(self, switchToRbacRole=False)
+ super(AttachInterfacesRbacTest, self).tearDown()
+
+ def _attach_interface_to_server(self):
+ interface = self.client.create_interface(
+ self.server['id'])['interfaceAttachment']
+ waiters.wait_for_interface_status(
+ self.interfaces_client, self.server['id'], interface['port_id'],
+ 'ACTIVE')
+ self.addCleanup(
+ test_utils.call_and_ignore_notfound_exc,
+ self.client.delete_interface, self.server['id'],
+ interface['port_id'])
+ return interface
+
+ @decorators.idempotent_id('ddf53cb6-4a0a-4e5a-91e3-6c32aaa3b9b6')
+ @rbac_rule_validation.action(
+ service="nova",
+ rule="os_compute_api:os-attach-interfaces")
+ def test_list_interfaces(self):
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.client.list_interfaces(self.server['id'])['interfaceAttachments']
+
+ @decorators.idempotent_id('d2d3a24d-4738-4bce-a287-36d664746cde')
+ @rbac_rule_validation.action(
+ service="nova",
+ rule="os_compute_api:os-attach-interfaces:create")
+ def test_create_interface(self):
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self._attach_interface_to_server()
+
+ @decorators.idempotent_id('55b05692-ed44-4608-a84c-cd4219c82799')
+ @rbac_rule_validation.action(
+ service="nova",
+ rule="os_compute_api:os-attach-interfaces:delete")
+ def test_delete_interface(self):
+ interface = self._attach_interface_to_server()
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.client.delete_interface(self.server['id'], interface['port_id'])
diff --git a/patrole_tempest_plugin/tests/api/compute/test_availability_zone_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_availability_zone_rbac.py
new file mode 100644
index 0000000..8465add
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/compute/test_availability_zone_rbac.py
@@ -0,0 +1,49 @@
+# Copyright 2017 AT&T Corporation.
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest import config
+from tempest.lib import decorators
+
+from patrole_tempest_plugin import rbac_rule_validation
+from patrole_tempest_plugin.rbac_utils import rbac_utils
+from patrole_tempest_plugin.tests.api.compute import rbac_base
+
+CONF = config.CONF
+
+
+class NovaAvailabilityZoneRbacTest(rbac_base.BaseV2ComputeRbacTest):
+
+ def tearDown(self):
+ rbac_utils.switch_role(self, switchToRbacRole=False)
+ super(NovaAvailabilityZoneRbacTest, self).tearDown()
+
+ @classmethod
+ def skip_checks(cls):
+ super(NovaAvailabilityZoneRbacTest, cls).skip_checks()
+ if not CONF.compute_feature_enabled.api_extensions:
+ raise cls.skipException(
+ '%s skipped as no compute extensions enabled' % cls.__name__)
+
+ @rbac_rule_validation.action(service="nova", rule="os_compute_api:"
+ "os-availability-zone:list")
+ @decorators.idempotent_id('cd34e7ea-d26e-4fa3-a8d0-f8883726ce3d')
+ def test_get_availability_zone_list_rbac(self):
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.os.availability_zone_client.list_availability_zones()
+
+ @rbac_rule_validation.action(service="nova", rule="os_compute_api:"
+ "os-availability-zone:detail")
+ @decorators.idempotent_id('2f61c191-6ece-4f21-b487-39d749e3d38e')
+ def test_get_availability_zone_list_detail_rbac(self):
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.os.availability_zone_client.list_availability_zones(detail=True)
diff --git a/patrole_tempest_plugin/tests/api/compute/test_flavor_access_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_flavor_access_rbac.py
new file mode 100644
index 0000000..32ec91a
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/compute/test_flavor_access_rbac.py
@@ -0,0 +1,93 @@
+# Copyright 2017 AT&T Corporation.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from oslo_log import log
+
+from tempest import config
+from tempest.lib.common.utils import test_utils
+from tempest.lib import decorators
+from tempest.lib import exceptions
+
+from patrole_tempest_plugin import rbac_exceptions
+from patrole_tempest_plugin import rbac_rule_validation
+from patrole_tempest_plugin.rbac_utils import rbac_utils
+from patrole_tempest_plugin.tests.api.compute import rbac_base
+
+CONF = config.CONF
+LOG = log.getLogger(__name__)
+
+
+class FlavorAccessAdminRbacTest(rbac_base.BaseV2ComputeAdminRbacTest):
+
+ @classmethod
+ def setup_clients(cls):
+ super(FlavorAccessAdminRbacTest, cls).setup_clients()
+ cls.client = cls.flavors_client
+
+ @classmethod
+ def skip_checks(cls):
+ super(FlavorAccessAdminRbacTest, cls).skip_checks()
+ if not CONF.compute_feature_enabled.api_extensions:
+ raise cls.skipException(
+ '%s skipped as no compute extensions enabled' % cls.__name__)
+
+ @classmethod
+ def resource_setup(cls):
+ super(FlavorAccessAdminRbacTest, cls).resource_setup()
+ cls.flavor_id = cls._create_flavor(is_public=False)['id']
+ cls.tenant_id = cls.auth_provider.credentials.tenant_id
+
+ def tearDown(self):
+ rbac_utils.switch_role(self, switchToRbacRole=False)
+ super(FlavorAccessAdminRbacTest, self).tearDown()
+
+ @decorators.idempotent_id('a2bd3740-765d-4c95-ac98-9e027378c75e')
+ @rbac_rule_validation.action(
+ service="nova",
+ rule="os_compute_api:os-flavor-access")
+ def test_list_flavor_access(self):
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ try:
+ self.client.list_flavor_access(self.flavor_id)
+ except exceptions.NotFound as e:
+ LOG.info("NotFound exception caught. Exception is thrown when "
+ "role doesn't have access to the endpoint."
+ "This is irregular and should be fixed.")
+ raise rbac_exceptions.RbacActionFailed(e)
+
+ @decorators.idempotent_id('39cb5c8f-9990-436f-9282-fc76a41d9bac')
+ @rbac_rule_validation.action(
+ service="nova",
+ rule="os_compute_api:os-flavor-access:add_tenant_access")
+ def test_add_flavor_access(self):
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.client.add_flavor_access(
+ flavor_id=self.flavor_id, tenant_id=self.tenant_id)
+ self.addCleanup(self.client.remove_flavor_access,
+ flavor_id=self.flavor_id, tenant_id=self.tenant_id)
+
+ @decorators.idempotent_id('61b8621f-52e4-473a-8d07-e228af8853d1')
+ @rbac_rule_validation.action(
+ service="nova",
+ rule="os_compute_api:os-flavor-access:remove_tenant_access")
+ def test_remove_flavor_access(self):
+ self.client.add_flavor_access(
+ flavor_id=self.flavor_id, tenant_id=self.tenant_id)
+ self.addCleanup(test_utils.call_and_ignore_notfound_exc,
+ self.client.remove_flavor_access,
+ flavor_id=self.flavor_id, tenant_id=self.tenant_id)
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.client.remove_flavor_access(
+ flavor_id=self.flavor_id, tenant_id=self.tenant_id)
diff --git a/patrole_tempest_plugin/tests/api/compute/test_floating_ips_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_floating_ips_rbac.py
new file mode 100644
index 0000000..ea5a346
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/compute/test_floating_ips_rbac.py
@@ -0,0 +1,57 @@
+# Copyright 2017 AT&T Corporation.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest import config
+from tempest.lib import decorators
+from tempest import test
+
+from patrole_tempest_plugin import rbac_rule_validation
+from patrole_tempest_plugin.rbac_utils import rbac_utils
+from patrole_tempest_plugin.tests.api.compute import rbac_base
+
+CONF = config.CONF
+
+
+class FloatingIpsRbacTest(rbac_base.BaseV2ComputeRbacTest):
+
+ # Tests will fail with a 404 starting from microversion 2.36, according to:
+ # https://developer.openstack.org/api-ref/
+ # compute/?expanded=list-floating-ip-addresses-detail
+ max_microversion = '2.35'
+
+ @classmethod
+ def setup_clients(cls):
+ super(FloatingIpsRbacTest, cls).setup_clients()
+ cls.client = cls.floating_ips_client
+
+ @classmethod
+ def skip_checks(cls):
+ super(FloatingIpsRbacTest, cls).skip_checks()
+ if not test.is_extension_enabled('os-floating-ips', 'compute'):
+ msg = "%s skipped as os-floating-ips extension not enabled." \
+ % cls.__name__
+ raise cls.skipException(msg)
+
+ def tearDown(self):
+ rbac_utils.switch_role(self, switchToRbacRole=False)
+ super(FloatingIpsRbacTest, self).tearDown()
+
+ @decorators.idempotent_id('ac1b3053-f755-4cda-85a0-30e88b88d7ba')
+ @rbac_rule_validation.action(
+ service="nova",
+ rule="os_compute_api:os-floating-ips")
+ def test_list_floating_ips(self):
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.client.list_floating_ips()['floating_ips']
diff --git a/patrole_tempest_plugin/tests/api/compute/test_access_ips_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_hosts_rbac.py
similarity index 62%
copy from patrole_tempest_plugin/tests/api/compute/test_access_ips_rbac.py
copy to patrole_tempest_plugin/tests/api/compute/test_hosts_rbac.py
index ffeebc9..d74a78e 100644
--- a/patrole_tempest_plugin/tests/api/compute/test_access_ips_rbac.py
+++ b/patrole_tempest_plugin/tests/api/compute/test_hosts_rbac.py
@@ -1,5 +1,5 @@
-# Copyright 2017 AT&T Corporation.
-# All Rights Reserved.
+# Copyright 2017 AT&T Corporation.
+# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
@@ -23,23 +23,28 @@
CONF = config.CONF
-class AccessIpsRbacTest(rbac_base.BaseV2ComputeRbacTest):
+class HostsAdminRbacTest(rbac_base.BaseV2ComputeAdminRbacTest):
- def tearDown(self):
- rbac_utils.switch_role(self, switchToRbacRole=True)
- super(AccessIpsRbacTest, self).tearDown()
+ @classmethod
+ def setup_clients(cls):
+ super(HostsAdminRbacTest, cls).setup_clients()
+ cls.client = cls.os.hosts_client
@classmethod
def skip_checks(cls):
- super(AccessIpsRbacTest, cls).skip_checks()
+ super(HostsAdminRbacTest, cls).skip_checks()
if not CONF.compute_feature_enabled.api_extensions:
raise cls.skipException(
'%s skipped as no compute extensions enabled' % cls.__name__)
- @rbac_rule_validation.action(service="nova",
- rule="os_compute_api:os-access-ips")
- @decorators.idempotent_id('f5811ed1-95d4-4085-a69e-87e6bd958738')
- def test_access_ip(self):
+ def tearDown(self):
+ rbac_utils.switch_role(self, switchToRbacRole=False)
+ super(HostsAdminRbacTest, self).tearDown()
+
+ @decorators.idempotent_id('035b7935-2fae-4218-8d37-27fa83097494')
+ @rbac_rule_validation.action(
+ service="nova",
+ rule="os_compute_api:os-hosts")
+ def test_list_hosts(self):
rbac_utils.switch_role(self, switchToRbacRole=True)
- ipv4 = '127.0.0.1'
- self.create_test_server(accessIPv4=ipv4)
+ self.client.list_hosts()['hosts']
diff --git a/patrole_tempest_plugin/tests/api/compute/test_access_ips_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_hypervisor_rbac.py
similarity index 60%
copy from patrole_tempest_plugin/tests/api/compute/test_access_ips_rbac.py
copy to patrole_tempest_plugin/tests/api/compute/test_hypervisor_rbac.py
index ffeebc9..e495b7d 100644
--- a/patrole_tempest_plugin/tests/api/compute/test_access_ips_rbac.py
+++ b/patrole_tempest_plugin/tests/api/compute/test_hypervisor_rbac.py
@@ -1,5 +1,5 @@
-# Copyright 2017 AT&T Corporation.
-# All Rights Reserved.
+# Copyright 2017 AT&T Corporation.
+# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
@@ -23,23 +23,27 @@
CONF = config.CONF
-class AccessIpsRbacTest(rbac_base.BaseV2ComputeRbacTest):
+class HypervisorAdminRbacTest(rbac_base.BaseV2ComputeAdminRbacTest):
- def tearDown(self):
- rbac_utils.switch_role(self, switchToRbacRole=True)
- super(AccessIpsRbacTest, self).tearDown()
+ @classmethod
+ def setup_clients(cls):
+ super(HypervisorAdminRbacTest, cls).setup_clients()
+ cls.client = cls.hypervisor_client
@classmethod
def skip_checks(cls):
- super(AccessIpsRbacTest, cls).skip_checks()
+ super(HypervisorAdminRbacTest, cls).skip_checks()
if not CONF.compute_feature_enabled.api_extensions:
raise cls.skipException(
'%s skipped as no compute extensions enabled' % cls.__name__)
- @rbac_rule_validation.action(service="nova",
- rule="os_compute_api:os-access-ips")
- @decorators.idempotent_id('f5811ed1-95d4-4085-a69e-87e6bd958738')
- def test_access_ip(self):
- rbac_utils.switch_role(self, switchToRbacRole=True)
- ipv4 = '127.0.0.1'
- self.create_test_server(accessIPv4=ipv4)
+ def tearDown(self):
+ rbac_utils.switch_role(self, switchToRbacRole=False)
+ super(HypervisorAdminRbacTest, self).tearDown()
+
+ @decorators.idempotent_id('17bbeb9a-e73e-445f-a771-c794448ef562')
+ @rbac_rule_validation.action(
+ service="nova",
+ rule="os_compute_api:os-hypervisors")
+ def test_list_hypervisors(self):
+ self.client.list_hypervisors()['hypervisors']
diff --git a/patrole_tempest_plugin/tests/api/compute/test_instance_usages_audit_log_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_instance_usages_audit_log_rbac.py
new file mode 100644
index 0000000..b37f74f
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/compute/test_instance_usages_audit_log_rbac.py
@@ -0,0 +1,50 @@
+# Copyright 2017 AT&T Corporation.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.lib import decorators
+from tempest import test
+
+from patrole_tempest_plugin import rbac_rule_validation
+from patrole_tempest_plugin.rbac_utils import rbac_utils
+from patrole_tempest_plugin.tests.api.compute import rbac_base
+
+
+class InstanceUsagesAuditLogAdminRbacTest(
+ rbac_base.BaseV2ComputeAdminRbacTest):
+
+ @classmethod
+ def skip_checks(cls):
+ super(InstanceUsagesAuditLogAdminRbacTest, cls).skip_checks()
+ if not test.is_extension_enabled('os-instance-usage-audit-log',
+ 'compute'):
+ msg = "os-instance-usage-audit-log extension not enabled."
+ raise cls.skipException(msg)
+
+ @classmethod
+ def setup_clients(cls):
+ super(InstanceUsagesAuditLogAdminRbacTest, cls).setup_clients()
+ cls.client = cls.instance_usages_audit_log_client
+
+ def tearDown(self):
+ rbac_utils.switch_role(self, switchToRbacRole=False)
+ super(InstanceUsagesAuditLogAdminRbacTest, self).tearDown()
+
+ @decorators.idempotent_id('c80246c0-5c13-4ab0-97ba-91551cd53dc1')
+ @rbac_rule_validation.action(
+ service="nova", rule="os_compute_api:os-instance-usage-audit-log")
+ def test_list_instance_usage_audit_logs(self):
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.client.list_instance_usage_audit_logs()
+ ["instance_usage_audit_logs"]
diff --git a/patrole_tempest_plugin/tests/api/compute/test_ips_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_ips_rbac.py
new file mode 100644
index 0000000..cbe66f6
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/compute/test_ips_rbac.py
@@ -0,0 +1,74 @@
+# Copyright 2017 AT&T Corporation.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest import config
+from tempest.lib import decorators
+
+from patrole_tempest_plugin import rbac_rule_validation
+from patrole_tempest_plugin.rbac_utils import rbac_utils
+from patrole_tempest_plugin.tests.api.compute import rbac_base
+
+CONF = config.CONF
+
+
+class IpsRbacTest(rbac_base.BaseV2ComputeRbacTest):
+
+ @classmethod
+ def setup_clients(cls):
+ super(IpsRbacTest, cls).setup_clients()
+ cls.client = cls.servers_client
+
+ @classmethod
+ def skip_checks(cls):
+ super(IpsRbacTest, cls).skip_checks()
+ if not CONF.compute_feature_enabled.api_extensions:
+ raise cls.skipException(
+ '%s skipped as no compute extensions enabled' % cls.__name__)
+ if not CONF.service_available.neutron:
+ raise cls.skipException(
+ '%s skipped as Neutron is required' % cls.__name__)
+
+ @classmethod
+ def setup_credentials(cls):
+ cls.prepare_instance_network()
+ super(IpsRbacTest, cls).setup_credentials()
+
+ @classmethod
+ def resource_setup(cls):
+ super(IpsRbacTest, cls).resource_setup()
+ cls.server = cls.create_test_server(wait_until='ACTIVE')
+
+ def tearDown(self):
+ rbac_utils.switch_role(self, switchToRbacRole=False)
+ super(IpsRbacTest, self).tearDown()
+
+ @decorators.idempotent_id('6886d360-0d86-4760-b1a3-882d81fbebcc')
+ @rbac_rule_validation.action(
+ service="nova",
+ rule="os_compute_api:ips:index")
+ def test_list_addresses(self):
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.client.list_addresses(self.server['id'])['addresses']
+
+ @decorators.idempotent_id('fa43e7e5-0db9-48eb-9c6b-c11eb766b8e4')
+ @rbac_rule_validation.action(
+ service="nova",
+ rule="os_compute_api:ips:show")
+ def test_list_addresses_by_network(self):
+ addresses = self.client.list_addresses(self.server['id'])['addresses']
+ address = next(iter(addresses))
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.client.list_addresses_by_network(
+ self.server['id'], address)[address]
diff --git a/patrole_tempest_plugin/tests/api/compute/test_security_groups_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_security_groups_rbac.py
new file mode 100644
index 0000000..7cbf012
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/compute/test_security_groups_rbac.py
@@ -0,0 +1,35 @@
+# Copyright 2017 AT&T Corporation.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.lib import decorators
+
+from patrole_tempest_plugin import rbac_rule_validation
+from patrole_tempest_plugin.rbac_utils import rbac_utils
+from patrole_tempest_plugin.tests.api.compute import rbac_base
+
+
+class SecurityGroupsRbacTest(rbac_base.BaseV2ComputeRbacTest):
+
+ def tearDown(self):
+ rbac_utils.switch_role(self, switchToRbacRole=False)
+ super(SecurityGroupsRbacTest, self).tearDown()
+
+ @rbac_rule_validation.action(
+ service="nova",
+ rule="os_compute_api:os-security-groups")
+ @decorators.idempotent_id('4ac58e49-48c1-4fca-a6c3-3f95fb99eb77')
+ def test_server_security_groups(self):
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.security_groups_client.list_security_groups()
diff --git a/patrole_tempest_plugin/tests/api/compute/test_tenant_networks_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_tenant_networks_rbac.py
new file mode 100644
index 0000000..1bb5100
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/compute/test_tenant_networks_rbac.py
@@ -0,0 +1,65 @@
+# Copyright 2017 AT&T Corporation.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from oslo_config import cfg
+
+from tempest.lib import decorators
+from tempest import test
+
+from patrole_tempest_plugin import rbac_rule_validation
+from patrole_tempest_plugin.rbac_utils import rbac_utils
+from patrole_tempest_plugin.tests.api.compute import rbac_base
+
+CONF = cfg.CONF
+
+
+class TenantNetworksRbacTest(rbac_base.BaseV2ComputeRbacTest):
+
+ # Tests will fail with a 404 starting from microversion 2.36, according to:
+ # https://developer.openstack.org/api-ref/
+ # compute/?expanded=list-project-networks-detail
+ max_microversion = '2.35'
+
+ @classmethod
+ def setup_clients(cls):
+ super(TenantNetworksRbacTest, cls).setup_clients()
+ cls.client = cls.os.tenant_networks_client
+
+ @classmethod
+ def skip_checks(cls):
+ super(TenantNetworksRbacTest, cls).skip_checks()
+ if not test.is_extension_enabled('os-tenant-networks', 'compute'):
+ msg = "os-tenant-networks extension not enabled."
+ raise cls.skipException(msg)
+ if not CONF.service_available.neutron:
+ raise cls.skipException(
+ '%s skipped as Neutron is required' % cls.__name__)
+
+ @classmethod
+ def setup_credentials(cls):
+ cls.set_network_resources(network=True)
+ super(TenantNetworksRbacTest, cls).setup_credentials()
+
+ def tearDown(self):
+ rbac_utils.switch_role(self, switchToRbacRole=False)
+ super(TenantNetworksRbacTest, self).tearDown()
+
+ @decorators.idempotent_id('42b39ba1-14aa-4799-9518-34367d0da67a')
+ @rbac_rule_validation.action(
+ service="nova",
+ rule="os_compute_api:os-tenant-networks")
+ def test_list_show_tenant_networks(self):
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.client.list_tenant_networks()['networks']
diff --git a/patrole_tempest_plugin/tests/api/identity/v2/__init__.py b/patrole_tempest_plugin/tests/api/identity/v2/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/identity/v2/__init__.py
diff --git a/patrole_tempest_plugin/tests/api/identity/v2/rbac_base.py b/patrole_tempest_plugin/tests/api/identity/v2/rbac_base.py
new file mode 100644
index 0000000..e379873
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/identity/v2/rbac_base.py
@@ -0,0 +1,54 @@
+# Copyright 2017 AT&T Corporation.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.api.identity import base
+from tempest import config
+from tempest.lib.common.utils import data_utils
+from tempest.lib.common.utils import test_utils
+
+CONF = config.CONF
+
+
+class BaseIdentityV2AdminRbacTest(base.BaseIdentityV2AdminTest):
+
+ credentials = ['primary', 'admin']
+
+ @classmethod
+ def skip_checks(cls):
+ super(BaseIdentityV2AdminRbacTest, cls).skip_checks()
+ if not CONF.rbac.rbac_flag:
+ raise cls.skipException(
+ "%s skipped as RBAC Flag not enabled" % cls.__name__)
+ if 'admin' not in CONF.auth.tempest_roles:
+ raise cls.skipException(
+ "%s skipped because tempest roles is not admin" % cls.__name__)
+
+ @classmethod
+ def setup_clients(cls):
+ super(BaseIdentityV2AdminRbacTest, cls).setup_clients()
+ cls.auth_provider = cls.os.auth_provider
+ cls.admin_client = cls.os_adm.identity_client
+
+ def _create_service(self):
+ name = data_utils.rand_name('service')
+ type = data_utils.rand_name('type')
+
+ self.service = self.services_client.create_service(
+ name=name, type=type,
+ description="description")
+ self.addCleanup(test_utils.call_and_ignore_notfound_exc,
+ self.services_client.delete_service,
+ self.service['OS-KSADM:service']['id'])
+ return self.service
diff --git a/patrole_tempest_plugin/tests/api/identity/v2/test_endpoints_rbac.py b/patrole_tempest_plugin/tests/api/identity/v2/test_endpoints_rbac.py
new file mode 100644
index 0000000..b448976
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/identity/v2/test_endpoints_rbac.py
@@ -0,0 +1,99 @@
+# Copyright 2017 AT&T Corporation.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest import config
+from tempest.lib.common.utils import data_utils
+from tempest.lib.common.utils import test_utils
+from tempest.lib import decorators
+
+from patrole_tempest_plugin import rbac_rule_validation
+from patrole_tempest_plugin.rbac_utils import rbac_utils
+from patrole_tempest_plugin.tests.api.identity.v2 import rbac_base
+
+CONF = config.CONF
+
+
+class IdentityEndpointsV2AdminRbacTest(rbac_base.BaseIdentityV2AdminRbacTest):
+
+ @classmethod
+ def setup_clients(cls):
+ super(IdentityEndpointsV2AdminRbacTest, cls).setup_clients()
+ cls.endpoints_client = cls.os.endpoints_client
+
+ @classmethod
+ def resource_setup(cls):
+ super(IdentityEndpointsV2AdminRbacTest, cls).resource_setup()
+ cls.region = data_utils.rand_name('region')
+ cls.public_url = data_utils.rand_url()
+ cls.admin_url = data_utils.rand_url()
+ cls.internal_url = data_utils.rand_url()
+
+ def tearDown(self):
+ rbac_utils.switch_role(self, switchToRbacRole=False)
+ super(IdentityEndpointsV2AdminRbacTest, self).tearDown()
+
+ def _create_endpoint(self):
+ self._create_service()
+ endpoint = self.endpoints_client.create_endpoint(
+ service_id=self.service['OS-KSADM:service']['id'],
+ region=self.region,
+ publicurl=self.public_url,
+ adminurl=self.admin_url,
+ internalurl=self.internal_url
+ )
+ self.addCleanup(test_utils.call_and_ignore_notfound_exc,
+ self.endpoints_client.delete_endpoint,
+ endpoint['endpoint']['id'])
+ return endpoint
+
+ @rbac_rule_validation.action(service="keystone",
+ rule="identity:create_endpoint")
+ @decorators.idempotent_id('6bdaecd4-0843-4ed6-ab64-3a57ab0cd124')
+ def test_create_endpoint(self):
+
+ """Create Endpoint Test
+
+ RBAC test for Identity Admin 2.0 create_endpoint
+ """
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self._create_endpoint()
+
+ @rbac_rule_validation.action(service="keystone",
+ rule="identity:delete_endpoint")
+ @decorators.idempotent_id('6bdaecd4-0843-4ed6-ab64-3a57ab0cd125')
+ def test_delete_endpoint(self):
+
+ """Delete Endpoint Test
+
+ RBAC test for Identity Admin 2.0 delete_endpoint
+ """
+
+ endpoint = self._create_endpoint()
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.endpoints_client.delete_endpoint(endpoint['endpoint']['id'])
+
+ @rbac_rule_validation.action(service="keystone",
+ rule="identity:list_endpoints")
+ @decorators.idempotent_id('6bdaecd4-0843-4ed6-ab64-3a57ab0cd126')
+ def test_list_endpoints(self):
+
+ """List Endpoints Test
+
+ RBAC test for Identity Admin 2.0 list_endpoint
+ """
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.endpoints_client.list_endpoints()
diff --git a/patrole_tempest_plugin/tests/api/identity/v2/test_projects_rbac.py b/patrole_tempest_plugin/tests/api/identity/v2/test_projects_rbac.py
new file mode 100644
index 0000000..0c2eb96
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/identity/v2/test_projects_rbac.py
@@ -0,0 +1,136 @@
+# Copyright 2017 AT&T Corporation.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest import config
+from tempest.lib.common.utils import data_utils
+from tempest.lib.common.utils import test_utils
+from tempest.lib import decorators
+
+from patrole_tempest_plugin import rbac_rule_validation
+from patrole_tempest_plugin.rbac_utils import rbac_utils
+from patrole_tempest_plugin.tests.api.identity.v2 import rbac_base
+
+CONF = config.CONF
+
+
+class IdentityProjectV2AdminRbacTest(rbac_base.BaseIdentityV2AdminRbacTest):
+
+ def tearDown(self):
+ rbac_utils.switch_role(self, switchToRbacRole=False)
+ super(IdentityProjectV2AdminRbacTest, self).tearDown()
+
+ @classmethod
+ def setup_clients(cls):
+ super(IdentityProjectV2AdminRbacTest, cls).setup_clients()
+ cls.tenants_client = cls.os.tenants_client
+
+ def _create_tenant(self, name):
+ self.tenant = self.tenants_client.create_tenant(name=name)
+ self.addCleanup(test_utils.call_and_ignore_notfound_exc,
+ self.tenants_client.delete_tenant,
+ self.tenant['tenant']['id'])
+ return self.tenant
+
+ @rbac_rule_validation.action(service="keystone",
+ rule="identity:create_project")
+ @decorators.idempotent_id('0f148510-63bf-11e6-b348-080044d0d904')
+ def test_create_project(self):
+
+ """Create Project Test
+
+ RBAC test for Identity 2.0 create_tenant
+ """
+
+ tenant_name = data_utils.rand_name('test_create_project')
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self._create_tenant(tenant_name)
+
+ @rbac_rule_validation.action(service="keystone",
+ rule="identity:update_project")
+ @decorators.idempotent_id('0f148510-63bf-11e6-b348-080044d0d905')
+ def test_update_project(self):
+
+ """Update Project Test
+
+ RBAC test for Identity 2.0 update_tenant
+ """
+
+ tenant_name = data_utils.rand_name('test_update_project')
+ tenant = self._create_tenant(tenant_name)
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.tenants_client.update_tenant(tenant['tenant']['id'],
+ description="Changed description")
+
+ @rbac_rule_validation.action(service="keystone",
+ rule="identity:delete_project")
+ @decorators.idempotent_id('0f148510-63bf-11e6-b348-080044d0d906')
+ def test_delete_project(self):
+
+ """Delete Project Test
+
+ RBAC test for Identity 2.0 delete_tenant
+ """
+
+ tenant_name = data_utils.rand_name('test_delete_project')
+ tenant = self._create_tenant(tenant_name)
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.tenants_client.delete_tenant(tenant['tenant']['id'])
+
+ @rbac_rule_validation.action(service="keystone",
+ rule="identity:get_project")
+ @decorators.idempotent_id('0f148510-63bf-11e6-b348-080044d0d907')
+ def test_get_project(self):
+
+ """Get Project Test
+
+ RBAC test for Identity 2.0 show_tenant
+ """
+
+ tenant_name = data_utils.rand_name('test_get_project')
+ tenant = self._create_tenant(tenant_name)
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.tenants_client.show_tenant(tenant['tenant']['id'])
+
+ @rbac_rule_validation.action(service="keystone",
+ rule="identity:list_projects")
+ @decorators.idempotent_id('0f148510-63bf-11e6-b348-080044d0d908')
+ def test_get_all_projects(self):
+
+ """List All Projects Test
+
+ RBAC test for Identity 2.0 list_tenants
+ """
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.tenants_client.list_tenants()
+
+ @rbac_rule_validation.action(service="keystone",
+ rule="identity:list_user_projects")
+ @decorators.idempotent_id('0f148510-63bf-11e6-b348-080044d0d909')
+ def test_list_users_for_tenant(self):
+
+ """Get Users of a Project Test
+
+ RBAC test for Identity 2.0 list_tenant_users
+ """
+
+ tenant_name = data_utils.rand_name('test_list_users_for_tenant')
+ tenant = self._create_tenant(tenant_name)
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.tenants_client.list_tenant_users(tenant['tenant']['id'])
diff --git a/patrole_tempest_plugin/tests/api/identity/v2/test_services_rbac.py b/patrole_tempest_plugin/tests/api/identity/v2/test_services_rbac.py
new file mode 100644
index 0000000..93f20ef
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/identity/v2/test_services_rbac.py
@@ -0,0 +1,83 @@
+# Copyright 2017 AT&T Corporation.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest import config
+from tempest.lib import decorators
+
+from patrole_tempest_plugin import rbac_rule_validation
+from patrole_tempest_plugin.rbac_utils import rbac_utils
+from patrole_tempest_plugin.tests.api.identity.v2 import rbac_base
+
+CONF = config.CONF
+
+
+class IdentityServicesV2AdminRbacTest(rbac_base.BaseIdentityV2AdminRbacTest):
+
+ def tearDown(self):
+ rbac_utils.switch_role(self, switchToRbacRole=False)
+ super(IdentityServicesV2AdminRbacTest, self).tearDown()
+
+ @classmethod
+ def setup_clients(cls):
+ super(IdentityServicesV2AdminRbacTest, cls).setup_clients()
+ cls.services_client = cls.os.identity_services_client
+
+ @rbac_rule_validation.action(service="keystone",
+ rule="identity:create_service")
+ @decorators.idempotent_id('370050f6-d271-4fb4-abc5-4de1d6dfbad2')
+ def test_create_service(self):
+ """Create Service Test
+
+ RBAC test for Identity Admin 2.0 create_service
+ """
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self._create_service()
+
+ @rbac_rule_validation.action(service="keystone",
+ rule="identity:delete_service")
+ @decorators.idempotent_id('f6c64fc3-6a1f-423e-af91-e411add3a384')
+ def test_delete_service(self):
+ """Delete Service Test
+
+ RBAC test for Identity Admin 2.0 delete_service
+ """
+ service_id = self._create_service()['OS-KSADM:service']['id']
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.services_client.delete_service(service_id)
+
+ @rbac_rule_validation.action(service="keystone",
+ rule="identity:get_service")
+ @decorators.idempotent_id('504d62bb-97d7-445e-9d6d-b1945a7c9e08')
+ def test_show_service(self):
+ """Show Service Test
+
+ RBAC test for Identity Admin 2.0 show_service
+ """
+ service_id = self._create_service()['OS-KSADM:service']['id']
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.services_client.show_service(service_id)
+
+ @rbac_rule_validation.action(service="keystone",
+ rule="identity:list_services")
+ @decorators.idempotent_id('d7dc461d-51ad-48e0-9cd2-33add1b88de9')
+ def test_list_services(self):
+ """List all the services
+
+ RBAC test for Identity Admin 2.0 list_service
+ """
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.services_client.list_services()
diff --git a/patrole_tempest_plugin/tests/api/identity/v3/rbac_base.py b/patrole_tempest_plugin/tests/api/identity/v3/rbac_base.py
index c2b883a..1e29023 100644
--- a/patrole_tempest_plugin/tests/api/identity/v3/rbac_base.py
+++ b/patrole_tempest_plugin/tests/api/identity/v3/rbac_base.py
@@ -42,6 +42,8 @@
cls.admin_client = cls.os_adm.identity_v3_client
cls.creds_client = cls.os.credentials_client
cls.services_client = cls.os.identity_services_v3_client
+ cls.endpoints_client = cls.os.endpoints_v3_client
+ cls.groups_client = cls.os.groups_client
def _create_service(self):
"""Creates a service for test."""
diff --git a/patrole_tempest_plugin/tests/api/identity/v3/test_endpoints_rbac.py b/patrole_tempest_plugin/tests/api/identity/v3/test_endpoints_rbac.py
new file mode 100644
index 0000000..b60c3e8
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/identity/v3/test_endpoints_rbac.py
@@ -0,0 +1,111 @@
+# Copyright 2017 AT&T Corporation.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.common.utils import data_utils
+from tempest import config
+from tempest.lib.common.utils import test_utils
+from tempest.lib import decorators
+
+from patrole_tempest_plugin import rbac_rule_validation
+from patrole_tempest_plugin.rbac_utils import rbac_utils
+from patrole_tempest_plugin.tests.api.identity.v3 import rbac_base
+
+CONF = config.CONF
+
+
+class IdentityEndpointsV3AdminRbacTest(
+ rbac_base.BaseIdentityV3RbacAdminTest):
+
+ def _create_endpoint(self):
+ """Creates a service and an endpoint for test."""
+ interface = 'public'
+ url = data_utils.rand_url()
+ service = self._create_service()
+ endpoint = self.endpoints_client \
+ .create_endpoint(service_id=service['id'],
+ interface=interface,
+ url=url)['endpoint']
+ self.addCleanup(test_utils.call_and_ignore_notfound_exc,
+ self.endpoints_client.delete_endpoint, endpoint['id'])
+ return (service, endpoint)
+
+ def tearDown(self):
+ """Reverts user back to admin for cleanup."""
+ rbac_utils.switch_role(self, switchToRbacRole=False)
+ super(IdentityEndpointsV3AdminRbacTest, self).tearDown()
+
+ @rbac_rule_validation.action(service="keystone",
+ rule="identity:create_endpoint")
+ @decorators.idempotent_id('6bdaecd4-0843-4ed6-ab64-3a57ab0cd127')
+ def test_create_endpoint(self):
+ """Create an endpoint.
+
+ RBAC test for Keystone: identity:create_endpoint
+ """
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self._create_endpoint()
+
+ @rbac_rule_validation.action(service="keystone",
+ rule="identity:update_endpoint")
+ @decorators.idempotent_id('6bdaecd4-0843-4ed6-ab64-3a57ab0cd128')
+ def test_update_endpoint(self):
+ """Update an endpoint.
+
+ RBAC test for Keystone: identity:update_endpoint
+ """
+ service, endpoint = self._create_endpoint()
+ new_url = data_utils.rand_url()
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.endpoints_client.update_endpoint(endpoint["id"],
+ service_id=service['id'],
+ url=new_url)
+
+ @rbac_rule_validation.action(service="keystone",
+ rule="identity:delete_endpoint")
+ @decorators.idempotent_id('6bdaecd4-0843-4ed6-ab64-3a57ab0cd129')
+ def test_delete_endpoint(self):
+ """Delete an endpoint.
+
+ RBAC test for Keystone: identity:delete_endpoint
+ """
+ _, endpoint = self._create_endpoint()
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.endpoints_client.delete_endpoint(endpoint['id'])
+
+ @rbac_rule_validation.action(service="keystone",
+ rule="identity:get_endpoint")
+ @decorators.idempotent_id('6bdaecd4-0843-4ed6-ab64-3a57ab0cd130')
+ def test_show_endpoint(self):
+ """Show/Get an endpoint.
+
+ RBAC test for Keystone: identity:get_endpoint
+ """
+ _, endpoint = self._create_endpoint()
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.endpoints_client.show_endpoint(endpoint['id'])
+
+ @rbac_rule_validation.action(service="keystone",
+ rule="identity:list_endpoints")
+ @decorators.idempotent_id('6bdaecd4-0843-4ed6-ab64-3a57ab0cd131')
+ def test_list_endpoints(self):
+ """Create a Domain.
+
+ RBAC test for Keystone: identity:create_domain
+ """
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.endpoints_client.list_endpoints()
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
new file mode 100644
index 0000000..ec4fd41
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/identity/v3/test_groups_rbac.py
@@ -0,0 +1,134 @@
+# Copyright 2017 AT&T Corporation.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.common.utils import data_utils
+from tempest import config
+from tempest.lib.common.utils import test_utils
+from tempest.lib import decorators
+
+from patrole_tempest_plugin import rbac_rule_validation
+from patrole_tempest_plugin.rbac_utils import rbac_utils
+from patrole_tempest_plugin.tests.api.identity.v3 import rbac_base
+
+CONF = config.CONF
+
+
+class IdentityGroupsV3AdminRbacTest(rbac_base.BaseIdentityV3RbacAdminTest):
+
+ def tearDown(self):
+ """Reverts user back to admin for cleanup."""
+ rbac_utils.switch_role(self, switchToRbacRole=False)
+ super(IdentityGroupsV3AdminRbacTest, self).tearDown()
+
+ def _create_group(self):
+ """Creates a group for test."""
+ name = data_utils.rand_name('Group')
+ group = self.groups_client \
+ .create_group(name=name)['group']
+
+ self.addCleanup(test_utils.call_and_ignore_notfound_exc,
+ self.groups_client.delete_group, group['id'])
+ return group
+
+ def _add_user_to_group(self, group_id):
+ """Creates a user and adds to a group for test."""
+ user_name = data_utils.rand_name('User')
+ user = self._create_test_user(name=user_name, password=None)
+
+ self.groups_client.add_group_user(group_id, user['id'])
+
+ return user['id']
+
+ @rbac_rule_validation.action(service="keystone",
+ rule="identity:create_group")
+ @decorators.idempotent_id('88377f51-9074-4d64-a22f-f8931d048c9a')
+ def test_create_group(self):
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self._create_group()
+
+ @rbac_rule_validation.action(service="keystone",
+ rule="identity:update_group")
+ @decorators.idempotent_id('790fb7be-a657-4a64-9b83-c43425cf180b')
+ def test_update_group(self):
+ group = self._create_group()
+ # Update Group
+ new_name = data_utils.rand_name('UpdateGroup')
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.groups_client.update_group(group['id'],
+ name=new_name)
+
+ @rbac_rule_validation.action(service="keystone",
+ rule="identity:delete_group")
+ @decorators.idempotent_id('646b52da-2a5f-486a-afb0-51fdc86a6c12')
+ def test_delete_group(self):
+ group = self._create_group()
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.groups_client.delete_group(group['id'])
+
+ @rbac_rule_validation.action(service="keystone",
+ rule="identity:get_group")
+ @decorators.idempotent_id('d530f0ad-42b9-429b-ad05-e53ac95a040e')
+ def test_show_group(self):
+ group = self._create_group()
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.groups_client.show_group(group['id'])
+
+ @rbac_rule_validation.action(service="keystone",
+ rule="identity:list_groups")
+ @decorators.idempotent_id('c4d0f76b-735f-4fd0-868b-0006bc420ff4')
+ def test_list_groups(self):
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.groups_client.list_groups()
+
+ @rbac_rule_validation.action(service="keystone",
+ rule="identity:add_user_to_group")
+ @decorators.idempotent_id('fdd49b74-3ed3-4736-9f0e-9027a32017ac')
+ def test_add_user_group(self):
+ group = self._create_group()
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self._add_user_to_group(group['id'])
+
+ @rbac_rule_validation.action(service="keystone",
+ rule="identity:remove_user_from_group")
+ @decorators.idempotent_id('8a60d11c-7d2b-47e5-a0f3-9ea900ca66fe')
+ def test_remove_user_group(self):
+ group = self._create_group()
+ user_id = self._add_user_to_group(group['id'])
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.groups_client.delete_group_user(group['id'], user_id)
+
+ @rbac_rule_validation.action(service="keystone",
+ rule="identity:list_users_in_group")
+ @decorators.idempotent_id('b3e394a7-079e-4a0d-a4ff-9b266293d1ee')
+ def test_list_user_group(self):
+ group = self._create_group()
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.groups_client.list_group_users(group['id'])
+
+ @rbac_rule_validation.action(service="keystone",
+ rule="identity:check_user_in_group")
+ @decorators.idempotent_id('d3603241-fd87-4a2d-94f9-f32469d1aaba')
+ def test_check_user_group(self):
+ group = self._create_group()
+ user_id = self._add_user_to_group(group['id'])
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.groups_client.check_group_user_existence(group['id'], user_id)
diff --git a/patrole_tempest_plugin/tests/api/image/v2/test_test_image_namespace_resource_type.py b/patrole_tempest_plugin/tests/api/image/v2/test_image_namespace_resource_type.py
similarity index 100%
rename from patrole_tempest_plugin/tests/api/image/v2/test_test_image_namespace_resource_type.py
rename to patrole_tempest_plugin/tests/api/image/v2/test_image_namespace_resource_type.py
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 eb5c42a..3faa696 100644
--- a/patrole_tempest_plugin/tests/api/network/test_networks_rbac.py
+++ b/patrole_tempest_plugin/tests/api/network/test_networks_rbac.py
@@ -97,6 +97,7 @@
return network
def _update_network(self,
+ net_id=None,
admin=None,
shared_network=None,
router_external=None,
@@ -104,7 +105,8 @@
segments=None):
# update a network that has been created during class setup
- net_id = self.admin_network['id']
+ if not net_id:
+ net_id = self.admin_network['id']
post_body = {}
updated_network = None
@@ -180,20 +182,6 @@
@rbac_rule_validation.action(
service="neutron",
- rule="create_network:provider:physical_network")
- @decorators.idempotent_id('f458033b-2d52-4fd1-86db-e31e111d6fac')
- def test_create_network_provider_physical_network(self):
-
- """Create Provider Physical Network Test
-
- RBAC test for the neutron create_network:provider:physical_network
- """
- rbac_utils.switch_role(self, switchToRbacRole=True)
- self._create_network(provider_network_type='flat',
- provider_physical_network='ph-eth0')
-
- @rbac_rule_validation.action(
- service="neutron",
rule="create_network:provider:segmentation_id")
@decorators.idempotent_id('b9decb7b-68ef-4504-b99b-41edbf7d2af5')
def test_create_network_provider_segmentation_id(self):
@@ -249,13 +237,9 @@
RBAC test for the neutron update_network:router:external policy
"""
+ network = self._create_network()
rbac_utils.switch_role(self, switchToRbacRole=True)
- updated_network = self._update_network(router_external=True)
- self.assertEqual(updated_network['router:external'], True)
-
- # Revert back to False
- updated_network = self._update_network(router_external=False)
- self.assertEqual(updated_network['router:external'], False)
+ self._update_network(net_id=network['id'], router_external=True)
@rbac_rule_validation.action(service="neutron",
rule="get_network")
diff --git a/patrole_tempest_plugin/tests/api/network/test_ports_rbac.py b/patrole_tempest_plugin/tests/api/network/test_ports_rbac.py
new file mode 100644
index 0000000..207ae54
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/network/test_ports_rbac.py
@@ -0,0 +1,358 @@
+# Copyright 2017 AT&T Corporation.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+import netaddr
+import random
+
+from oslo_log import log
+from tempest import config
+from tempest.lib.common.utils import data_utils
+from tempest.lib.common.utils import test_utils
+from tempest.lib import decorators
+from tempest.lib import exceptions
+
+from patrole_tempest_plugin import rbac_exceptions
+from patrole_tempest_plugin import rbac_rule_validation
+from patrole_tempest_plugin.rbac_utils import rbac_utils
+from patrole_tempest_plugin.tests.api.network import rbac_base as base
+
+CONF = config.CONF
+LOG = log.getLogger(__name__)
+
+
+class PortsRbacTest(base.BaseNetworkRbacTest):
+
+ @classmethod
+ def resource_setup(cls):
+ super(PortsRbacTest, cls).resource_setup()
+ cls.admin_network = cls.create_network()
+
+ # Create a subnet by admin user
+ cls.cidr = netaddr.IPNetwork(CONF.network.project_network_cidr)
+
+ cls.admin_subnet = cls.create_subnet(cls.admin_network,
+ cidr=cls.cidr,
+ mask_bits=24)
+ cls.admin_ip_range = netaddr.IPRange(
+ cls.admin_subnet['allocation_pools'][0]['start'],
+ cls.admin_subnet['allocation_pools'][0]['end'])
+
+ # Create a port by admin user
+ body = cls.ports_client.create_port(network_id=cls.admin_network['id'])
+ cls.admin_port = body['port']
+ cls.ports.append(cls.admin_port)
+ ipaddr = cls.admin_port['fixed_ips'][0]['ip_address']
+ cls.admin_port_ip_address = ipaddr
+ cls.admin_port_mac_address = cls.admin_port['mac_address']
+
+ def _create_port(self, **post_body):
+
+ body = self.ports_client.create_port(**post_body)
+ port = body['port']
+
+ # Schedule port deletion with verification upon test completion
+ self.addCleanup(test_utils.call_and_ignore_notfound_exc,
+ self.ports_client.delete_port,
+ port['id'])
+
+ return port
+
+ def tearDown(self):
+ rbac_utils.switch_role(self, switchToRbacRole=False)
+ super(PortsRbacTest, self).tearDown()
+
+ @rbac_rule_validation.action(service="neutron",
+ rule="create_port")
+ @decorators.idempotent_id('0ec8c551-625c-4864-8a52-85baa7c40f22')
+ def test_create_port(self):
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ post_body = {'network_id': self.admin_network['id']}
+ self._create_port(**post_body)
+
+ @rbac_rule_validation.action(service="neutron",
+ rule="create_port:binding:host_id")
+ @decorators.idempotent_id('a54bd6b8-a7eb-4101-bfe8-093930b0d660')
+ def test_create_port_binding_host_id(self):
+
+ post_body = {'network_id': self.admin_network['id'],
+ 'binding:host_id': "rbac_test_host"}
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self._create_port(**post_body)
+
+ @rbac_rule_validation.action(service="neutron",
+ rule="create_port:fixed_ips")
+ @decorators.idempotent_id('2551e10d-006a-413c-925a-8c6f834c09ac')
+ def test_create_port_fixed_ips(self):
+ # Pick an ip address within the allocation_pools range
+ ip_address = random.choice(list(self.admin_ip_range))
+
+ fixed_ips = [{'ip_address': ip_address},
+ {'subnet_id': self.admin_subnet['id']}]
+
+ post_body = {'network_id': self.admin_network['id'],
+ 'fixed_ips': fixed_ips}
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self._create_port(**post_body)
+
+ @rbac_rule_validation.action(service="neutron",
+ rule="create_port:mac_address")
+ @decorators.idempotent_id('aee6d0be-a7f3-452f-aefc-796b4eb9c9a8')
+ def test_create_port_mac_address(self):
+
+ post_body = {'network_id': self.admin_network['id'],
+ 'mac_address': data_utils.rand_mac_address()}
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self._create_port(**post_body)
+
+ @rbac_rule_validation.action(service="neutron",
+ rule="create_port:binding:profile")
+ @decorators.idempotent_id('98fa38ab-c2ed-46a0-99f0-59f18cbd257a')
+ def test_create_port_binding_profile(self):
+
+ binding_profile = {"foo": "1"}
+
+ post_body = {'network_id': self.admin_network['id'],
+ 'binding:profile': binding_profile}
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self._create_port(**post_body)
+
+ @rbac_rule_validation.action(service="neutron",
+ rule="create_port:allowed_address_pairs")
+ @decorators.idempotent_id('b638d1f4-d903-4ca8-aa2a-6fd603c5ec3a')
+ def test_create_port_allowed_address_pairs(self):
+
+ # Create port with allowed address pair attribute
+ allowed_address_pairs = [{'ip_address': self.admin_port_ip_address,
+ 'mac_address': self.admin_port_mac_address}]
+
+ post_body = {'network_id': self.admin_network['id'],
+ 'allowed_address_pairs': allowed_address_pairs}
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self._create_port(**post_body)
+
+ @rbac_rule_validation.action(service="neutron", rule="get_port")
+ @decorators.idempotent_id('a9d41cb8-78a2-4b97-985c-44e4064416f4')
+ def test_show_port(self):
+
+ try:
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+
+ self.ports_client.show_port(self.admin_port['id'])
+
+ except exceptions.NotFound as e:
+ LOG.info("NotFound exception caught. Exception is thrown when "
+ "role doesn't have access to the endpoint."
+ "This is irregular and should be fixed.")
+ raise rbac_exceptions.RbacActionFailed(e)
+
+ @rbac_rule_validation.action(service="neutron",
+ rule="get_port:binding:vif_type")
+ @decorators.idempotent_id('125aff0b-8fed-4f8e-8410-338616594b06')
+ def test_show_port_binding_vif_type(self):
+
+ # Verify specific fields of a port
+ fields = ['binding:vif_type']
+
+ try:
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.ports_client.show_port(self.admin_port['id'],
+ fields=fields)
+
+ except exceptions.NotFound as e:
+ LOG.info("NotFound exception caught. Exception is thrown when "
+ "role doesn't have access to the endpoint."
+ "This is irregular and should be fixed.")
+ raise rbac_exceptions.RbacActionFailed(e)
+
+ @rbac_rule_validation.action(service="neutron",
+ rule="get_port:binding:vif_details")
+ @decorators.idempotent_id('e42bfd77-fcce-45ee-9728-3424300f0d6f')
+ def test_show_port_binding_vif_details(self):
+
+ # Verify specific fields of a port
+ fields = ['binding:vif_details']
+
+ try:
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.ports_client.show_port(self.admin_port['id'],
+ fields=fields)
+
+ except exceptions.NotFound as e:
+ LOG.info("NotFound exception caught. Exception is thrown when "
+ "role doesn't have access to the endpoint."
+ "This is irregular and should be fixed.")
+ raise rbac_exceptions.RbacActionFailed(e)
+
+ @rbac_rule_validation.action(service="neutron",
+ rule="get_port:binding:host_id")
+ @decorators.idempotent_id('8e61bcdc-6f81-443c-833e-44410266551e')
+ def test_show_port_binding_host_id(self):
+
+ # Verify specific fields of a port
+ fields = ['binding:host_id']
+ post_body = {'network_id': self.admin_network['id'],
+ 'binding:host_id': data_utils.rand_name('host-id')}
+ port = self._create_port(**post_body)
+
+ try:
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.ports_client.show_port(port['id'],
+ fields=fields)
+
+ except exceptions.NotFound as e:
+ LOG.info("NotFound exception caught. Exception is thrown when "
+ "role doesn't have access to the endpoint."
+ "This is irregular and should be fixed.")
+ raise rbac_exceptions.RbacActionFailed(e)
+
+ @rbac_rule_validation.action(service="neutron",
+ rule="get_port:binding:profile")
+ @decorators.idempotent_id('d497cea9-c4ad-42e0-acc9-8d257d6b01fc')
+ def test_show_port_binding_profile(self):
+
+ # Verify specific fields of a port
+ fields = ['binding:profile']
+ binding_profile = {"foo": "1"}
+ post_body = {'network_id': self.admin_network['id'],
+ 'binding:profile': binding_profile}
+ port = self._create_port(**post_body)
+
+ try:
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.ports_client.show_port(port['id'],
+ fields=fields)
+
+ except exceptions.NotFound as e:
+ LOG.info("NotFound exception caught. Exception is thrown when "
+ "role doesn't have access to the endpoint."
+ "This is irregular and should be fixed.")
+ raise rbac_exceptions.RbacActionFailed(e)
+
+ @rbac_rule_validation.action(service="neutron",
+ rule="update_port")
+ @decorators.idempotent_id('afa80981-3c59-42fd-9531-3bcb2cd03711')
+ def test_update_port(self):
+
+ port = self.create_port(self.admin_network)
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.ports_client.update_port(port['id'],
+ admin_state_up=False)
+
+ @rbac_rule_validation.action(service="neutron",
+ rule="update_port:mac_address")
+ @decorators.idempotent_id('507140c8-7b14-4d63-b627-2103691d887e')
+ def test_update_port_mac_address(self):
+
+ port = self.create_port(self.admin_network)
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.ports_client.update_port(
+ port['id'],
+ mac_address=data_utils.rand_mac_address())
+
+ @rbac_rule_validation.action(service="neutron",
+ rule="update_port:fixed_ips")
+ @decorators.idempotent_id('c091c825-532b-4c6f-a14f-affd3259c1c3')
+ def test_update_port_fixed_ips(self):
+
+ # Pick an ip address within the allocation_pools range
+ ip_address = random.choice(list(self.admin_ip_range))
+ fixed_ips = [{'ip_address': ip_address}]
+ post_body = {'network_id': self.admin_network['id']}
+ port = self._create_port(**post_body)
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.ports_client.update_port(port['id'],
+ fixed_ips=fixed_ips)
+
+ @rbac_rule_validation.action(service="neutron",
+ rule="update_port:port_security_enabled")
+ @decorators.idempotent_id('795541af-6652-4e35-9581-fd58224f7545')
+ def test_update_port_security_enabled(self):
+
+ port = self.create_port(self.admin_network)
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.ports_client.update_port(port['id'],
+ security_groups=[])
+
+ @rbac_rule_validation.action(service="neutron",
+ rule="update_port:binding:host_id")
+ @decorators.idempotent_id('24206a72-0d90-4712-918c-5c9a1ebef64d')
+ def test_update_port_binding_host_id(self):
+
+ post_body = {'network_id': self.admin_network['id'],
+ 'binding:host_id': 'rbac_test_host'}
+ port = self._create_port(**post_body)
+
+ updated_body = {'port_id': port['id'],
+ 'binding:host_id': 'rbac_test_host_updated'}
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.ports_client.update_port(**updated_body)
+
+ @rbac_rule_validation.action(service="neutron",
+ rule="update_port:binding:profile")
+ @decorators.idempotent_id('990ea8d1-9257-4f71-a3bf-d6d0914625c5')
+ def test_update_port_binding_profile(self):
+
+ binding_profile = {"foo": "1"}
+ post_body = {'network_id': self.admin_network['id'],
+ 'binding:profile': binding_profile}
+
+ port = self._create_port(**post_body)
+
+ new_binding_profile = {"foo": "2"}
+ updated_body = {'port_id': port['id'],
+ 'binding:profile': new_binding_profile}
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.ports_client.update_port(**updated_body)
+
+ @rbac_rule_validation.action(service="neutron",
+ rule="update_port:allowed_address_pairs")
+ @decorators.idempotent_id('729c2151-bb49-4f4f-9d58-3ed8819b7582')
+ def test_update_port_allowed_address_pairs(self):
+
+ ip_address = random.choice(list(self.admin_ip_range))
+ # Update allowed address pair attribute of port
+ address_pairs = [{'ip_address': ip_address,
+ 'mac_address': data_utils.rand_mac_address()}]
+ post_body = {'network_id': self.admin_network['id']}
+ port = self._create_port(**post_body)
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.ports_client.update_port(port['id'],
+ allowed_address_pairs=address_pairs)
+
+ @rbac_rule_validation.action(service="neutron",
+ rule="delete_port")
+ @decorators.idempotent_id('1cf8e582-bc09-46cb-b32a-82bf991ad56f')
+ def test_delete_port(self):
+
+ try:
+ port = self._create_port(network_id=self.admin_network['id'])
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.ports_client.delete_port(port['id'])
+
+ except exceptions.NotFound as e:
+ LOG.info("NotFound exception caught. Exception is thrown when "
+ "role doesn't have access to the endpoint."
+ "This is irregular and should be fixed.")
+ raise rbac_exceptions.RbacActionFailed(e)
diff --git a/patrole_tempest_plugin/tests/api/network/test_routers_rbac.py b/patrole_tempest_plugin/tests/api/network/test_routers_rbac.py
new file mode 100644
index 0000000..662eb41
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/network/test_routers_rbac.py
@@ -0,0 +1,292 @@
+# Copyright 2017 AT&T Corporation.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import netaddr
+import random
+
+from oslo_log import log
+from tempest import config
+from tempest.lib.common.utils import data_utils
+from tempest.lib.common.utils import test_utils
+from tempest.lib import decorators
+from tempest.lib import exceptions
+from tempest import test
+
+from patrole_tempest_plugin import rbac_exceptions
+from patrole_tempest_plugin import rbac_rule_validation
+from patrole_tempest_plugin.rbac_utils import rbac_utils
+from patrole_tempest_plugin.tests.api.network import rbac_base as base
+
+CONF = config.CONF
+LOG = log.getLogger(__name__)
+
+
+class RouterRbacTest(base.BaseNetworkRbacTest):
+ @classmethod
+ def skip_checks(cls):
+ super(RouterRbacTest, cls).skip_checks()
+ if not test.is_extension_enabled('router', 'network'):
+ msg = "router extension not enabled."
+ raise cls.skipException(msg)
+
+ @classmethod
+ def resource_setup(cls):
+ super(RouterRbacTest, cls).resource_setup()
+ post_body = {}
+ post_body['router:external'] = True
+ cls.admin_network = cls.create_network(**post_body)
+ cls.admin_subnet = cls.create_subnet(cls.admin_network)
+ cls.admin_ip_range = netaddr.IPRange(
+ cls.admin_subnet['allocation_pools'][0]['start'],
+ cls.admin_subnet['allocation_pools'][0]['end'])
+ cls.admin_router = cls.create_router()
+
+ def tearDown(self):
+ rbac_utils.switch_role(self, switchToRbacRole=False)
+ super(RouterRbacTest, self).tearDown()
+
+ @rbac_rule_validation.action(service="neutron",
+ rule="create_router")
+ @decorators.idempotent_id('acc5005c-bdb6-4192-bc9f-ece9035bb488')
+ def test_create_router(self):
+ """Create Router
+
+ RBAC test for the neutron create_router policy
+ """
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ router = self.routers_client.create_router()
+ self.addCleanup(self.routers_client.delete_router,
+ router['router']['id'])
+
+ @rbac_rule_validation.action(
+ service="neutron",
+ rule="create_router:external_gateway_info:enable_snat")
+ @decorators.idempotent_id('3c5acd49-0ec7-4109-ab51-640557b48ebc')
+ def test_create_router_enable_snat(self):
+ """Create Router Snat
+
+ RBAC test for the neutron
+ create_router:external_gateway_info:enable_snat policy
+ """
+ name = data_utils.rand_name('snat-router')
+ external_gateway_info = {'network_id': self.admin_network['id'],
+ 'enable_snat': True}
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ router = self.routers_client.create_router(
+ name=name, external_gateway_info=external_gateway_info)
+ self.addCleanup(self.routers_client.delete_router,
+ router['router']['id'])
+
+ @rbac_rule_validation.action(
+ service="neutron",
+ rule="create_router:external_gateway_info:external_fixed_ips")
+ @decorators.idempotent_id('d0354369-a040-4349-b869-645c8aed13cd')
+ def test_create_router_external_fixed_ips(self):
+ """Create Router Fixed IPs
+
+ RBAC test for the neutron
+ create_router:external_gateway_info:external_fixed_ips policy
+ """
+ name = data_utils.rand_name('snat-router')
+ # Pick an ip address within the allocation_pools range
+ ip_address = random.choice(list(self.admin_ip_range))
+ external_fixed_ips = {'subnet_id': self.admin_subnet['id'],
+ 'ip_address': ip_address}
+
+ external_gateway_info = {'network_id': self.admin_network['id'],
+ 'enable_snat': False,
+ 'external_fixed_ips': [external_fixed_ips]}
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ router = self.routers_client.create_router(
+ name=name, external_gateway_info=external_gateway_info)
+ self.addCleanup(self.routers_client.delete_router,
+ router['router']['id'])
+
+ @rbac_rule_validation.action(service="neutron", rule="get_router")
+ @decorators.idempotent_id('bfbdbcff-f115-4d3e-8cd5-6ada33fd0e21')
+ def test_show_router(self):
+ """Get Router
+
+ RBAC test for the neutron get_router policy
+ """
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ try:
+ self.routers_client.show_router(self.admin_router['id'])
+ except exceptions.NotFound as e:
+ LOG.info("NotFound exception caught. Exception is thrown when "
+ "role doesn't have access to the endpoint."
+ "This is irregular and should be fixed.")
+ raise rbac_exceptions.RbacActionFailed(e)
+
+ @rbac_rule_validation.action(
+ service="neutron", rule="update_router")
+ @decorators.idempotent_id('3d182f4e-0023-4218-9aa0-ea2b0ae0bd7a')
+ def test_update_router(self):
+ """Update Router
+
+ RBAC test for the neutron update_router policy
+ """
+ new_name = data_utils.rand_name('new-router-name')
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.routers_client.update_router(self.admin_router['id'],
+ name=new_name)
+
+ @rbac_rule_validation.action(
+ service="neutron", rule="update_router:external_gateway_info")
+ @decorators.idempotent_id('5a6ae104-a9c3-4b56-8622-e1a0a0194474')
+ def test_update_router_external_gateway_info(self):
+ """Update Router External Gateway Info
+
+ RBAC test for the neutron
+ update_router:external_gateway_info policy
+ """
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.routers_client.update_router(self.admin_router['id'],
+ external_gateway_info={})
+
+ @rbac_rule_validation.action(
+ service="neutron",
+ rule="update_router:external_gateway_info:network_id")
+ @decorators.idempotent_id('f1fc5a23-e3d8-44f0-b7bc-47006ad9d3d4')
+ def test_update_router_external_gateway_info_network_id(self):
+ """Update Router External Gateway Info Network Id
+
+ RBAC test for the neutron
+ update_router:external_gateway_info:network_id policy
+ """
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.routers_client.update_router(
+ self.admin_router['id'],
+ external_gateway_info={'network_id': self.admin_network['id']})
+
+ @rbac_rule_validation.action(
+ service="neutron",
+ rule="update_router:external_gateway_info:enable_snat")
+ @decorators.idempotent_id('515a2954-3d79-4695-aeb9-d1c222765840')
+ def test_update_router_enable_snat(self):
+ """Update Router External Gateway Info Enable Snat
+
+ RBAC test for the neutron
+ update_router:external_gateway_info:enable_snat policy
+ """
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.routers_client.update_router(
+ self.admin_router['id'],
+ external_gateway_info={'network_id': self.admin_network['id'],
+ 'enable_snat': True})
+
+ @rbac_rule_validation.action(
+ service="neutron",
+ rule="update_router:external_gateway_info:external_fixed_ips")
+ @decorators.idempotent_id('f429e5ee-8f0a-4667-963e-72dd95d5adee')
+ def test_update_router_external_fixed_ips(self):
+ """Update Router External Gateway Info External Fixed Ips
+
+ RBAC test for the neutron
+ update_router:external_gateway_info:external_fixed_ips policy
+ """
+ # Pick an ip address within the allocation_pools range
+ ip_address = random.choice(list(self.admin_ip_range))
+ external_fixed_ips = {'subnet_id': self.admin_subnet['id'],
+ 'ip_address': ip_address}
+ external_gateway_info = {'network_id': self.admin_network['id'],
+ 'external_fixed_ips': [external_fixed_ips]}
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.routers_client.update_router(
+ self.admin_router['id'],
+ external_gateway_info=external_gateway_info)
+ self.addCleanup(
+ self.routers_client.update_router,
+ self.admin_router['id'],
+ external_gateway_info=None)
+
+ @rbac_rule_validation.action(service="neutron",
+ rule="delete_router")
+ @decorators.idempotent_id('c0634dd5-0467-48f7-a4ae-1014d8edb2a7')
+ def test_delete_router(self):
+ """Delete Router
+
+ RBAC test for the neutron delete_router policy
+ """
+ router = self.create_router()
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ try:
+ self.routers_client.delete_router(router['id'])
+ except exceptions.NotFound as e:
+ LOG.info("NotFound exception caught. Exception is thrown when "
+ "role doesn't have access to the endpoint."
+ "This is irregular and should be fixed.")
+ raise rbac_exceptions.RbacActionFailed(e)
+
+ @rbac_rule_validation.action(service="neutron",
+ rule="add_router_interface")
+ @decorators.idempotent_id('a0627778-d68d-4913-881b-e345360cca19')
+ def test_add_router_interfaces(self):
+ """Add Router Interface
+
+ RBAC test for the neutron add_router_interface policy
+ """
+ network = self.create_network()
+ subnet = self.create_subnet(network)
+ router = self.create_router()
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ try:
+ self.routers_client.add_router_interface(
+ router['id'], subnet_id=subnet['id'])
+ self.addCleanup(
+ test_utils.call_and_ignore_notfound_exc,
+ self.routers_client.remove_router_interface,
+ router['id'],
+ subnet_id=subnet['id'])
+ except exceptions.NotFound as e:
+ LOG.info("NotFound exception caught. Exception is thrown when "
+ "role doesn't have access to the endpoint."
+ "This is irregular and should be fixed.")
+ raise rbac_exceptions.RbacActionFailed(e)
+
+ @rbac_rule_validation.action(service="neutron",
+ rule="remove_router_interface")
+ @decorators.idempotent_id('ff2593a4-2bff-4c27-97d3-dd3702b27dfb')
+ def test_remove_router_interfaces(self):
+ """Remove Router Interface
+
+ RBAC test for the neutron remove_router_interface policy
+ """
+ network = self.create_network()
+ subnet = self.create_subnet(network)
+ router = self.create_router()
+
+ self.routers_client.add_router_interface(
+ router['id'], subnet_id=subnet['id'])
+
+ self.addCleanup(test_utils.call_and_ignore_notfound_exc,
+ self.routers_client.remove_router_interface,
+ router['id'],
+ subnet_id=subnet['id'])
+
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ try:
+ self.routers_client.remove_router_interface(
+ router['id'],
+ subnet_id=subnet['id'])
+ except exceptions.NotFound as e:
+ LOG.info("NotFound exception caught. Exception is thrown when "
+ "role doesn't have access to the endpoint."
+ "This is irregular and should be fixed.")
+ raise rbac_exceptions.RbacActionFailed(e)
diff --git a/patrole_tempest_plugin/tests/api/volume/test_volume_transfers_rbac.py b/patrole_tempest_plugin/tests/api/volume/test_volume_transfers_rbac.py
index f88d44f..485844f 100644
--- a/patrole_tempest_plugin/tests/api/volume/test_volume_transfers_rbac.py
+++ b/patrole_tempest_plugin/tests/api/volume/test_volume_transfers_rbac.py
@@ -54,22 +54,24 @@
waiters.wait_for_volume_status(self.client, self.volume['id'],
'available')
+ def _create_transfer(self):
+ transfer = self.client.create_volume_transfer(
+ volume_id=self.volume['id'])['transfer']
+ self.addCleanup(self._delete_transfer, transfer)
+ return transfer
+
@rbac_rule_validation.action(service="cinder",
rule="volume:create_transfer")
@decorators.idempotent_id('25413af4-468d-48ff-94ca-4436f8526b3e')
def test_create_volume_transfer(self):
rbac_utils.switch_role(self, switchToRbacRole=True)
- transfer = self.client.create_volume_transfer(
- volume_id=self.volume['id'])['transfer']
- self.addCleanup(self._delete_transfer, transfer)
+ self._create_transfer()
@rbac_rule_validation.action(service="cinder",
- rule="volume:get_all_transfers")
+ rule="volume:get_transfer")
@decorators.idempotent_id('7a0925d3-ed97-4c25-8299-e5cdabe2eb55')
def test_get_volume_transfer(self):
- transfer = self.client.create_volume_transfer(
- volume_id=self.volume['id'])['transfer']
- self.addCleanup(self._delete_transfer, transfer)
+ transfer = self._create_transfer()
rbac_utils.switch_role(self, switchToRbacRole=True)
self.client.show_volume_transfer(transfer['id'])
@@ -84,13 +86,19 @@
rule="volume:accept_transfer")
@decorators.idempotent_id('987f2a11-d657-4984-a6c9-28f06c1cd014')
def test_accept_volume_transfer(self):
- transfer = self.client.create_volume_transfer(
- volume_id=self.volume['id'])['transfer']
- self.addCleanup(self._delete_transfer, transfer)
+ transfer = self._create_transfer()
rbac_utils.switch_role(self, switchToRbacRole=True)
self.client.accept_volume_transfer(transfer['id'],
auth_key=transfer['auth_key'])
+ @rbac_rule_validation.action(service="cinder",
+ rule="volume:delete_transfer")
+ @decorators.idempotent_id('4672187e-7fff-454b-832a-5c8865dda868')
+ def test_delete_volume_transfer(self):
+ transfer = self._create_transfer()
+ rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.client.delete_volume_transfer(transfer['id'])
+
class VolumesTransfersV3RbacTest(VolumesTransfersRbacTest):
_api_version = 3
diff --git a/patrole_tempest_plugin/tests/api/volume/test_volumes_rbac.py b/patrole_tempest_plugin/tests/api/volume/test_volumes_rbac.py
index 5d889e8..093e2bc 100644
--- a/patrole_tempest_plugin/tests/api/volume/test_volumes_rbac.py
+++ b/patrole_tempest_plugin/tests/api/volume/test_volumes_rbac.py
@@ -46,7 +46,7 @@
# Test volume reset status : available->error->available
rbac_utils.switch_role(self, switchToRbacRole=True)
self.client.reset_volume_status(volume['id'], status='error')
- self.client.reset_volume_status(volume['id'], status='availble')
+ self.client.reset_volume_status(volume['id'], status='available')
@rbac_rule_validation.action(
service="cinder",