Merge "Roles RBAC test for Keystone API v2 roles"
diff --git a/patrole_tempest_plugin/rbac_auth.py b/patrole_tempest_plugin/rbac_auth.py
index 1afc7ae..40a46a7 100644
--- a/patrole_tempest_plugin/rbac_auth.py
+++ b/patrole_tempest_plugin/rbac_auth.py
@@ -15,15 +15,15 @@
 
 from oslo_log import log as logging
 
-from patrole_tempest_plugin import rbac_role_converter
+from patrole_tempest_plugin import rbac_policy_parser
 
 LOG = logging.getLogger(__name__)
 
 
 class RbacAuthority(object):
     def __init__(self, tenant_id, service=None):
-        self.converter = rbac_role_converter.RbacPolicyConverter(tenant_id,
-                                                                 service)
+        self.converter = rbac_policy_parser.RbacPolicyParser(tenant_id,
+                                                             service)
 
     def get_permission(self, rule_name, role):
         try:
diff --git a/patrole_tempest_plugin/rbac_role_converter.py b/patrole_tempest_plugin/rbac_policy_parser.py
similarity index 97%
rename from patrole_tempest_plugin/rbac_role_converter.py
rename to patrole_tempest_plugin/rbac_policy_parser.py
index bc6e006..860a53d 100644
--- a/patrole_tempest_plugin/rbac_role_converter.py
+++ b/patrole_tempest_plugin/rbac_policy_parser.py
@@ -19,15 +19,13 @@
 from oslo_log import log as logging
 from oslo_policy import generator
 from oslo_policy import policy
-from tempest import config
 
 from patrole_tempest_plugin import rbac_exceptions
 
-CONF = config.CONF
 LOG = logging.getLogger(__name__)
 
 
-class RbacPolicyConverter(object):
+class RbacPolicyParser(object):
     """A class for parsing policy rules into lists of allowed roles.
 
     RBAC testing requires that each rule in a policy file be broken up into
@@ -38,7 +36,7 @@
     """
 
     def __init__(self, tenant_id, service, path=None):
-        """Initialization of Policy Converter.
+        """Initialization of Rbac Policy Parser.
 
         Parses a policy file to create a dictionary, mapping policy actions to
         roles. If a policy file does not exist, checks whether the policy file
@@ -161,5 +159,5 @@
             LOG.debug("{0} not found in policy file.".format(apply_rule))
             return False
         except Exception as e:
-            LOG.debug("Exception: {0} for rule: {1}.".format(e, rule))
+            LOG.debug("Exception: {0} for rule: {1}.".format(e, apply_rule))
             return False
