Prevents creating is_domain=True projects in v2
Keystone v2 must not allow the creation of projects with the is_domain field set True. Co-Authored-By: Rodrigo Duarte <rodrigods@lsd.ufcg.edu.br> Change-Id: I569e4ab147a16bb019fb3d5f4f6218c75f4a3cca Closes-Bug: 1496946
This commit is contained in:
parent
71436b3ca2
commit
5599226956
|
@ -85,6 +85,11 @@ class Tenant(controller.V2Controller):
|
|||
msg = _('Name field is required and cannot be empty')
|
||||
raise exception.ValidationError(message=msg)
|
||||
|
||||
if 'is_domain' in tenant_ref:
|
||||
msg = _('The creation of projects acting as domains is not '
|
||||
'allowed in v2.')
|
||||
raise exception.ValidationError(message=msg)
|
||||
|
||||
self.assert_admin(context)
|
||||
tenant_ref['id'] = tenant_ref.get('id', uuid.uuid4().hex)
|
||||
initiator = notifications._get_request_audit_info(context)
|
||||
|
|
|
@ -124,6 +124,30 @@ class TenantTestCase(unit.TestCase):
|
|||
context
|
||||
)
|
||||
|
||||
def test_create_is_domain_project_fails(self):
|
||||
"""Test that the creation of a project acting as a domain fails."""
|
||||
project = {'name': uuid.uuid4().hex, 'domain_id': 'default',
|
||||
'is_domain': True}
|
||||
|
||||
self.assertRaises(
|
||||
exception.ValidationError,
|
||||
self.tenant_controller.create_project,
|
||||
_ADMIN_CONTEXT,
|
||||
project
|
||||
)
|
||||
|
||||
def test_create_project_passing_is_domain_false_fails(self):
|
||||
"""Test that passing is_domain=False is not allowed."""
|
||||
project = {'name': uuid.uuid4().hex, 'domain_id': 'default',
|
||||
'is_domain': False}
|
||||
|
||||
self.assertRaises(
|
||||
exception.ValidationError,
|
||||
self.tenant_controller.create_project,
|
||||
_ADMIN_CONTEXT,
|
||||
project
|
||||
)
|
||||
|
||||
def test_update_is_domain_project_not_found(self):
|
||||
"""Test that update is_domain project is not allowed in v2."""
|
||||
project = self._create_is_domain_project()
|
||||
|
|
Loading…
Reference in New Issue