From fac321458166cccffc0eb1d13a986a01c9e6d33e Mon Sep 17 00:00:00 2001 From: Huanxuan Ao Date: Tue, 2 Aug 2016 19:30:25 +0800 Subject: Implement "network rbac set" command Add "network rbac set" command which just supports setting a target project. Also, This patch adds the doc, unit test and functional test. But there is a bug of showing network RBAC https://bugs.launchpad.net/python-openstacksdk/+bug/1608903 We need to skip the functional test before this bug fixed. Change-Id: I756f448bb333cf1098a735e57a1c5dc4edf195d4 Partially-Implements: blueprint neutron-client-rbac --- functional/tests/network/v2/test_network_rbac.py | 29 ++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'functional/tests') diff --git a/functional/tests/network/v2/test_network_rbac.py b/functional/tests/network/v2/test_network_rbac.py index 5d8cc1cc..e7e35858 100644 --- a/functional/tests/network/v2/test_network_rbac.py +++ b/functional/tests/network/v2/test_network_rbac.py @@ -12,12 +12,15 @@ import uuid +import testtools + from functional.common import test class NetworkRBACTests(test.TestCase): """Functional tests for network rbac. """ NET_NAME = uuid.uuid4().hex + PROJECT_NAME = uuid.uuid4().hex OBJECT_ID = None ID = None HEADERS = ['ID'] @@ -39,10 +42,10 @@ class NetworkRBACTests(test.TestCase): @classmethod def tearDownClass(cls): - raw_output = cls.openstack('network rbac delete ' + cls.ID) - cls.assertOutput('', raw_output) - raw_output = cls.openstack('network delete ' + cls.OBJECT_ID) - cls.assertOutput('', raw_output) + raw_output_rbac = cls.openstack('network rbac delete ' + cls.ID) + raw_output_network = cls.openstack('network delete ' + cls.OBJECT_ID) + cls.assertOutput('', raw_output_rbac) + cls.assertOutput('', raw_output_network) def test_network_rbac_list(self): opts = self.get_opts(self.HEADERS) @@ -53,3 +56,21 @@ class NetworkRBACTests(test.TestCase): opts = self.get_opts(self.FIELDS) raw_output = self.openstack('network rbac show ' + self.ID + opts) self.assertEqual(self.ID + "\n", raw_output) + + # TODO(Huanxuan Ao): This test can pass after bug + # https://bugs.launchpad.net/python-openstackclient/+bug/1608903 fixed. + @testtools.skip( + 'Skip because of the bug ' + 'https://bugs.launchpad.net/python-openstackclient/+bug/1608903') + def test_network_rbac_set(self): + opts = self.get_opts(self.FIELDS) + project_id = self.openstack( + 'project create ' + self.PROJECT_NAME + opts) + self.openstack('network rbac set ' + self.ID + + ' --target-project ' + self.PROJECT_NAME) + opts = self.get_opts(['target_project']) + raw_output_rbac = self.openstack('network rbac show ' + self.ID + opts) + raw_output_project = self.openstack( + 'project delete ' + self.PROJECT_NAME) + self.assertEqual(project_id, raw_output_rbac) + self.assertOutput('', raw_output_project) -- cgit v1.2.1