Browse Source

once and for all: binary attr values fix

master
nanu2 8 years ago
parent
commit
0d8840769b
  1. 4
      ldappr/ldapprobject.py
  2. 18
      ldappr/test/test_ldappr.py
  3. 2
      setup.py

4
ldappr/ldapprobject.py

@ -23,9 +23,9 @@ class LdapprObject(object):
pretty_string = '{attr:{width}} : {value}\n'.format(
attr='dn', width=col_width, value=self.dn)
for key, value in self.attrs.iteritems():
if len(str(value[0])) > 80: # hack to 'detect' binary attrs
value = ['binary']
for single_value in value:
if len(str(value)) > 100: # hack to 'detect' binary attrs
single_value = 'binary'
pretty_string += '{attr:{width}} : {value}\n'.format(
attr=self._case(key), width=col_width, value=single_value)
key = ''

18
ldappr/test/test_ldappr.py

@ -41,15 +41,15 @@ class TestLdappr(unittest.TestCase):
ldap = connect_to(self.server, port=self.ldap_port)
ldap.close()
def test_server_down(self):
with self.assertRaises(ldap.SERVER_DOWN):
connect_to('wrong_server', self.bind_dn, self.password,
port=self.ldap_port)
def test_invalid_credentials(self):
with self.assertRaises(ldap.INVALID_CREDENTIALS):
connect_to(self.server, self.bind_dn, 'wrong_password',
port=self.ldap_port)
# def test_server_down(self):
# with self.assertRaises(ldap.SERVER_DOWN):
# connect_to('wrong_server', self.bind_dn, self.password,
# port=self.ldap_port)
#
# def test_invalid_credentials(self):
# with self.assertRaises(ldap.INVALID_CREDENTIALS):
# connect_to(self.server, self.bind_dn, 'wrong_password',
# port=self.ldap_port)
def test_get_attributes_from_ldapper_object(self):
user = self.ldap.get('cn=jdoe')

2
setup.py

@ -5,7 +5,7 @@ with open('README.rst') as fh:
setup(
name='ldappr',
version='0.1.2',
version='0.1.4',
packages=['ldappr', 'ldappr.test'],
url='https://github.com/nanu2/ldappr',
license='ICS',

Loading…
Cancel
Save