diff --git a/patrole_tempest_plugin/tests/api/compute/test_assisted_volume_snapshot_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_assisted_volume_snapshot_rbac.py
new file mode 100644
index 0000000..6e0680a
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/compute/test_assisted_volume_snapshot_rbac.py
@@ -0,0 +1,79 @@
+# 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 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
+
+from tempest.lib.common.utils import data_utils
+from tempest.lib import decorators
+
+
+class AssistedVolumeSnapshotRbacTest(rbac_base.BaseV2ComputeRbacTest):
+    """Assisted volume snapshot tests.
+
+    Test class for create and delete
+    """
+
+    @classmethod
+    def setup_clients(cls):
+        """Setup clients."""
+        super(AssistedVolumeSnapshotRbacTest, cls).setup_clients()
+        cls.client = cls.servers_client
+
+    def tearDown(self):
+        """Cleanup and reset RBAC role."""
+        rbac_utils.switch_role(self, switchToRbacRole=False)
+        super(AssistedVolumeSnapshotRbacTest, self).tearDown()
+
+    def _create_and_attach(self):
+        self.server = self.create_test_server(wait_until='ACTIVE')
+        self.volume = self.create_volume()
+        self.attachment = self.attach_volume(
+            self.server, self.volume)
+
+    @decorators.skip_because(bug="1668407")
+    @decorators.idempotent_id('74f64957-912d-4537-983b-cea4a31c5c9f')
+    @rbac_rule_validation.action(
+        service="nova",
+        rule="os_compute_api:os-assisted-volume-snapshots:create")
+    def test_assisted_volume_snapshot_create(self):
+        """Create Role Test.
+
+        RBAC test for assisted volume snapshot role-create
+        """
+        self._create_and_attach()
+        rbac_utils.switch_role(self, switchToRbacRole=True)
+        self.assisted_volume_snapshot_client.\
+            create_volume_attachments(self.volume['id'],
+                                      data_utils.rand_uuid())
+
+    @decorators.skip_because(bug="1668407")
+    @decorators.idempotent_id('01323040-c5df-4e15-8b1a-3df98fa7d998')
+    @rbac_rule_validation.action(
+        service="nova",
+        rule="os_compute_api:os-assisted-volume-snapshots:delete")
+    def test_assisted_volume_snapshot_delete(self):
+        """Delete Role Test.
+
+        RBAC test for assisted volume snapshot role-delete
+        """
+        self._create_and_attach()
+        snapshot_id = data_utils.rand_uuid()
+        self.assisted_volume_snapshot_client.\
+            create_volume_attachments(self.volume['id'], snapshot_id)
+        rbac_utils.switch_role(self, switchToRbacRole=True)
+        self.assisted_volume_snapshot_client.\
+            delete_volume_attachments(snapshot_id, self.volume['id'])
diff --git a/patrole_tempest_plugin/tests/api/compute/test_config_drive_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_config_drive_rbac.py
new file mode 100644
index 0000000..ed4edfd
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/compute/test_config_drive_rbac.py
@@ -0,0 +1,53 @@
+#    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 ConfigDriveRbacTest(rbac_base.BaseV2ComputeRbacTest):
+
+    @classmethod
+    def setup_clients(cls):
+        super(ConfigDriveRbacTest, cls).setup_clients()
+        cls.client = cls.servers_client
+
+    @classmethod
+    def skip_checks(cls):
+        super(ConfigDriveRbacTest, cls).skip_checks()
+        if not test.is_extension_enabled('os-config-drive', 'compute'):
+            msg = "%s skipped as os-config-drive extension not enabled." \
+                  % cls.__name__
+            raise cls.skipException(msg)
+
+    def tearDown(self):
+        rbac_utils.switch_role(self, switchToRbacRole=False)
+        super(ConfigDriveRbacTest, self).tearDown()
+
+    @decorators.idempotent_id('55c62ef7-b72b-4970-acc6-05b0a4316e5d')
+    @rbac_rule_validation.action(
+        service="nova",
+        rule="os_compute_api:os-config-drive")
+    def test_create_test_server_with_config_drive(self):
+        rbac_utils.switch_role(self, switchToRbacRole=True)
+        # NOTE(felipemonteiro): This policy action is always enforced,
+        # regardless whether the config_drive flag is set to true or false.
+        # However, it has been explicitly set to true below, in case that this
+        # behavior ever changes in the future.
+        self.create_test_server(config_drive=True)
diff --git a/patrole_tempest_plugin/tests/api/compute/test_hypervisor_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_hypervisor_rbac.py
index e495b7d..e50bb9e 100644
--- a/patrole_tempest_plugin/tests/api/compute/test_hypervisor_rbac.py
+++ b/patrole_tempest_plugin/tests/api/compute/test_hypervisor_rbac.py
@@ -13,15 +13,13 @@
 #    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 HypervisorAdminRbacTest(rbac_base.BaseV2ComputeAdminRbacTest):
 
@@ -33,9 +31,10 @@
     @classmethod
     def skip_checks(cls):
         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__)
+        if not test.is_extension_enabled('os-hypervisors', 'compute'):
+            msg = "%s skipped as os-hypervisors extension not enabled." \
+                  % cls.__name__
+            raise cls.skipException(msg)
 
     def tearDown(self):
         rbac_utils.switch_role(self, switchToRbacRole=False)
@@ -46,4 +45,5 @@
         service="nova",
         rule="os_compute_api:os-hypervisors")
     def test_list_hypervisors(self):
+        rbac_utils.switch_role(self, switchToRbacRole=True)
         self.client.list_hypervisors()['hypervisors']
