def test_hook_posixgroup(self): """Test saving with PosixGroup hook calls """ pg = PosixGroup(LDAP_CONN, 'cn=nazwa,ou=groups,dc=company,dc=com') pu = PosixUser(LDAP_CONN, 'cn=hook_user,ou=users,dc=company,dc=com') pg.gid = 1094 pg.save() pu.update() self.assertEqual(pg.gid, pu.gid) pg.gid = 345 pg.save() pu.update() self.assertEqual(pg.gid, pu.gid)
def test_posixgroup(self): """Test PosixGroup methods """ ou = Unit(LDAP_CONN) ou.name = u"posix_group" ou.save() pu = PosixUser(LDAP_CONN) pu.set_parent(ou.dn) pu.uid = 8361 pu.gid = 8245 pu.login = u"login" pu.surname = u"Surname" pu.fullname = u"Fullname" pu.home = u"/home" pu.save() pg = PosixGroup(LDAP_CONN) pg.set_parent(ou.dn) pg.name = u"group" pg.gid = 45921 pg.save() self.assertFalse(pg.ismember(pu.uid)) pg.add_member(pu.uid) pg.save() pg.update() pu.update() self.assertEqual(pu.gid, pg.gid) self.assertRaises(ValueError, pg.remove_member, 1) pg.remove_member(pu.uid) pg.save() pg.update() self.assertFalse(pg.ismember(pu.uid)) ou.delete(recursive=True)