From 7763cf3789836487732c3545225763782703f924 Mon Sep 17 00:00:00 2001 From: Mark Cavage Date: Tue, 4 Oct 2011 10:27:43 -0700 Subject: [PATCH] GH-22: Client should preserve attribute type casing --- lib/attribute.js | 2 +- lib/messages/add_request.js | 3 ++- lib/messages/compare_request.js | 1 - lib/messages/ext_request.js | 1 - lib/messages/moddn_request.js | 1 - lib/messages/modify_request.js | 1 + tst/client.test.js | 4 +++- 7 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/attribute.js b/lib/attribute.js index 9a006e4..5d9a453 100644 --- a/lib/attribute.js +++ b/lib/attribute.js @@ -69,7 +69,7 @@ Attribute.prototype.parse = function(ber) { assert.ok(ber); ber.readSequence(); - this.type = ber.readString().toLowerCase(); + this.type = ber.readString(); if (ber.peek() === Protocol.LBER_SET) { if (ber.readSequence(Protocol.LBER_SET)) { diff --git a/lib/messages/add_request.js b/lib/messages/add_request.js index 0a73e5e..b78b0a9 100644 --- a/lib/messages/add_request.js +++ b/lib/messages/add_request.js @@ -63,6 +63,7 @@ AddRequest.prototype._parse = function(ber) { while (ber.offset < end) { var a = new Attribute(); a.parse(ber); + a.type = a.type.toLowerCase(); if (a.type === 'objectclass') { for (var i = 0; i < a.vals.length; i++) a.vals[i] = a.vals[i].toLowerCase(); @@ -127,7 +128,7 @@ AddRequest.prototype.attributeNames = function() { AddRequest.prototype.getAttribute = function(name) { if (!name || typeof(name) !== 'string') - throw new TypeEroror('attribute name (string) required'); + throw new TypeError('attribute name (string) required'); name = name.toLowerCase(); diff --git a/lib/messages/compare_request.js b/lib/messages/compare_request.js index 45abd14..d6bffad 100644 --- a/lib/messages/compare_request.js +++ b/lib/messages/compare_request.js @@ -7,7 +7,6 @@ var LDAPMessage = require('./message'); var LDAPResult = require('./result'); var dn = require('../dn'); -var Attribute = require('../attribute'); var Protocol = require('../protocol'); diff --git a/lib/messages/ext_request.js b/lib/messages/ext_request.js index e8ccd1d..e7024c2 100644 --- a/lib/messages/ext_request.js +++ b/lib/messages/ext_request.js @@ -9,7 +9,6 @@ var LDAPMessage = require('./message'); var LDAPResult = require('./result'); var dn = require('../dn'); -var Attribute = require('../attribute'); var Protocol = require('../protocol'); diff --git a/lib/messages/moddn_request.js b/lib/messages/moddn_request.js index e87681c..cdeab0f 100644 --- a/lib/messages/moddn_request.js +++ b/lib/messages/moddn_request.js @@ -9,7 +9,6 @@ var LDAPMessage = require('./message'); var LDAPResult = require('./result'); var dn = require('../dn'); -var Attribute = require('../attribute'); var Protocol = require('../protocol'); diff --git a/lib/messages/modify_request.js b/lib/messages/modify_request.js index 28e35c1..8ce17af 100644 --- a/lib/messages/modify_request.js +++ b/lib/messages/modify_request.js @@ -56,6 +56,7 @@ ModifyRequest.prototype._parse = function(ber) { while (ber.offset < end) { var c = new Change(); c.parse(ber); + c.modification.type = c.modification.type.toLowerCase(); this.changes.push(c); } diff --git a/tst/client.test.js b/tst/client.test.js index 6fc2fdf..3a968c5 100644 --- a/tst/client.test.js +++ b/tst/client.test.js @@ -82,7 +82,7 @@ test('setup', function(t) { objectName: req.dn, attributes: { cn: ['unit', 'test'], - sn: 'testy' + SN: 'testy' } }); res.send(e); @@ -345,6 +345,8 @@ test('search basic', function(t) { 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'); t.ok(entry.object); gotEntry++; });