Check for empty/single value parameters before calling callbacks

https://fedorahosted.org/freeipa/ticket/2701
This commit is contained in:
Petr Viktorin 2012-05-10 11:03:41 -04:00 committed by Martin Kosek
parent 26ab9a504f
commit ece68f381a
2 changed files with 11 additions and 2 deletions

View File

@ -1255,6 +1255,9 @@ class LDAPUpdate(LDAPQuery, crud.Update):
set(self.obj.default_attributes + entry_attrs.keys())
)
_check_single_value_attrs(self.params, entry_attrs)
_check_empty_attrs(self.obj.params, entry_attrs)
for callback in self.PRE_CALLBACKS:
if hasattr(callback, 'im_self'):
dn = callback(
@ -1265,8 +1268,6 @@ class LDAPUpdate(LDAPQuery, crud.Update):
self, ldap, dn, entry_attrs, attrs_list, *keys, **options
)
_check_single_value_attrs(self.params, entry_attrs)
_check_empty_attrs(self.obj.params, entry_attrs)
ldap.get_schema()
_check_limit_object_class(self.api.Backend.ldap2.schema.attribute_types(self.obj.limit_object_classes), entry_attrs.keys(), allow_only=True)
_check_limit_object_class(self.api.Backend.ldap2.schema.attribute_types(self.obj.disallow_object_classes), entry_attrs.keys(), allow_only=False)

View File

@ -21,6 +21,7 @@
Test the `ipalib/plugins/config.py` module.
"""
from ipalib import errors
from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid
class test_config(Declarative):
@ -52,4 +53,11 @@ class test_config(Declarative):
),
),
dict(
desc='Try to remove ipausersearchfields',
command=('config_mod', [],
dict(delattr=u'ipausersearchfields=uid,givenname,sn,telephonenumber,ou,title')),
expected=errors.RequirementError(name='ipausersearchfields'),
),
]