diff --git a/patrole_tempest_plugin/tests/api/compute/test_server_actions_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_server_actions_rbac.py
new file mode 100644
index 0000000..9e3b259
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/compute/test_server_actions_rbac.py
@@ -0,0 +1,81 @@
+#    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 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 ServerActionsRbacTest(rbac_base.BaseV2ComputeRbacTest):
+
+    def tearDown(self):
+        rbac_utils.switch_role(self, switchToRbacRole=False)
+        super(ServerActionsRbacTest, self).tearDown()
+
+    @classmethod
+    def setup_clients(cls):
+        super(ServerActionsRbacTest, cls).setup_clients()
+        cls.client = cls.servers_client
+
+    @classmethod
+    def skip_checks(cls):
+        super(ServerActionsRbacTest, 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__)
+
+    @classmethod
+    def resource_setup(cls):
+        cls.set_validation_resources()
+        super(ServerActionsRbacTest, cls).resource_setup()
+        cls.server_id = cls.create_test_server(wait_until='ACTIVE',
+                                               validatable=True)['id']
+
+    def _test_start_server(self):
+        self.client.start_server(self.server_id)
+        waiters.wait_for_server_status(self.client, self.server_id,
+                                       'ACTIVE')
+
+    def _test_stop_server(self):
+        self.client.stop_server(self.server_id)
+        waiters.wait_for_server_status(self.client, self.server_id,
+                                       'SHUTOFF')
+
+    @rbac_rule_validation.action(
+        service="nova",
+        rule="os_compute_api:servers:stop")
+    @decorators.idempotent_id('ab4a17d2-166f-4a6d-9944-f17baa576cf2')
+    def test_stop_server(self):
+        rbac_utils.switch_role(self, switchToRbacRole=True)
+        self._test_stop_server()
+
+    @rbac_rule_validation.action(
+        service="nova",
+        rule="os_compute_api:servers:start")
+    @decorators.idempotent_id('8876bfa9-4d10-406e-a335-a57e451abb12')
+    def test_start_server(self):
+        self._test_stop_server()
+        rbac_utils.switch_role(self, switchToRbacRole=True)
+        self._test_start_server()
diff --git a/patrole_tempest_plugin/tests/api/compute/test_server_password_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_server_password_rbac.py
new file mode 100644
index 0000000..8dd2a64
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/compute/test_server_password_rbac.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.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 ServerPasswordRbacTest(rbac_base.BaseV2ComputeRbacTest):
+
+    @classmethod
+    def setup_clients(cls):
+        super(ServerPasswordRbacTest, cls).setup_clients()
+        cls.client = cls.servers_client
+
+    @classmethod
+    def skip_checks(cls):
+        super(ServerPasswordRbacTest, cls).skip_checks()
+        if not test.is_extension_enabled('os-server-password', 'compute'):
+            msg = "%s skipped as os-server-password extension not enabled." \
+                  % cls.__name__
+            raise cls.skipException(msg)
+
+    @classmethod
+    def resource_setup(cls):
+        super(ServerPasswordRbacTest, cls).resource_setup()
+        cls.server = cls.create_test_server()
+
+    def tearDown(self):
+        rbac_utils.switch_role(self, switchToRbacRole=False)
+        super(ServerPasswordRbacTest, self).tearDown()
+
+    @decorators.idempotent_id('43ad7995-2f12-41cd-8ef1-bae9ffc36818')
+    @rbac_rule_validation.action(
+        service="nova",
+        rule="os_compute_api:os-server-password")
+    def test_delete_password(self):
+        rbac_utils.switch_role(self, switchToRbacRole=True)
+        self.client.delete_password(self.server['id'])
diff --git a/patrole_tempest_plugin/tests/api/compute/test_suspend_server_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_suspend_server_rbac.py
new file mode 100644
index 0000000..a546ee6
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/compute/test_suspend_server_rbac.py
@@ -0,0 +1,81 @@
+#    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 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 SuspendServerRbacTest(rbac_base.BaseV2ComputeRbacTest):
+
+    @classmethod
+    def setup_clients(cls):
+        super(SuspendServerRbacTest, cls).setup_clients()
+        cls.client = cls.servers_client
+
+    @classmethod
+    def skip_checks(cls):
+        super(SuspendServerRbacTest, cls).skip_checks()
+        if not CONF.compute_feature_enabled.suspend:
+            msg = "%s skipped as suspend compute feature is not available." \
+                  % cls.__name__
+            raise cls.skipException(msg)
+
+    @classmethod
+    def resource_setup(cls):
+        super(SuspendServerRbacTest, cls).resource_setup()
+        cls.server = cls.create_test_server(wait_until='ACTIVE')
+
+    def tearDown(self):
+        rbac_utils.switch_role(self, switchToRbacRole=False)
+
+        # Guarantee that the server is active during each test run.
+        vm_state = self.client.show_server(self.server['id'])['server'][
+            'OS-EXT-STS:vm_state'].upper()
+        if vm_state != 'ACTIVE':
+            self.client.resume_server(self.server['id'])
+            waiters.wait_for_server_status(self.client, self.server['id'],
+                                           'ACTIVE')
+
+        super(SuspendServerRbacTest, self).tearDown()
+
+    @decorators.idempotent_id('b775930f-237c-431c-83ae-d33ed1b9700b')
+    @rbac_rule_validation.action(
+        service="nova",
+        rule="os_compute_api:os-suspend-server:suspend")
+    def test_suspend_server(self):
+        rbac_utils.switch_role(self, switchToRbacRole=True)
+        self.client.suspend_server(self.server['id'])
+        waiters.wait_for_server_status(self.client, self.server['id'],
+                                       'SUSPENDED')
+
+    @decorators.idempotent_id('4d90bd02-11f8-45b1-a8a1-534665584675')
+    @rbac_rule_validation.action(
+        service="nova",
+        rule="os_compute_api:os-suspend-server:resume")
+    def test_resume_server(self):
+        self.client.suspend_server(self.server['id'])
+        waiters.wait_for_server_status(self.client, self.server['id'],
+                                       'SUSPENDED')
+        rbac_utils.switch_role(self, switchToRbacRole=True)
+        self.client.resume_server(self.server['id'])
+        waiters.wait_for_server_status(self.client, self.server['id'],
+                                       'ACTIVE')
diff --git a/patrole_tempest_plugin/tests/api/identity/v3/test_credentials_rbac.py b/patrole_tempest_plugin/tests/api/identity/v3/test_credentials_rbac.py
index 3428e7f..b1018cd 100644
--- a/patrole_tempest_plugin/tests/api/identity/v3/test_credentials_rbac.py
+++ b/patrole_tempest_plugin/tests/api/identity/v3/test_credentials_rbac.py
@@ -15,7 +15,7 @@
 
 from tempest.common.utils import data_utils
 from tempest.lib.common.utils import test_utils
