Fix ensureDN (#918)
This commit is contained in:
parent
3c7b7cbedf
commit
0fcad2443d
|
@ -80,7 +80,7 @@ function validateControls (controls) {
|
||||||
|
|
||||||
function ensureDN (input) {
|
function ensureDN (input) {
|
||||||
if (DN.isDn(input)) {
|
if (DN.isDn(input)) {
|
||||||
return DN
|
return input
|
||||||
} else if (typeof (input) === 'string') {
|
} else if (typeof (input) === 'string') {
|
||||||
return DN.fromString(input)
|
return DN.fromString(input)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -10,6 +10,7 @@ const Attribute = require('@ldapjs/attribute')
|
||||||
const Change = require('@ldapjs/change')
|
const Change = require('@ldapjs/change')
|
||||||
const messages = require('@ldapjs/messages')
|
const messages = require('@ldapjs/messages')
|
||||||
const controls = require('@ldapjs/controls')
|
const controls = require('@ldapjs/controls')
|
||||||
|
const dn = require('@ldapjs/dn')
|
||||||
const ldap = require('../lib')
|
const ldap = require('../lib')
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -761,6 +762,36 @@ tap.test('search basic', function (t) {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
tap.test('search basic with DN', function (t) {
|
||||||
|
const { SearchResultEntry, SearchResultDone } = messages
|
||||||
|
|
||||||
|
t.context.client.search(dn.DN.fromString('cn=test, ' + SUFFIX, '(objectclass=*)'), function (err, res) {
|
||||||
|
t.error(err)
|
||||||
|
t.ok(res)
|
||||||
|
let gotEntry = 0
|
||||||
|
res.on('searchEntry', function (entry) {
|
||||||
|
t.ok(entry)
|
||||||
|
t.ok(entry instanceof SearchResultEntry)
|
||||||
|
t.equal(entry.dn.toString(), 'cn=test,' + SUFFIX)
|
||||||
|
t.ok(entry.attributes)
|
||||||
|
t.ok(entry.attributes.length)
|
||||||
|
t.equal(entry.attributes[0].type, 'cn')
|
||||||
|
t.equal(entry.attributes[1].type, 'SN')
|
||||||
|
gotEntry++
|
||||||
|
})
|
||||||
|
res.on('error', function (err) {
|
||||||
|
t.fail(err)
|
||||||
|
})
|
||||||
|
res.on('end', function (res) {
|
||||||
|
t.ok(res)
|
||||||
|
t.ok(res instanceof SearchResultDone)
|
||||||
|
t.equal(res.status, 0)
|
||||||
|
t.equal(gotEntry, 2)
|
||||||
|
t.end()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
tap.test('GH-602 search basic with delayed event listener binding', function (t) {
|
tap.test('GH-602 search basic with delayed event listener binding', function (t) {
|
||||||
t.context.client.search('cn=test, ' + SUFFIX, '(objectclass=*)', function (err, res) {
|
t.context.client.search('cn=test, ' + SUFFIX, '(objectclass=*)', function (err, res) {
|
||||||
t.error(err)
|
t.error(err)
|
||||||
|
|
Loading…
Reference in New Issue