Make some test_list_projects tests work w/ pre-prov
This is part 2 of 2 commits to not force dynamic creds to execute
the following tests:
* test_list_projects
* test_list_projects_with_name
* test_list_projects_with_domains
so that users with a cloud using the pre-provisioned credential
provider can execute these tests.
Part 1 did some refactoring[1]
The other tests cannot be moved because they require resources to
be created explained below:
* test_list_projects_with_parent
- if this test requires a project with a parent then we cannot
use pre-provisioned credentials because there is no way to
provide an account with a parent using the current
implementation of the pre-provisioned credential provider.
* test_list_projects_with_enabled
- if this test requires projects that are disabled then we
cannot use pre-provisioned credentials because there is no
way to provide an account that is disabled with the current
implementation of the pre-provisioned credential provider.
[1] https://review.openstack.org/#/c/583385/
Change-Id: I9ee67c8c99a33fa75fb7faa1efcccd5bba5b05ef
diff --git a/tempest/api/identity/admin/v3/test_list_projects.py b/tempest/api/identity/admin/v3/test_list_projects.py
index 148b368..50f3186 100644
--- a/tempest/api/identity/admin/v3/test_list_projects.py
+++ b/tempest/api/identity/admin/v3/test_list_projects.py
@@ -14,9 +14,12 @@
# under the License.
from tempest.api.identity import base
+from tempest import config
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
+CONF = config.CONF
+
class BaseListProjectsTestJSON(base.BaseIdentityV3AdminTest):
@@ -60,34 +63,12 @@
cls.p3['id'])
cls.project_ids.append(cls.p3['id'])
- @decorators.idempotent_id('1d830662-22ad-427c-8c3e-4ec854b0af44')
- def test_list_projects(self):
- # List projects
- list_projects = self.projects_client.list_projects()['projects']
-
- for p in self.project_ids:
- show_project = self.projects_client.show_project(p)['project']
- self.assertIn(show_project, list_projects)
-
- @decorators.idempotent_id('fab13f3c-f6a6-4b9f-829b-d32fd44fdf10')
- def test_list_projects_with_domains(self):
- # List projects with domain
- self._list_projects_with_params(
- [self.p1], [self.p2, self.p3], {'domain_id': self.domain['id']},
- 'domain_id')
-
@decorators.idempotent_id('0fe7a334-675a-4509-b00e-1c4b95d5dae8')
def test_list_projects_with_enabled(self):
# List the projects with enabled
self._list_projects_with_params(
[self.p1], [self.p2, self.p3], {'enabled': False}, 'enabled')
- @decorators.idempotent_id('fa178524-4e6d-4925-907c-7ab9f42c7e26')
- def test_list_projects_with_name(self):
- # List projects with name
- self._list_projects_with_params(
- [self.p1], [self.p2, self.p3], {'name': self.p1_name}, 'name')
-
@decorators.idempotent_id('6edc66f5-2941-4a17-9526-4073311c1fac')
def test_list_projects_with_parent(self):
# List projects with parent
@@ -97,3 +78,51 @@
self.assertNotEmpty(fetched_projects)
for project in fetched_projects:
self.assertEqual(self.p3['parent_id'], project['parent_id'])
+
+
+class ListProjectsStaticTestJSON(BaseListProjectsTestJSON):
+ # NOTE: force_tenant_isolation is true in the base class by default but
+ # overridden to false here to allow test execution for clouds using the
+ # pre-provisioned credentials provider.
+ force_tenant_isolation = False
+
+ @classmethod
+ def resource_setup(cls):
+ super(ListProjectsStaticTestJSON, cls).resource_setup()
+ cls.domain_id = CONF.identity.default_domain_id
+ cls.project_ids = list()
+ cls.p1_name = cls.os_primary.credentials.project_name
+ cls.p1 = cls.projects_client.show_project(
+ cls.os_primary.credentials.project_id)['project']
+ cls.project_ids.append(cls.p1['id'])
+ p2_name = data_utils.rand_name('project')
+ cls.p2 = cls.projects_client.create_project(
+ p2_name, domain_id=cls.domain_id)['project']
+ cls.addClassResourceCleanup(cls.projects_client.delete_project,
+ cls.p2['id'])
+ cls.project_ids.append(cls.p2['id'])
+
+ @decorators.idempotent_id('1d830662-22ad-427c-8c3e-4ec854b0af44')
+ def test_list_projects(self):
+ # List projects
+ list_projects = self.projects_client.list_projects()['projects']
+
+ for p in self.project_ids:
+ show_project = self.projects_client.show_project(p)['project']
+ self.assertIn(show_project, list_projects)
+
+ @decorators.idempotent_id('fa178524-4e6d-4925-907c-7ab9f42c7e26')
+ def test_list_projects_with_name(self):
+ # List projects with name
+ self._list_projects_with_params(
+ [self.p1], [self.p2], {'name': self.p1_name}, 'name')
+
+ @decorators.idempotent_id('fab13f3c-f6a6-4b9f-829b-d32fd44fdf10')
+ def test_list_projects_with_domains(self):
+ # List projects with domain
+ key = 'domain_id'
+ params = {key: self.domain_id}
+ # Verify both projects are in the self.domain_id which is the default
+ # domain
+ self._list_projects_with_params(
+ [self.p1, self.p2], [], params, key)