-from tempest import test
+from tempest.lib import decorators
 
 from patrole_tempest_plugin import rbac_rule_validation
 from patrole_tempest_plugin.rbac_utils import rbac_utils
@@ -52,7 +52,7 @@
 
     @rbac_rule_validation.action(service="keystone",
                                  rule="identity:create_credential")
-    @test.idempotent_id('c1ab6d34-c59f-4ae1-bae9-bb3c1089b48e')
+    @decorators.idempotent_id('c1ab6d34-c59f-4ae1-bae9-bb3c1089b48e')
     def test_create_credential(self):
         """Create a Credential.
 
@@ -63,7 +63,7 @@
 
     @rbac_rule_validation.action(service="keystone",
                                  rule="identity:update_credential")
-    @test.idempotent_id('cfb05ce3-bffb-496e-a3c2-9515d730da63')
+    @decorators.idempotent_id('cfb05ce3-bffb-496e-a3c2-9515d730da63')
     def test_update_credential(self):
         """Update a Credential.
 
@@ -84,7 +84,7 @@
 
     @rbac_rule_validation.action(service="keystone",
                                  rule="identity:delete_credential")
-    @test.idempotent_id('87ab42af-8d41-401b-90df-21e72919fcde')
+    @decorators.idempotent_id('87ab42af-8d41-401b-90df-21e72919fcde')
     def test_delete_credential(self):
         """Delete a Credential.
 
@@ -97,7 +97,7 @@
 
     @rbac_rule_validation.action(service="keystone",
                                  rule="identity:get_credential")
-    @test.idempotent_id('1b6eeae6-f1e8-4cdf-8903-1c002b1fc271')
+    @decorators.idempotent_id('1b6eeae6-f1e8-4cdf-8903-1c002b1fc271')
     def test_show_credential(self):
         """Show/Get a Credential.
 
@@ -110,7 +110,7 @@
 
     @rbac_rule_validation.action(service="keystone",
                                  rule="identity:list_credentials")
-    @test.idempotent_id('3de303e2-12a7-4811-805a-f18906472038')
+    @decorators.idempotent_id('3de303e2-12a7-4811-805a-f18906472038')
     def test_list_credentials(self):
         """List all Credentials.
 
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 f5a0a3e..30ecb7b 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
@@ -15,7 +15,7 @@
 
 from tempest.common.utils import data_utils
 from tempest import config
-from tempest import test
+from tempest.lib import decorators
 
 from patrole_tempest_plugin import rbac_rule_validation
 from patrole_tempest_plugin.rbac_utils import rbac_utils
@@ -33,7 +33,7 @@
 
     @rbac_rule_validation.action(service="keystone",
                                  rule="identity:create_service")
-    @test.idempotent_id('9a4bb317-f0bb-4005-8df0-4b672885b7c8')
+    @decorators.idempotent_id('9a4bb317-f0bb-4005-8df0-4b672885b7c8')
     def test_create_service(self):
         """Create a service.
 
