Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Commit

Permalink
Add test for issue #885
Browse files Browse the repository at this point in the history
  • Loading branch information
jsumners committed May 16, 2023
1 parent a37daf1 commit bdaaf29
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions test-integration/client/issue-885.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
'use strict'

const tap = require('tap')
const ldapjs = require('../../lib')
const parseDN = ldapjs.parseDN

const SCHEME = process.env.SCHEME || 'ldap'
const HOST = process.env.HOST || '127.0.0.1'
const PORT = process.env.PORT || 389
const baseURL = `${SCHEME}://${HOST}:${PORT}`

const client = ldapjs.createClient({ url: baseURL })

const searchOpts = {
filter: '(&(objectClass=person))',
scope: 'sub',
paged: true,
sizeLimit: 0,
attributes: ['cn', 'employeeID']
}

const baseDN = parseDN('ou=large_ou,dc=planetexpress,dc=com')

tap.test('paged search option returns pages', t => {
t.plan(4)

client.bind('cn=admin,dc=planetexpress,dc=com', 'GoodNewsEveryone', (err) => {
t.error(err, 'bind error')
})

client.search(baseDN.toString(), searchOpts, (err, res) => {
t.error(err, 'search error')

let pages = 0
const results = []
res.on('searchEntry', (entry) => {
results.push(entry)
})

res.on('page', () => {
pages += 1
})

res.on('error', (err) => {
t.error(err, 'search entry error')
})

res.on('end', () => {
t.equal(results.length, 2000)
t.equal(pages, 20)

client.unbind(t.end)
})
})
})

0 comments on commit bdaaf29

Please sign in to comment.