fix search display

* fix attritues handling, not using backend attribute name but key given
  in attributes.yml
This commit is contained in:
kakwa 2015-06-15 23:03:47 +02:00
parent 47e51d2451
commit 322aba33e8
3 changed files with 8 additions and 6 deletions

View File

@ -332,8 +332,10 @@ class LdapCherry(object):
if not u in ret:
ret[u] = {}
for attr in tmp[u]:
if not attr in ret[u]:
ret[u][attr] = tmp[u][attr]
if attr in self.attributes.backend_attributes[b]:
attrid = self.attributes.backend_attributes[b][attr]
if not attr in ret[u]:
ret[u][attrid] = tmp[u][attr]
return ret
def _check_admin(self):

View File

@ -48,8 +48,8 @@ class Attributes:
for b in attr['backends']:
self.backends.add(b)
if b not in self.backend_attributes:
self.backend_attributes[b] = []
self.backend_attributes[b].append(attr['backends'][b])
self.backend_attributes[b] = {}
self.backend_attributes[b][attr['backends'][b]] = attrid
if 'search_displayed' in attr and attr['search_displayed']:
self.displayed_attributes[attrid] = attr
@ -78,7 +78,7 @@ class Attributes:
def get_backend_attributes(self, backend):
if backend not in self.backends:
raise WrongBackend(backend)
return self.backend_attributes[backend]
return self.backend_attributes[backend].keys()
def get_backend_key(self, backend):
if backend not in self.backends:

View File

@ -39,7 +39,7 @@ class TestError(object):
def testGetBackendAttributes(self):
inv = Attributes('./tests/cfg/attributes.yml')
ret = inv.get_backend_attributes('ldap')
expected = ['shell', 'cn', 'uid', 'uidNumber', 'gidNumber', 'home', 'userPassword', 'givenName', 'email', 'sn']
expected = ['shell', 'cn', 'userPassword', 'uidNumber', 'gidNumber', 'sn', 'home', 'givenName', 'email', 'uid']
assert ret == expected
def testGetKey(self):