From b66da2c76ebbc522f1ec85d44d30afaf0d9983b4 Mon Sep 17 00:00:00 2001 From: Manfred Steiner Date: Mon, 26 Aug 2019 08:22:26 +0200 Subject: [PATCH] rebase to branch next, fixing issue #434 (can delete attributes) --- lib/change.js | 2 +- test/client.test.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/change.js b/lib/change.js index 4e23de8..c5fac30 100644 --- a/lib/change.js +++ b/lib/change.js @@ -82,7 +82,7 @@ Object.defineProperties(Change.prototype, { val[k].forEach(function (v) { _attr.addValue(v.toString()); }); - } else { + } else if (val[k] !== undefined && val[k] !== null) { _attr.addValue(val[k].toString()); } this._modification = _attr; diff --git a/test/client.test.js b/test/client.test.js index a4b39d8..7ca4a24 100644 --- a/test/client.test.js +++ b/test/client.test.js @@ -506,6 +506,22 @@ test('modify change plain object success', function (t) { }); +// https://github.com/ldapjs/node-ldapjs/pull/435 +test('can delete attributes', function (t) { + try { + var change = new Change({ + type: 'Delete', + modification: { cn: null } + }); + t.ok(true); + t.end(); + } catch (err) { + t.ifError(err); + t.end(); + } +}); + + test('modify array success', function (t) { var changes = [ new Change({