@@ -44,7 +44,7 @@
 
     @rbac_rule_validation.action(service="keystone",
                                  rule="identity:update_service")
-    @test.idempotent_id('b39447d1-2cf6-40e5-a899-46f287f2ecf0')
+    @decorators.idempotent_id('b39447d1-2cf6-40e5-a899-46f287f2ecf0')
     def test_update_service(self):
         """Update a service.
 
@@ -61,7 +61,7 @@
 
     @rbac_rule_validation.action(service="keystone",
                                  rule="identity:delete_service")
-    @test.idempotent_id('177b991a-438d-4bef-8e9f-9c6cc5a1c9e8')
+    @decorators.idempotent_id('177b991a-438d-4bef-8e9f-9c6cc5a1c9e8')
     def test_delete_service(self):
         """Delete a service.
 
@@ -74,7 +74,7 @@
 
     @rbac_rule_validation.action(service="keystone",
                                  rule="identity:get_service")
-    @test.idempotent_id('d89a9ac6-cd53-428d-84c0-5bc71f4a432d')
+    @decorators.idempotent_id('d89a9ac6-cd53-428d-84c0-5bc71f4a432d')
     def test_show_service(self):
         """Show/Get a service.
 
@@ -87,7 +87,7 @@
 
     @rbac_rule_validation.action(service="keystone",
                                  rule="identity:list_services")
-    @test.idempotent_id('706e6bea-3385-4718-919c-0b5121395806')
+    @decorators.idempotent_id('706e6bea-3385-4718-919c-0b5121395806')
     def test_list_services(self):
         """list all services.
 
