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

Commit bdaaf29

Browse files
committed
Add test for issue #885
1 parent a37daf1 commit bdaaf29

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
'use strict'
2+
3+
const tap = require('tap')
4+
const ldapjs = require('../../lib')
5+
const parseDN = ldapjs.parseDN
6+
7+
const SCHEME = process.env.SCHEME || 'ldap'
8+
const HOST = process.env.HOST || '127.0.0.1'
9+
const PORT = process.env.PORT || 389
10+
const baseURL = `${SCHEME}://${HOST}:${PORT}`
11+
12+
const client = ldapjs.createClient({ url: baseURL })
13+
14+
const searchOpts = {
15+
filter: '(&(objectClass=person))',
16+
scope: 'sub',
17+
paged: true,
18+
sizeLimit: 0,
19+
attributes: ['cn', 'employeeID']
20+
}
21+
22+
const baseDN = parseDN('ou=large_ou,dc=planetexpress,dc=com')
23+
24+
tap.test('paged search option returns pages', t => {
25+
t.plan(4)
26+
27+
client.bind('cn=admin,dc=planetexpress,dc=com', 'GoodNewsEveryone', (err) => {
28+
t.error(err, 'bind error')
29+
})
30+
31+
client.search(baseDN.toString(), searchOpts, (err, res) => {
32+
t.error(err, 'search error')
33+
34+
let pages = 0
35+
const results = []
36+
res.on('searchEntry', (entry) => {
37+
results.push(entry)
38+
})
39+
40+
res.on('page', () => {
41+
pages += 1
42+
})
43+
44+
res.on('error', (err) => {
45+
t.error(err, 'search entry error')
46+
})
47+
48+
res.on('end', () => {
49+
t.equal(results.length, 2000)
50+
t.equal(pages, 20)
51+
52+
client.unbind(t.end)
53+
})
54+
})
55+
})

0 commit comments

Comments
 (0)