summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2012-05-10 11:03:41 -0400
committerMartin Kosek <mkosek@redhat.com>2012-05-15 10:02:26 +0200
commitece68f381a1bcf38d2f9c2d1b7f960438d5e2241 (patch)
treec776ec94026a3bc33f9ca58d81cebabf553205b3
parent26ab9a504f504f59cfd3af929dbeac2ddc201ed3 (diff)
downloadfreeipa-ece68f381a1bcf38d2f9c2d1b7f960438d5e2241.tar.gz
freeipa-ece68f381a1bcf38d2f9c2d1b7f960438d5e2241.tar.xz
freeipa-ece68f381a1bcf38d2f9c2d1b7f960438d5e2241.zip
Check for empty/single value parameters before calling callbacks
https://fedorahosted.org/freeipa/ticket/2701
-rw-r--r--ipalib/plugins/baseldap.py5
-rw-r--r--tests/test_xmlrpc/test_config_plugin.py8
2 files changed, 11 insertions, 2 deletions
diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py
index 895ec682a..2851f0f27 100644
--- a/ipalib/plugins/baseldap.py
+++ b/ipalib/plugins/baseldap.py
@@ -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)
diff --git a/tests/test_xmlrpc/test_config_plugin.py b/tests/test_xmlrpc/test_config_plugin.py
index fbe389106..da549bfb3 100644
--- a/tests/test_xmlrpc/test_config_plugin.py
+++ b/tests/test_xmlrpc/test_config_plugin.py
@@ -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'),
+ ),
+
]