diff options
author | Rob Crittenden <rcritten@redhat.com> | 2011-04-13 10:48:07 -0400 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2011-04-13 17:30:29 +0200 |
commit | 5b580454a261803349bfb2c40e7ceedabf31554c (patch) | |
tree | 5c2e5338296f5dd3da702ed3824ae2e9cbc7e216 | |
parent | c132c8bbd5bd9b8d5a84c3cd79fab1c46a7ed8a6 (diff) | |
download | freeipa-5b580454a261803349bfb2c40e7ceedabf31554c.tar.gz freeipa-5b580454a261803349bfb2c40e7ceedabf31554c.tar.xz freeipa-5b580454a261803349bfb2c40e7ceedabf31554c.zip |
Sort entries returned by *-find by the primary key (if any).
Do a server-side sort if there is a primary key.
Fix a couple of tests that were failing due to the new sorting.
ticket 794
-rw-r--r-- | ipalib/plugins/baseldap.py | 4 | ||||
-rw-r--r-- | tests/test_xmlrpc/test_automount_plugin.py | 4 | ||||
-rw-r--r-- | tests/test_xmlrpc/test_group_plugin.py | 12 |
3 files changed, 12 insertions, 8 deletions
diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py index d516ed673..0dcb89039 100644 --- a/ipalib/plugins/baseldap.py +++ b/ipalib/plugins/baseldap.py @@ -1418,6 +1418,10 @@ class LDAPSearch(CallbackInterface, crud.Search): else: callback(self, ldap, entries, truncated, *args, **options) + if self.obj.primary_key: + sortfn=lambda x,y: cmp(x[1][self.obj.primary_key.name][0].lower(), y[1][self.obj.primary_key.name][0].lower()) + entries.sort(sortfn) + if not options.get('raw', False): for e in entries: self.obj.convert_attribute_members(e[1], *args, **options) diff --git a/tests/test_xmlrpc/test_automount_plugin.py b/tests/test_xmlrpc/test_automount_plugin.py index c2fa15ac3..c5dd619e2 100644 --- a/tests/test_xmlrpc/test_automount_plugin.py +++ b/tests/test_xmlrpc/test_automount_plugin.py @@ -119,8 +119,8 @@ class test_automount(XMLRPC_test): res = api.Command['automountkey_find'](self.locname, self.mapname, raw=True)['result'] assert res assert len(res) == 2 - assert_attr_equal(res[1], 'automountkey', self.keyname) - assert_attr_equal(res[1], 'automountinformation', self.info) + assert_attr_equal(res[0], 'automountkey', self.keyname) + assert_attr_equal(res[0], 'automountinformation', self.info) def test_9_automountkey_mod(self): """ diff --git a/tests/test_xmlrpc/test_group_plugin.py b/tests/test_xmlrpc/test_group_plugin.py index 5cb94f34a..a49193261 100644 --- a/tests/test_xmlrpc/test_group_plugin.py +++ b/tests/test_xmlrpc/test_group_plugin.py @@ -336,17 +336,17 @@ class test_group(Declarative): 'description': [u'Account administrators group'], }, { - 'dn': u'cn=ipausers,cn=groups,cn=accounts,%s' % api.env.basedn, - 'gidnumber': [fuzzy_digits], - 'cn': [u'ipausers'], - 'description': [u'Default group for all users'], - }, - { 'dn': u'cn=editors,cn=groups,cn=accounts,%s' % api.env.basedn, 'gidnumber': [fuzzy_digits], 'cn': [u'editors'], 'description': [u'Limited admins who can edit other users'], }, + { + 'dn': u'cn=ipausers,cn=groups,cn=accounts,%s' % api.env.basedn, + 'gidnumber': [fuzzy_digits], + 'cn': [u'ipausers'], + 'description': [u'Default group for all users'], + }, dict( dn=u'cn=%s,cn=groups,cn=accounts,%s' % (group1, api.env.basedn), cn=[group1], |