Ejemplo n.º 1
0
 def test_update_object(self):
     self.session.authenticate(
         'cn=John Doe,ou=Employees,ou=People,dc=example,dc=com', 'password')
     user = pyldap_orm.LDAPObject(self.session).by_dn(
         'cn=John Doe,ou=Employees,ou=People,dc=example,dc=com', '[+,*]')
     user.description = ['Test']
     user.save()
     user = pyldap_orm.LDAPObject(self.session).by_dn(
         'cn=John Doe,ou=Employees,ou=People,dc=example,dc=com')
     assert user.description == ['Test']
     user.description = []
     user.save()
Ejemplo n.º 2
0
 def test_create_object(self):
     ldap_object = pyldap_orm.LDAPObject(self.session)
     ldap_object.dn = 'cn=Test,ou=Tests,dc=example,dc=com'
     ldap_object.objectClass = ['person']
     ldap_object.sn = ['Test']
     ldap_object.save()
     ldap_object = pyldap_orm.LDAPObject(
         self.session).by_dn('cn=Test,ou=Tests,dc=example,dc=com')
     assert ldap_object.dn == 'cn=Test,ou=Tests,dc=example,dc=com'
     assert ldap_object.sn == ['Test']
     ldap_object.delete()
     with pytest.raises(ldap.NO_SUCH_OBJECT):
         pyldap_orm.LDAPObject(
             self.session).by_dn('cn=Test,ou=Tests,dc=example,dc=com')
Ejemplo n.º 3
0
 def test_entry(self):
     user = pyldap_orm.LDAPObject(self.session).by_dn(
         'cn=John Doe,ou=Employees,ou=People,dc=example,dc=com')
     user.gidNumber = [10000]
     assert sorted(user.attributes()) == sorted([
         'uidNumber', 'homeDirectory', 'sn', 'gidNumber', 'cn',
         'objectClass', 'uid', 'userPassword'
     ])
Ejemplo n.º 4
0
 def test_entry_extended_attributes(self):
     user = pyldap_orm.LDAPObject(self.session).by_dn(
         'cn=John Doe,ou=Employees,ou=People,dc=example,dc=com', '[+,*]')
     assert user.dn == 'cn=John Doe,ou=Employees,ou=People,dc=example,dc=com'
     assert user.homeDirectory == ['/home/jdoe']
     assert user.gidNumber == [10000]
     assert user.hasSubordinates == [False]
     assert user.isMemberOf == ['cn=Developers,ou=Groups,dc=example,dc=com']
     with pytest.raises(KeyError):
         user.givenName
Ejemplo n.º 5
0
 def test_save_for_nothing(self):
     user = pyldap_orm.LDAPObject(self.session).by_dn(
         'cn=John Doe,ou=Employees,ou=People,dc=example,dc=com')
     user.save()