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

Commit 4a3113f

Browse files
authored
Merge branch 'master' into fix/anonbind
2 parents 8b2449c + b971204 commit 4a3113f

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

lib/client/client.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ Client.prototype.add = function add (name, entry, controls, callback) {
238238
save[k].forEach(function (v) {
239239
attr.addValue(v.toString())
240240
})
241+
} else if (Buffer.isBuffer(save[k])) {
242+
attr.addValue(save[k])
241243
} else {
242244
attr.addValue(save[k].toString())
243245
}

test/client.test.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,40 @@ tap.test('add success with object', function (t) {
508508
})
509509
})
510510

511+
tap.test('add buffer', function (t) {
512+
const { BerReader } = require('asn1')
513+
const dn = `cn=add, ${SUFFIX}`
514+
const attribute = 'thumbnailPhoto'
515+
const binary = 0xa5
516+
const entry = {
517+
[attribute]: Buffer.from([binary])
518+
}
519+
const write = t.context.client._socket.write
520+
t.context.client._socket.write = (data, encoding, cb) => {
521+
const reader = new BerReader(data)
522+
t.equal(data.byteLength, 49)
523+
t.ok(reader.readSequence())
524+
t.equal(reader.readInt(), 0x1)
525+
t.equal(reader.readSequence(), 0x68)
526+
t.equal(reader.readString(), dn)
527+
t.ok(reader.readSequence())
528+
t.ok(reader.readSequence())
529+
t.equal(reader.readString(), attribute)
530+
t.equal(reader.readSequence(), 0x31)
531+
t.equal(reader.readByte(), 0x4)
532+
t.equal(reader.readByte(), 1)
533+
t.equal(reader.readByte(), binary)
534+
t.context.client._socket.write = write
535+
t.context.client._socket.write(data, encoding, cb)
536+
}
537+
t.context.client.add(dn, entry, function (err, res) {
538+
t.error(err)
539+
t.ok(res)
540+
t.equal(res.status, 0)
541+
t.end()
542+
})
543+
})
544+
511545
tap.test('compare success', function (t) {
512546
t.context.client.compare('cn=compare, ' + SUFFIX, 'cn', 'test', function (err, matched, res) {
513547
t.error(err)

0 commit comments

Comments
 (0)