diff --git a/patrole_tempest_plugin/tests/api/network/test_floating_ips_rbac.py b/patrole_tempest_plugin/tests/api/network/test_floating_ips_rbac.py
new file mode 100644
index 0000000..3b3d5a9
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/network/test_floating_ips_rbac.py
@@ -0,0 +1,154 @@
+# 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
+
+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.network import rbac_base as base
+
+CONF = config.CONF
+LOG = log.getLogger(__name__)
+
+
+class FloatingIpsRbacTest(base.BaseNetworkRbacTest):
+
+    @classmethod
+    def resource_setup(cls):
+        super(FloatingIpsRbacTest, cls).resource_setup()
+
+        # Create an external network for floating ip creation
+        cls.fip_extnet = cls.create_network(**{'router:external': True})
+        cls.fip_extnet_id = cls.fip_extnet['id']
+
+        # Create a subnet for the external network
+        cls.cidr = netaddr.IPNetwork(CONF.network.project_network_cidr)
+        cls.create_subnet(cls.fip_extnet,
+                          cidr=cls.cidr,
+                          mask_bits=24)
+
+    @classmethod
+    def resource_cleanup(cls):
+        # Update router:external attribute to False for proper subnet resource
+        # cleanup by base class
+        cls.networks_client.update_network(cls.fip_extnet_id,
+                                           **{'router:external': False})
+        super(FloatingIpsRbacTest, cls).resource_cleanup()
+
+    def _create_floatingip(self, floating_ip_address=None):
+        if floating_ip_address is not None:
+            body = self.floating_ips_client.create_floatingip(
+                floating_network_id=self.fip_extnet_id,
+                floating_ip_address=floating_ip_address)
+        else:
+            body = self.floating_ips_client.create_floatingip(
+                floating_network_id=self.fip_extnet_id)
+
+        floating_ip = body['floatingip']
+        self.addCleanup(test_utils.call_and_ignore_notfound_exc,
+                        self.floating_ips_client.delete_floatingip,
+                        floating_ip['id'])
+
+        return floating_ip
+
+    def tearDown(self):
+        rbac_utils.switch_role(self, switchToRbacRole=False)
+        super(FloatingIpsRbacTest, self).tearDown()
+
+    @rbac_rule_validation.action(service="neutron",
+                                 rule="create_floatingip")
+    @decorators.idempotent_id('f8f7474c-b8a5-4174-af84-73097d6ced38')
+    def test_create_floating_ip(self):
+        """Create floating IP.
+
+        RBAC test for the neutron create_floatingip policy
+        """
+        rbac_utils.switch_role(self, switchToRbacRole=True)
+        self._create_floatingip()
+
+    @rbac_rule_validation.action(service="neutron",
+                                 rule="create_floatingip:floating_ip_address")
+    @decorators.idempotent_id('a8bb826a-403d-4130-a55d-120a0a660806')
+    def test_create_floating_ip_floatingip_address(self):
+        """Create floating IP with address.
+
+        RBAC test for the neutron create_floatingip:floating_ip_address policy
+        """
+        fip = str(netaddr.IPAddress(self.cidr) + 10)
+
+        rbac_utils.switch_role(self, switchToRbacRole=True)
+        self._create_floatingip(floating_ip_address=fip)
+
+    @rbac_rule_validation.action(service="neutron",
+                                 rule="update_floatingip")
+    @decorators.idempotent_id('2ab1b060-19f8-4ef6-a838-e2ab7b377c63')
+    def test_update_floating_ip(self):
+        """Update floating IP.
+
+        RBAC test for the neutron update_floatingip policy
+        """
+        floating_ip = self._create_floatingip()
+        rbac_utils.switch_role(self, switchToRbacRole=True)
+
+        # Associate floating IP to the other port
+        self.floating_ips_client.update_floatingip(
+            floating_ip['id'], port_id=None)
+
+    @rbac_rule_validation.action(service="neutron", rule="get_floatingip")
+    @decorators.idempotent_id('f8846fd0-c976-48fe-a148-105303931b32')
+    def test_show_floating_ip(self):
+        """Show floating IP.
+
+        RBAC test for the neutron get_floatingip policy
+        """
+        floating_ip = self._create_floatingip()
+        rbac_utils.switch_role(self, switchToRbacRole=True)
+
+        try:
+            # Show floating IP
+            self.floating_ips_client.show_floatingip(floating_ip['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="delete_floatingip")
+    @decorators.idempotent_id('2611b068-30d4-4241-a78f-1b801a14db7e')
+    def test_delete_floating_ip(self):
+        """Delete floating IP.
+
+        RBAC test for the neutron delete_floatingip policy
+        """
+        floating_ip = self._create_floatingip()
+        rbac_utils.switch_role(self, switchToRbacRole=True)
+
+        try:
+            # Delete the floating IP
+            self.floating_ips_client.delete_floatingip(floating_ip['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_subnetpools_rbac.py b/patrole_tempest_plugin/tests/api/network/test_subnetpools_rbac.py
new file mode 100644
index 0000000..052176f
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/network/test_subnetpools_rbac.py
@@ -0,0 +1,133 @@
+# 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 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 SubnetPoolsRbacTest(base.BaseNetworkRbacTest):
+
+    @classmethod
+    def skip_checks(cls):
+        super(SubnetPoolsRbacTest, cls).skip_checks()
+        if not test.is_extension_enabled('subnet_allocation', 'network'):
+            msg = "subnet_allocation extension not enabled."
+            raise cls.skipException(msg)
+
+    def tearDown(self):
+        rbac_utils.switch_role(self, switchToRbacRole=False)
+        super(SubnetPoolsRbacTest, self).tearDown()
+
+    def _create_subnetpool(self, shared=None):
+        post_body = {'name': data_utils.rand_name(self.__class__.__name__),
+                     'min_prefixlen': 24,
+                     'max_prefixlen': 32,
+                     'prefixes': [CONF.network.project_network_cidr]}
+
+        if shared is not None:
+            post_body['shared'] = shared
+
+        body = self.subnetpools_client.create_subnetpool(**post_body)
+        subnetpool = body['subnetpool']
+
+        self.addCleanup(test_utils.call_and_ignore_notfound_exc,
+                        self.subnetpools_client.delete_subnetpool,
+                        subnetpool['id'])
+
+        return subnetpool
+
+    @rbac_rule_validation.action(service="neutron",
+                                 rule="create_subnetpool")
+    @decorators.idempotent_id('1b5509fd-2c32-44a8-a786-1b6ca162dbd1')
+    def test_create_subnetpool(self):
+        """Create subnetpool.
+
+        RBAC test for the neutron create_subnetpool policy
+        """
+        rbac_utils.switch_role(self, switchToRbacRole=True)
+        self._create_subnetpool()
+
+    @rbac_rule_validation.action(service="neutron",
+                                 rule="create_subnetpool:shared")
+    @decorators.idempotent_id('cf730989-0d47-40bc-b39a-99e7de484723')
+    def test_create_subnetpool_shared(self):
+        """Create subnetpool shared.
+
+        RBAC test for the neutron create_subnetpool:shared policy
+        """
+        rbac_utils.switch_role(self, switchToRbacRole=True)
+        self._create_subnetpool(shared=True)
+
+    @rbac_rule_validation.action(service="neutron",
+                                 rule="get_subnetpool")
+    @decorators.idempotent_id('4f5aee26-0507-4b6d-b44c-3128a25094d2')
+    def test_show_subnetpool(self):
+        """Show subnetpool.
+
+        RBAC test for the neutron get_subnetpool policy
+        """
+        subnetpool = self._create_subnetpool()
+        rbac_utils.switch_role(self, switchToRbacRole=True)
+        try:
+            self.subnetpools_client.show_subnetpool(subnetpool['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_subnetpool")
+    @decorators.idempotent_id('1e79cead-5081-4be2-a4f7-484c0f443b9b')
+    def test_update_subnetpool(self):
+        """Update subnetpool.
+
+        RBAC test for the neutron update_subnetpool policy
+        """
+        subnetpool = self._create_subnetpool()
+        rbac_utils.switch_role(self, switchToRbacRole=True)
+        self.subnetpools_client.update_subnetpool(subnetpool['id'],
+                                                  min_prefixlen=24)
+
+    @rbac_rule_validation.action(service="neutron",
+                                 rule="delete_subnetpool")
+    @decorators.idempotent_id('50f5944e-43e5-457b-ab50-fb48a73f0d3e')
+    def test_delete_subnetpool(self):
+        """Delete subnetpool.
+
+        RBAC test for the neutron delete_subnetpool policy
+        """
+        subnetpool = self._create_subnetpool()
+        rbac_utils.switch_role(self, switchToRbacRole=True)
+        try:
+            self.subnetpools_client.delete_subnetpool(subnetpool['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/tests/__init__.py b/patrole_tempest_plugin/tests/unit/__init__.py
similarity index 100%
rename from tests/__init__.py
rename to patrole_tempest_plugin/tests/unit/__init__.py
diff --git a/tests/base.py b/patrole_tempest_plugin/tests/unit/base.py
similarity index 100%
rename from tests/base.py
rename to patrole_tempest_plugin/tests/unit/base.py
diff --git a/tests/resources/admin_rbac_policy.json b/patrole_tempest_plugin/tests/unit/resources/admin_rbac_policy.json
similarity index 100%
rename from tests/resources/admin_rbac_policy.json
rename to patrole_tempest_plugin/tests/unit/resources/admin_rbac_policy.json
diff --git a/tests/resources/alt_admin_rbac_policy.json b/patrole_tempest_plugin/tests/unit/resources/alt_admin_rbac_policy.json
similarity index 100%
rename from tests/resources/alt_admin_rbac_policy.json
rename to patrole_tempest_plugin/tests/unit/resources/alt_admin_rbac_policy.json
diff --git a/tests/resources/custom_rbac_policy.json b/patrole_tempest_plugin/tests/unit/resources/custom_rbac_policy.json
similarity index 100%
rename from tests/resources/custom_rbac_policy.json
rename to patrole_tempest_plugin/tests/unit/resources/custom_rbac_policy.json
diff --git a/tests/resources/tenant_rbac_policy.json b/patrole_tempest_plugin/tests/unit/resources/tenant_rbac_policy.json
similarity index 100%
rename from tests/resources/tenant_rbac_policy.json
rename to patrole_tempest_plugin/tests/unit/resources/tenant_rbac_policy.json
diff --git a/tests/test_patrole.py b/patrole_tempest_plugin/tests/unit/test_patrole.py
similarity index 93%
rename from tests/test_patrole.py
rename to patrole_tempest_plugin/tests/unit/test_patrole.py
index d374e20..58aff05 100644
--- a/tests/test_patrole.py
+++ b/patrole_tempest_plugin/tests/unit/test_patrole.py
@@ -20,7 +20,7 @@
 Tests for `patrole` module.
 """
 
-from tests import base
+from patrole_tempest_plugin.tests.unit import base
 
 
 class TestPatrole(base.TestCase):
diff --git a/tests/test_rbac_role_converter.py b/patrole_tempest_plugin/tests/unit/test_rbac_policy_parser.py
similarity index 93%
rename from tests/test_rbac_role_converter.py
rename to patrole_tempest_plugin/tests/unit/test_rbac_policy_parser.py
index 09fa081..cc0fc4f 100644
--- a/tests/test_rbac_role_converter.py
+++ b/patrole_tempest_plugin/tests/unit/test_rbac_policy_parser.py
@@ -19,7 +19,7 @@
 from tempest import config
 from tempest.tests import base
 
-from patrole_tempest_plugin import rbac_role_converter
+from patrole_tempest_plugin import rbac_policy_parser
 
 CONF = config.CONF
 
@@ -43,12 +43,12 @@
                                                'resources',
                                                'tenant_rbac_policy.json')
 
-    @mock.patch.object(rbac_role_converter, 'LOG', autospec=True)
+    @mock.patch.object(rbac_policy_parser, 'LOG', autospec=True)
     def test_custom_policy(self, m_log):
         default_roles = ['zero', 'one', 'two', 'three', 'four',
                          'five', 'six', 'seven', 'eight', 'nine']
 
-        converter = rbac_role_converter.RbacPolicyConverter(
+        converter = rbac_policy_parser.RbacPolicyParser(
             None, "test", self.custom_policy_file)
 
         expected = {
@@ -76,7 +76,7 @@
                 self.assertFalse(converter.allowed(rule, role))
 
     def test_admin_policy_file_with_admin_role(self):
-        converter = rbac_role_converter.RbacPolicyConverter(
+        converter = rbac_policy_parser.RbacPolicyParser(
             None, "test", self.admin_policy_file)
 
         role = 'admin'
@@ -94,7 +94,7 @@
             self.assertFalse(allowed)
 
     def test_admin_policy_file_with_member_role(self):
-        converter = rbac_role_converter.RbacPolicyConverter(
+        converter = rbac_policy_parser.RbacPolicyParser(
             None, "test", self.admin_policy_file)
 
         role = 'Member'
@@ -113,7 +113,7 @@
             self.assertFalse(allowed)
 
     def test_admin_policy_file_with_context_is_admin(self):
-        converter = rbac_role_converter.RbacPolicyConverter(
+        converter = rbac_policy_parser.RbacPolicyParser(
             None, "test", self.alt_admin_policy_file)
 
         role = 'fake_admin'
@@ -147,7 +147,7 @@
         network:tenant_id pass.
         """
         test_tenant_id = mock.sentinel.tenant_id
-        converter = rbac_role_converter.RbacPolicyConverter(
+        converter = rbac_policy_parser.RbacPolicyParser(
             test_tenant_id, "test", self.tenant_policy_file)
 
         # Check whether Member role can perform expected actions.
diff --git a/tests/test_rbac_rule_validation.py b/patrole_tempest_plugin/tests/unit/test_rbac_rule_validation.py
similarity index 100%
rename from tests/test_rbac_rule_validation.py
rename to patrole_tempest_plugin/tests/unit/test_rbac_rule_validation.py
diff --git a/tests/test_rbac_utils.py b/patrole_tempest_plugin/tests/unit/test_rbac_utils.py
similarity index 100%
rename from tests/test_rbac_utils.py
rename to patrole_tempest_plugin/tests/unit/test_rbac_utils.py
diff --git a/test-whitelist.txt b/test-whitelist.txt
new file mode 100644
index 0000000..162992a
--- /dev/null
+++ b/test-whitelist.txt
@@ -0,0 +1 @@
+patrole_tempest_plugin.tests.unit.test*
diff --git a/tox.ini b/tox.ini
index 847adad..ba00222 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,6 +1,6 @@
 [tox]
 minversion = 1.6
-envlist = py35,py27,pypy,pep8
+envlist = pep8,py35,py27
 skipsdist = True
 
 [testenv]
@@ -9,16 +9,20 @@
 setenv =
    VIRTUAL_ENV={envdir}
    PYTHONWARNINGS=default::DeprecationWarning
-passenv = OS_STDOUT_CAPTURE OS_STDERR_CAPTURE OS_TEST_TIMEOUT OS_TEST_LOCK_PATH OS_TEST_PATH TEMPEST_CONFIG TEMPEST_CONFIG_DIR http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
-whitelist_externals = *
+passenv = OS_STDOUT_CAPTURE OS_STDERR_CAPTURE OS_TEST_TIMEOUT OS_TEST_LOCK_PATH OS_TEST_PATH http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
+whitelist_externals = find
 deps = -r{toxinidir}/requirements.txt
        -r{toxinidir}/test-requirements.txt
 commands = 
     find . -type f -name "*.pyc" -delete
-    ostestr {posargs}
+    ostestr {posargs} --whitelist-file test-whitelist.txt
 
 [testenv:pep8]
 commands = flake8 {posargs}
+		   check-uuid
+
+[testenv:uuidgen]
+commands = check-uuid --fix
 
 [testenv:venv]
 commands = {posargs}