From 13bc3793e0f0378db0151acb171dbe5f2d9c08dd Mon Sep 17 00:00:00 2001 From: Huanxuan Ao Date: Mon, 25 Jul 2016 17:37:41 +0800 Subject: Implement network rbac create and delete commands Add "network rbac create" and "network rbac delete" commands and also add unit tests, functional tests, docs and release note for them. Change-Id: I5fd58342f2deaa9bae7717412a942a21bbd7d045 Partially-Implements: blueprint neutron-client-rbac --- functional/tests/network/v2/test_network_rbac.py | 55 ++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 functional/tests/network/v2/test_network_rbac.py (limited to 'functional/tests') diff --git a/functional/tests/network/v2/test_network_rbac.py b/functional/tests/network/v2/test_network_rbac.py new file mode 100644 index 00000000..5d8cc1cc --- /dev/null +++ b/functional/tests/network/v2/test_network_rbac.py @@ -0,0 +1,55 @@ +# 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 uuid + +from functional.common import test + + +class NetworkRBACTests(test.TestCase): + """Functional tests for network rbac. """ + NET_NAME = uuid.uuid4().hex + OBJECT_ID = None + ID = None + HEADERS = ['ID'] + FIELDS = ['id'] + + @classmethod + def setUpClass(cls): + opts = cls.get_opts(cls.FIELDS) + raw_output = cls.openstack('network create ' + cls.NET_NAME + opts) + cls.OBJECT_ID = raw_output.strip('\n') + opts = cls.get_opts(['id', 'object_id']) + raw_output = cls.openstack('network rbac create ' + + cls.OBJECT_ID + + ' --action access_as_shared' + + ' --target-project admin' + + ' --type network' + opts) + cls.ID, object_id, rol = tuple(raw_output.split('\n')) + cls.assertOutput(cls.OBJECT_ID, object_id) + + @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) + + def test_network_rbac_list(self): + opts = self.get_opts(self.HEADERS) + raw_output = self.openstack('network rbac list' + opts) + self.assertIn(self.ID, raw_output) + + def test_network_rbac_show(self): + opts = self.get_opts(self.FIELDS) + raw_output = self.openstack('network rbac show ' + self.ID + opts) + self.assertEqual(self.ID + "\n", raw_output) -- cgit v1.2.1