diff options
author | Jenkins <jenkins@review.openstack.org> | 2012-05-19 18:59:55 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2012-05-19 18:59:55 +0000 |
commit | 507294ab1a65726dceaf8fe4b7c3a2ad3bd71b56 (patch) | |
tree | 3e1cd2c9bb29f030e9ea098c0cf7991e85b41891 /keystone/identity/core.py | |
parent | aec02eb8204b4747d66a6cb9d7ae3de11be76196 (diff) | |
parent | 19b6076869f6e177febc559b191f4ef9c352e55b (diff) | |
download | keystone-507294ab1a65726dceaf8fe4b7c3a2ad3bd71b56.tar.gz keystone-507294ab1a65726dceaf8fe4b7c3a2ad3bd71b56.tar.xz keystone-507294ab1a65726dceaf8fe4b7c3a2ad3bd71b56.zip |
Merge "Add validations of 'name' field for roles, users and tenants."
Diffstat (limited to 'keystone/identity/core.py')
-rw-r--r-- | keystone/identity/core.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/keystone/identity/core.py b/keystone/identity/core.py index 3f5a3f35..a0cacb3e 100644 --- a/keystone/identity/core.py +++ b/keystone/identity/core.py @@ -295,6 +295,11 @@ class TenantController(wsgi.Application): # CRUD Extension def create_tenant(self, context, tenant): tenant_ref = self._normalize_dict(tenant) + + if not 'name' in tenant_ref or not tenant_ref['name']: + msg = 'Name field is required and cannot be empty' + raise exception.ValidationError(message=msg) + self.assert_admin(context) tenant_id = (tenant_ref.get('id') and tenant_ref.get('id') @@ -388,6 +393,11 @@ class UserController(wsgi.Application): def create_user(self, context, user): user = self._normalize_dict(user) self.assert_admin(context) + + if not 'name' in user or not user['name']: + msg = 'Name field is required and cannot be empty' + raise exception.ValidationError(message=msg) + tenant_id = user.get('tenantId', None) if (tenant_id is not None and self.identity_api.get_tenant(context, tenant_id) is None): @@ -482,6 +492,11 @@ class RoleController(wsgi.Application): def create_role(self, context, role): role = self._normalize_dict(role) self.assert_admin(context) + + if not 'name' in role or not role['name']: + msg = 'Name field is required and cannot be empty' + raise exception.ValidationError(message=msg) + role_id = uuid.uuid4().hex role['id'] = role_id role_ref = self.identity_api.create_role(context, role_id, role) |