예제 #1
0
    def run(self):
        # Add 5000 entries
        idx = 0
        RDN = 'uid=add_del_supplier_' + self.id + '-'

        conn = DirectoryManager(self.inst).bind()

        while idx < NUM_USERS:
            USER_DN = RDN + str(idx) + ',' + DEFAULT_SUFFIX
            try:
                conn.add_s(
                    Entry((USER_DN, {
                        'objectclass': 'top extensibleObject'.split(),
                        'uid': 'user' + str(idx),
                        'cn': 'g' * random.randint(1, 500)
                    })))
            except ldap.LDAPError as e:
                log.fatal('Add users to supplier ' + self.id + ' failed (' +
                          USER_DN + ') error: ' + e.message['desc'])
            idx += 1
        conn.close()

        # Delete 5000 entries
        conn = DirectoryManager(self.inst).bind()
        idx = 0
        while idx < NUM_USERS:
            USER_DN = RDN + str(idx) + ',' + DEFAULT_SUFFIX
            try:
                conn.delete_s(USER_DN)
            except ldap.LDAPError as e:
                log.fatal('Failed to delete (' + USER_DN + ') on supplier ' +
                          self.id + ': error ' + e.message['desc'])
            idx += 1
        conn.close()
예제 #2
0
    def run(self):
        global RUNNING
        conn = DirectoryManager(self.inst).bind()
        while RUNNING:
            time.sleep(2)
            try:
                conn.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE,
                              'objectclass=top')
            except ldap.LDAPError as e:
                log.fatal('Full Search Users: Search failed (%s): %s' %
                          ('objectclass=*', e.message['desc']))
                conn.close()
                assert False

        conn.close()
예제 #3
0
    def run(self):
        # Add 1000 entries
        log.info('Run.')
        conn = DirectoryManager(self.inst.standalone).bind()

        time.sleep(30)
        log.info('Adding users.')
        for i in range(1000):
            user = UserAccounts(conn, DEFAULT_SUFFIX)
            users = user.create_test_user(uid=i)
            users.delete()
            self._ran = True
            if self._should_stop:
                break
        if not self._should_stop:
            raise RuntimeError('We finished too soon.')
        conn.close()
예제 #4
0
    def run(self):
        # Equality
        conn = DirectoryManager(self.inst).bind()
        idx = 0
        while idx < NUM_USERS:
            search_filter = ('(|(uid=supplier' + self.id + '_entry' +
                             str(idx) + ')(cn=supplier' + self.id + '_entry' +
                             str(idx) + '))')
            try:
                conn.search(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, search_filter)
            except ldap.LDAPError as e:
                log.fatal('Search Users: Search failed (%s): %s' %
                          (search_filter, e.message['desc']))
                conn.close()
                return

            idx += 1
        conn.close()

        # Substring
        conn = DirectoryManager(self.inst).bind()
        idx = 0
        while idx < NUM_USERS:
            search_filter = ('(|(uid=supplier' + self.id + '_entry' +
                             str(idx) + '*)(cn=supplier' + self.id + '_entry' +
                             str(idx) + '*))')
            try:
                conn.search(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, search_filter)
            except ldap.LDAPError as e:
                log.fatal('Search Users: Search failed (%s): %s' %
                          (search_filter, e.message['desc']))
                conn.close()
                return

            idx += 1
        conn.close()
예제 #5
0
    def run(self):
        # Mod existing entries
        conn = DirectoryManager(self.inst).bind()
        idx = 0
        while idx < NUM_USERS:
            USER_DN = ('uid=supplier' + self.id + '_entry' + str(idx) + ',' +
                       DEFAULT_SUFFIX)
            try:
                conn.modify(USER_DN, [(ldap.MOD_REPLACE, 'givenname',
                                       'new givenname supplier1-' + str(idx))])
            except ldap.LDAPError as e:
                log.fatal('Failed to modify (' + USER_DN + ') on supplier ' +
                          self.id + ': error ' + e.message['desc'])
            idx += 1
        conn.close()

        # Modrdn existing entries
        conn = DirectoryManager(self.inst).bind()
        idx = 0
        while idx < NUM_USERS:
            USER_DN = ('uid=supplier' + self.id + '_entry' + str(idx) + ',' +
                       DEFAULT_SUFFIX)
            NEW_RDN = 'cn=supplier' + self.id + '_entry' + str(idx)
            try:
                conn.rename_s(USER_DN, NEW_RDN, delold=1)
            except ldap.LDAPError as e:
                log.error('Failed to modrdn (' + USER_DN + ') on supplier ' +
                          self.id + ': error ' + e.message['desc'])
            idx += 1
        conn.close()

        # Undo modrdn to we can rerun this test
        conn = DirectoryManager(self.inst).bind()
        idx = 0
        while idx < NUM_USERS:
            USER_DN = ('cn=supplier' + self.id + '_entry' + str(idx) + ',' +
                       DEFAULT_SUFFIX)
            NEW_RDN = 'uid=supplier' + self.id + '_entry' + str(idx)
            try:
                conn.rename_s(USER_DN, NEW_RDN, delold=1)
            except ldap.LDAPError as e:
                log.error('Failed to modrdn (' + USER_DN + ') on supplier ' +
                          self.id + ': error ' + e.message['desc'])
            idx += 1
        conn.close()