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

Commit

Permalink
Merge pull request #754 from JohnTJohnston/clientFix
Browse files Browse the repository at this point in the history
  • Loading branch information
UziTech authored Aug 3, 2021
2 parents 3f13640 + bab1dfc commit b971204
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ Client.prototype.add = function add (name, entry, controls, callback) {
save[k].forEach(function (v) {
attr.addValue(v.toString())
})
} else if (Buffer.isBuffer(save[k])) {
attr.addValue(save[k])
} else {
attr.addValue(save[k].toString())
}
Expand Down
34 changes: 34 additions & 0 deletions test/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,40 @@ tap.test('add success with object', function (t) {
})
})

tap.test('add buffer', function (t) {
const { BerReader } = require('asn1')
const dn = `cn=add, ${SUFFIX}`
const attribute = 'thumbnailPhoto'
const binary = 0xa5
const entry = {
[attribute]: Buffer.from([binary])
}
const write = t.context.client._socket.write
t.context.client._socket.write = (data, encoding, cb) => {
const reader = new BerReader(data)
t.equal(data.byteLength, 49)
t.ok(reader.readSequence())
t.equal(reader.readInt(), 0x1)
t.equal(reader.readSequence(), 0x68)
t.equal(reader.readString(), dn)
t.ok(reader.readSequence())
t.ok(reader.readSequence())
t.equal(reader.readString(), attribute)
t.equal(reader.readSequence(), 0x31)
t.equal(reader.readByte(), 0x4)
t.equal(reader.readByte(), 1)
t.equal(reader.readByte(), binary)
t.context.client._socket.write = write
t.context.client._socket.write(data, encoding, cb)
}
t.context.client.add(dn, entry, function (err, res) {
t.error(err)
t.ok(res)
t.equal(res.status, 0)
t.end()
})
})

tap.test('compare success', function (t) {
t.context.client.compare('cn=compare, ' + SUFFIX, 'cn', 'test', function (err, matched, res) {
t.error(err)
Expand Down

0 comments on commit b971204

Please sign in to comment.