diff --git a/package.json b/package.json index 60c8cc98..c73e455b 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test-integration/client/issue-860.test.js b/test-integration/client/issue-860.test.js index 9b3aad06..e7e6e05b 100644 --- a/test-integration/client/issue-860.test.js +++ b/test-integration/client/issue-860.test.js @@ -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') @@ -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() }) }) })