Resolve issue #860
This commit is contained in:
parent
7b869f4a9d
commit
971f1bbc3b
14
package.json
14
package.json
|
@ -11,13 +11,13 @@
|
||||||
},
|
},
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ldapjs/asn1": "2.0.0",
|
"@ldapjs/asn1": "^2.0.0",
|
||||||
"@ldapjs/attribute": "1.0.0",
|
"@ldapjs/attribute": "^1.0.0",
|
||||||
"@ldapjs/change": "1.0.0",
|
"@ldapjs/change": "^1.0.0",
|
||||||
"@ldapjs/controls": "2.0.0",
|
"@ldapjs/controls": "^2.0.0",
|
||||||
"@ldapjs/dn": "1.1.0",
|
"@ldapjs/dn": "^1.1.0",
|
||||||
"@ldapjs/filter": "2.1.0",
|
"@ldapjs/filter": "^2.1.1",
|
||||||
"@ldapjs/messages": "^1.2.0",
|
"@ldapjs/messages": "^1.2.1",
|
||||||
"@ldapjs/protocol": "^1.2.1",
|
"@ldapjs/protocol": "^1.2.1",
|
||||||
"abstract-logging": "^2.0.1",
|
"abstract-logging": "^2.0.1",
|
||||||
"assert-plus": "^1.0.0",
|
"assert-plus": "^1.0.0",
|
||||||
|
|
|
@ -11,20 +11,33 @@ const baseURL = `${SCHEME}://${HOST}:${PORT}`
|
||||||
|
|
||||||
const client = ldapjs.createClient({ url: baseURL })
|
const client = ldapjs.createClient({ url: baseURL })
|
||||||
|
|
||||||
const opts = {
|
tap.before(() => {
|
||||||
filter: '(&(objectClass=person))',
|
return new Promise((resolve, reject) => {
|
||||||
scope: 'sub',
|
client.bind('cn=admin,dc=planetexpress,dc=com', 'GoodNewsEveryone', (err) => {
|
||||||
paged: true,
|
if (err) {
|
||||||
sizeLimit: 100,
|
return reject(err)
|
||||||
attributes: ['cn', 'employeeID']
|
}
|
||||||
}
|
resolve()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
const baseDN = parseDN('ou=テスト,dc=planetexpress,dc=com')
|
tap.teardown(() => {
|
||||||
|
client.unbind()
|
||||||
|
})
|
||||||
|
|
||||||
tap.test('can search OUs with Japanese characters', t => {
|
tap.test('can search OUs with Japanese characters', t => {
|
||||||
client.bind('cn=admin,dc=planetexpress,dc=com', 'GoodNewsEveryone', (err) => {
|
t.plan(2)
|
||||||
t.error(err, 'bind error')
|
|
||||||
})
|
const opts = {
|
||||||
|
filter: '(&(objectClass=person))',
|
||||||
|
scope: 'sub',
|
||||||
|
paged: true,
|
||||||
|
sizeLimit: 100,
|
||||||
|
attributes: ['cn', 'employeeID']
|
||||||
|
}
|
||||||
|
|
||||||
|
const baseDN = parseDN('ou=テスト,dc=planetexpress,dc=com')
|
||||||
|
|
||||||
client.search(baseDN.toString(), opts, (err, res) => {
|
client.search(baseDN.toString(), opts, (err, res) => {
|
||||||
t.error(err, 'search error')
|
t.error(err, 'search error')
|
||||||
|
@ -42,7 +55,41 @@ tap.test('can search OUs with Japanese characters', t => {
|
||||||
t.error(err, 'search entry error')
|
t.error(err, 'search entry error')
|
||||||
})
|
})
|
||||||
res.on('end', () => {
|
res.on('end', () => {
|
||||||
client.unbind(t.end)
|
t.end()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
tap.test('can search with non-ascii chars in filter', t => {
|
||||||
|
t.plan(3)
|
||||||
|
|
||||||
|
const opts = {
|
||||||
|
filter: '(&(sn=Rodríguez))',
|
||||||
|
scope: 'sub',
|
||||||
|
attributes: ['dn', 'sn', 'cn'],
|
||||||
|
type: 'user'
|
||||||
|
}
|
||||||
|
|
||||||
|
let searchEntryCount = 0
|
||||||
|
client.search('dc=planetexpress,dc=com', opts, (err, res) => {
|
||||||
|
t.error(err, 'search error')
|
||||||
|
res.on('searchEntry', (entry) => {
|
||||||
|
searchEntryCount += 1
|
||||||
|
t.match(entry.pojo, {
|
||||||
|
type: 'SearchResultEntry',
|
||||||
|
objectName: 'cn=Bender Bending Rodr\\c3\\adguez,ou=people,dc=planetexpress,dc=com',
|
||||||
|
attributes: [{
|
||||||
|
type: 'cn',
|
||||||
|
values: ['Bender Bending Rodríguez']
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
})
|
||||||
|
res.on('error', (err) => {
|
||||||
|
t.error(err, 'search entry error')
|
||||||
|
})
|
||||||
|
res.on('end', () => {
|
||||||
|
t.equal(searchEntryCount, 1, 'should have found 1 entry')
|
||||||
|
t.end()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue