Merge "Reclassify get_project_by_name() controller method"
This commit is contained in:
commit
43bd7944fe
@ -40,11 +40,11 @@ class Tenant(controller.V2Controller):
|
|||||||
@controller.v2_deprecated
|
@controller.v2_deprecated
|
||||||
def get_all_projects(self, context, **kw):
|
def get_all_projects(self, context, **kw):
|
||||||
"""Gets a list of all tenants for an admin user."""
|
"""Gets a list of all tenants for an admin user."""
|
||||||
if 'name' in context['query_string']:
|
|
||||||
return self.get_project_by_name(
|
|
||||||
context, context['query_string'].get('name'))
|
|
||||||
|
|
||||||
self.assert_admin(context)
|
self.assert_admin(context)
|
||||||
|
|
||||||
|
if 'name' in context['query_string']:
|
||||||
|
return self._get_project_by_name(context['query_string']['name'])
|
||||||
|
|
||||||
tenant_refs = self.resource_api.list_projects_in_domain(
|
tenant_refs = self.resource_api.list_projects_in_domain(
|
||||||
CONF.identity.default_domain_id)
|
CONF.identity.default_domain_id)
|
||||||
tenant_refs = [self.v3_to_v2_project(tenant_ref)
|
tenant_refs = [self.v3_to_v2_project(tenant_ref)
|
||||||
@ -71,9 +71,7 @@ class Tenant(controller.V2Controller):
|
|||||||
self._assert_not_is_domain_project(tenant_id, ref)
|
self._assert_not_is_domain_project(tenant_id, ref)
|
||||||
return {'tenant': self.v3_to_v2_project(ref)}
|
return {'tenant': self.v3_to_v2_project(ref)}
|
||||||
|
|
||||||
@controller.v2_deprecated
|
def _get_project_by_name(self, tenant_name):
|
||||||
def get_project_by_name(self, context, tenant_name):
|
|
||||||
self.assert_admin(context)
|
|
||||||
# Projects acting as a domain should not be visible via v2
|
# Projects acting as a domain should not be visible via v2
|
||||||
ref = self.resource_api.get_project_by_name(
|
ref = self.resource_api.get_project_by_name(
|
||||||
tenant_name, CONF.identity.default_domain_id)
|
tenant_name, CONF.identity.default_domain_id)
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
|
import copy
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from keystone.assignment import controllers as assignment_controllers
|
from keystone.assignment import controllers as assignment_controllers
|
||||||
@ -107,18 +108,22 @@ class TenantTestCase(unit.TestCase):
|
|||||||
"""Test that get project does not return is_domain projects."""
|
"""Test that get project does not return is_domain projects."""
|
||||||
project = self._create_is_domain_project()
|
project = self._create_is_domain_project()
|
||||||
|
|
||||||
self.assertRaises(
|
context = copy.deepcopy(_ADMIN_CONTEXT)
|
||||||
exception.ProjectNotFound,
|
context['query_string']['name'] = project['name']
|
||||||
self.tenant_controller.get_project_by_name,
|
|
||||||
_ADMIN_CONTEXT,
|
|
||||||
project['name']
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exception.ProjectNotFound,
|
exception.ProjectNotFound,
|
||||||
self.tenant_controller.get_project,
|
self.tenant_controller.get_all_projects,
|
||||||
_ADMIN_CONTEXT,
|
context
|
||||||
project['id']
|
)
|
||||||
|
|
||||||
|
context = copy.deepcopy(_ADMIN_CONTEXT)
|
||||||
|
context['query_string']['name'] = project['id']
|
||||||
|
|
||||||
|
self.assertRaises(
|
||||||
|
exception.ProjectNotFound,
|
||||||
|
self.tenant_controller.get_all_projects,
|
||||||
|
context
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_update_is_domain_project_not_found(self):
|
def test_update_is_domain_project_not_found(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user