From 4ee6b918bad9af444f2b1c63dbd61cbda4591775 Mon Sep 17 00:00:00 2001 From: Rodrigo Duarte Date: Fri, 26 Feb 2016 17:52:25 -0300 Subject: [PATCH] Add parent_id to create_project Now keystone supports the creation of projects hierarchies, this patch adds the parent_id field in the project client and adds a simple test to check it. As of Mitaka, if not provided, the parent_id must point to the root project of the hierarchy (its domain). Change-Id: Ie69dae09c2b42e825e9d51abf158fc14788387d1 --- .../api/identity/admin/v3/test_projects.py | 36 +++++++++++++++++++ tempest/config.py | 7 +++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/tempest/api/identity/admin/v3/test_projects.py b/tempest/api/identity/admin/v3/test_projects.py index 607bebe3e6..b53cfae932 100644 --- a/tempest/api/identity/admin/v3/test_projects.py +++ b/tempest/api/identity/admin/v3/test_projects.py @@ -13,10 +13,15 @@ # License for the specific language governing permissions and limitations # under the License. +import testtools + from tempest.api.identity import base from tempest.common.utils import data_utils +from tempest import config from tempest import test +CONF = config.CONF + class ProjectsTestJSON(base.BaseIdentityV3AdminTest): @@ -52,6 +57,37 @@ class ProjectsTestJSON(base.BaseIdentityV3AdminTest): self.assertEqual(project_name, body['name']) self.assertEqual(self.data.domain['id'], body['domain_id']) + @testtools.skipUnless(CONF.identity_feature_enabled.reseller, + 'Reseller not available.') + @test.idempotent_id('1854f9c0-70bc-4d11-a08a-1c789d339e3d') + def test_project_create_with_parent(self): + # Create root project without providing a parent_id + self.data.setup_test_domain() + domain_id = self.data.domain['id'] + + root_project_name = data_utils.rand_name('root_project') + root_project = self.projects_client.create_project( + root_project_name, domain_id=domain_id)['project'] + self.addCleanup( + self.projects_client.delete_project, root_project['id']) + + root_project_id = root_project['id'] + parent_id = root_project['parent_id'] + self.assertEqual(root_project_name, root_project['name']) + # If not provided, the parent_id must point to the top level + # project in the hierarchy, i.e. its domain + self.assertEqual(domain_id, parent_id) + + # Create a project using root_project_id as parent_id + project_name = data_utils.rand_name('project') + project = self.projects_client.create_project( + project_name, domain_id=domain_id, + parent_id=root_project_id)['project'] + self.data.projects.append(project) + parent_id = project['parent_id'] + self.assertEqual(project_name, project['name']) + self.assertEqual(root_project_id, parent_id) + @test.idempotent_id('1f66dc76-50cc-4741-a200-af984509e480') def test_project_create_enabled(self): # Create a project that is enabled diff --git a/tempest/config.py b/tempest/config.py index b3d409f79c..caaebea047 100644 --- a/tempest/config.py +++ b/tempest/config.py @@ -191,7 +191,12 @@ IdentityFeatureGroup = [ help="A list of enabled identity extensions with a special " "entry all which indicates every extension is enabled. " "Empty list indicates all extensions are disabled. " - "To get the list of extensions run: 'keystone discover'") + "To get the list of extensions run: 'keystone discover'"), + # TODO(rodrigods): Remove the reseller flag when Kilo and Liberty is end + # of life. + cfg.BoolOpt('reseller', + default=False, + help='Does the environment support reseller?') ] compute_group = cfg.OptGroup(name='compute',