Example #1
0
    def test_refresh(self):
        config_path = os.path.join(self.tmp_dir, 'config.yaml')

        db_path = os.path.join(self.tmp_dir, 'naaya.test.db')
        self.assertTrue(not os.path.exists(db_path))

        before = datetime.now().isoformat()
        main.dump_ldap(config_path)
        after = datetime.now().isoformat()

        reader = main.get_reader(config_path)
        latest_timestamp = reader.latest_timestamp()
        self.assertTrue(before < latest_timestamp < after)
        values = dict(reader.get_dump())

        self.assertEqual(len(values), 3)
        self.assertEqual(values['uid=test,ou=people,dc=naaya,dc=org']['uid'],
                         u'test')
        self.assertEqual(values['uid=admin,ou=people,dc=naaya,dc=org']['uid'],
                         u'admin')
        self.assertEqual(values['uid=test2,ou=people,dc=naaya,dc=org']['uid'],
                         u'test2')

        self.assertTrue(os.path.exists(db_path))
        os.remove(db_path)
Example #2
0
def dump_ldap(ldap_logging_path):
    """ Perform a dump of an LDAP database according to the config file. """
    naaya_ldap_cfg = os.path.join(ldap_logging_path, 'config.yaml')
    if not os.path.exists(naaya_ldap_cfg):
        log.info("%s does not exist", naaya_ldap_cfg)
    else:
        return main.dump_ldap(naaya_ldap_cfg)
Example #3
0
def dump_ldap(ldap_logging_path):
    """ Perform a dump of an LDAP database according to the config file. """
    naaya_ldap_cfg = os.path.join(ldap_logging_path, 'config.yaml')
    if not os.path.exists(naaya_ldap_cfg):
        log.info("%s does not exist", naaya_ldap_cfg)
    else:
        return main.dump_ldap(naaya_ldap_cfg)
Example #4
0
def dump_ldap(ldap_logging_path):
    """ Perform a dump of an LDAP database according to the config file. """
    naaya_ldap_cfg = os.path.join(ldap_logging_path, 'config.yaml')
    if os.path.exists(naaya_ldap_cfg):
        return main.dump_ldap(naaya_ldap_cfg)
    return None