From 6efc5e0c43a388fef3c5f4d40ffd1d2805d1e4e7 Mon Sep 17 00:00:00 2001 From: James Stenhouse Date: Sat, 4 Jul 2020 19:05:59 +1000 Subject: [PATCH 1/2] fix spaces in returned ObjectName --- lib/messages/search_entry.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/messages/search_entry.js b/lib/messages/search_entry.js index b6ba798..5bc6bfe 100644 --- a/lib/messages/search_entry.js +++ b/lib/messages/search_entry.js @@ -171,7 +171,8 @@ SearchEntry.prototype._parse = function (ber) { SearchEntry.prototype._toBer = function (ber) { assert.ok(ber) - ber.writeString(this.objectName.toString()) + var formattedObjectName = this.objectName.format({ skipSpace: true }) + ber.writeString(formattedObjectName) ber.startSequence() this.attributes.forEach(function (a) { // This may or may not be an attribute From 24d8a6f8b396605111ed006d9ecee396ced6c9a4 Mon Sep 17 00:00:00 2001 From: James Stenhouse Date: Tue, 28 Jul 2020 09:15:46 +1000 Subject: [PATCH 2/2] remove space from dn comparision --- test/client.test.js | 8 ++++---- test/messages/search_entry.test.js | 2 +- test/server.test.js | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/client.test.js b/test/client.test.js index fca862f..bd9b9a2 100644 --- a/test/client.test.js +++ b/test/client.test.js @@ -682,7 +682,7 @@ tap.test('search basic', function (t) { res.on('searchEntry', function (entry) { t.ok(entry) t.ok(entry instanceof ldap.SearchEntry) - t.equal(entry.dn.toString(), 'cn=test, ' + SUFFIX) + t.equal(entry.dn.toString(), 'cn=test,' + SUFFIX) t.ok(entry.attributes) t.ok(entry.attributes.length) t.equal(entry.attributes[0].type, 'cn') @@ -1118,7 +1118,7 @@ tap.test('GH-21 binary attributes', function (t) { res.on('searchEntry', function (entry) { t.ok(entry) t.ok(entry instanceof ldap.SearchEntry) - t.equal(entry.dn.toString(), 'cn=bin, ' + SUFFIX) + t.equal(entry.dn.toString(), 'cn=bin,' + SUFFIX) t.ok(entry.attributes) t.ok(entry.attributes.length) t.equal(entry.attributes[0].type, 'foo;binary') @@ -1159,7 +1159,7 @@ tap.test('GH-23 case insensitive attribute filtering', function (t) { res.on('searchEntry', function (entry) { t.ok(entry) t.ok(entry instanceof ldap.SearchEntry) - t.equal(entry.dn.toString(), 'cn=test, ' + SUFFIX) + t.equal(entry.dn.toString(), 'cn=test,' + SUFFIX) t.ok(entry.attributes) t.ok(entry.attributes.length) t.equal(entry.attributes[0].type, 'cn') @@ -1191,7 +1191,7 @@ tap.test('GH-24 attribute selection of *', function (t) { res.on('searchEntry', function (entry) { t.ok(entry) t.ok(entry instanceof ldap.SearchEntry) - t.equal(entry.dn.toString(), 'cn=test, ' + SUFFIX) + t.equal(entry.dn.toString(), 'cn=test,' + SUFFIX) t.ok(entry.attributes) t.ok(entry.attributes.length) t.equal(entry.attributes[0].type, 'cn') diff --git a/test/messages/search_entry.test.js b/test/messages/search_entry.test.js index a166ae0..e732edc 100644 --- a/test/messages/search_entry.test.js +++ b/test/messages/search_entry.test.js @@ -74,7 +74,7 @@ test('toBer', function (t) { t.equal(ber.readSequence(), 0x30) t.equal(ber.readInt(), 123) t.equal(ber.readSequence(), 0x64) - t.equal(ber.readString(), 'cn=foo, o=test') + t.equal(ber.readString(), 'cn=foo,o=test') t.ok(ber.readSequence()) t.ok(ber.readSequence()) diff --git a/test/server.test.js b/test/server.test.js index 5ec2528..74c5c1b 100644 --- a/test/server.test.js +++ b/test/server.test.js @@ -107,8 +107,8 @@ tap.test('route order', function (t) { const server = ldap.createServer() const sock = t.context.sock const dnShort = SUFFIX - const dnMed = 'dc=sub, ' + SUFFIX - const dnLong = 'dc=long, dc=sub, ' + SUFFIX + const dnMed = 'dc=sub,' + SUFFIX + const dnLong = 'dc=long,dc=sub,' + SUFFIX // Mount routes out of order server.search(dnMed, generateHandler(dnMed))