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

Commit 0558c1a

Browse files
committed
Add test for issue #883
1 parent bdaaf29 commit 0558c1a

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
'use strict'
2+
3+
const tap = require('tap')
4+
const ldapjs = require('../../lib')
5+
6+
const SCHEME = process.env.SCHEME || 'ldap'
7+
const HOST = process.env.HOST || '127.0.0.1'
8+
const PORT = process.env.PORT || 389
9+
const baseURL = `${SCHEME}://${HOST}:${PORT}`
10+
11+
const client = ldapjs.createClient({ url: baseURL })
12+
13+
tap.test('adds entries with Korean characters', t => {
14+
t.plan(4)
15+
16+
client.bind('cn=admin,dc=planetexpress,dc=com', 'GoodNewsEveryone', (err) => {
17+
t.error(err, 'bind error')
18+
})
19+
20+
const nm = '홍길동'
21+
const dn = `cn=${nm},ou=people,dc=planetexpress,dc=com`
22+
const entry = {
23+
objectclass: 'person',
24+
sn: 'korean test'
25+
}
26+
27+
client.add(dn, entry, err => {
28+
t.error(err, 'add entry error')
29+
30+
const searchOpts = {
31+
filter: '(sn=korean test)',
32+
scope: 'subtree',
33+
attributes: ['cn', 'sn'],
34+
sizeLimit: 10,
35+
timeLimit: 0
36+
}
37+
client.search('ou=people,dc=planetexpress,dc=com', searchOpts, (err, res) => {
38+
t.error(err, 'search error')
39+
40+
res.on('searchEntry', (entry) => {
41+
t.equal(
42+
entry.attributes.filter(a => a.type === 'cn').pop().values.pop(),
43+
nm
44+
)
45+
})
46+
47+
res.on('error', (err) => {
48+
t.error(err, 'search entry error')
49+
})
50+
51+
res.on('end', () => {
52+
client.unbind(t.end)
53+
})
54+
})
55+
})
56+
})

0 commit comments

Comments
 (0)