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

Commit

Permalink
Resolve issue #860
Browse files Browse the repository at this point in the history
  • Loading branch information
jsumners committed Aug 16, 2023
1 parent 7b869f4 commit 971f1bb
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 19 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
},
"main": "lib/index.js",
"dependencies": {
"@ldapjs/asn1": "2.0.0",
"@ldapjs/attribute": "1.0.0",
"@ldapjs/change": "1.0.0",
"@ldapjs/controls": "2.0.0",
"@ldapjs/dn": "1.1.0",
"@ldapjs/filter": "2.1.0",
"@ldapjs/messages": "^1.2.0",
"@ldapjs/asn1": "^2.0.0",
"@ldapjs/attribute": "^1.0.0",
"@ldapjs/change": "^1.0.0",
"@ldapjs/controls": "^2.0.0",
"@ldapjs/dn": "^1.1.0",
"@ldapjs/filter": "^2.1.1",
"@ldapjs/messages": "^1.2.1",
"@ldapjs/protocol": "^1.2.1",
"abstract-logging": "^2.0.1",
"assert-plus": "^1.0.0",
Expand Down
71 changes: 59 additions & 12 deletions test-integration/client/issue-860.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,33 @@ const baseURL = `${SCHEME}://${HOST}:${PORT}`

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

const opts = {
filter: '(&(objectClass=person))',
scope: 'sub',
paged: true,
sizeLimit: 100,
attributes: ['cn', 'employeeID']
}
tap.before(() => {
return new Promise((resolve, reject) => {
client.bind('cn=admin,dc=planetexpress,dc=com', 'GoodNewsEveryone', (err) => {
if (err) {
return reject(err)
}
resolve()
})
})
})

const baseDN = parseDN('ou=テスト,dc=planetexpress,dc=com')
tap.teardown(() => {
client.unbind()
})

tap.test('can search OUs with Japanese characters', t => {
client.bind('cn=admin,dc=planetexpress,dc=com', 'GoodNewsEveryone', (err) => {
t.error(err, 'bind error')
})
t.plan(2)

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) => {
t.error(err, 'search error')
Expand All @@ -42,7 +55,41 @@ tap.test('can search OUs with Japanese characters', t => {
t.error(err, 'search entry error')
})
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()
})
})
})

0 comments on commit 971f1bb

Please sign in to comment.