GH-53 unable to parse !filters
This commit is contained in:
parent
c727ac922f
commit
0e30dc50c4
3
Makefile
3
Makefile
|
@ -23,7 +23,7 @@ RESTDOWN = ./node_modules/.restdown/bin/restdown \
|
||||||
-m ${DOCPKGDIR} \
|
-m ${DOCPKGDIR} \
|
||||||
-D mediaroot=media
|
-D mediaroot=media
|
||||||
|
|
||||||
.PHONY: dep lint test doc clean all
|
.PHONY: dep lint test doc clean all install
|
||||||
|
|
||||||
all:: test doc
|
all:: test doc
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ node_modules/.ldapjs.npm.installed:
|
||||||
@touch ./node_modules/.ldapjs.npm.installed
|
@touch ./node_modules/.ldapjs.npm.installed
|
||||||
|
|
||||||
dep: ./node_modules/.ldapjs.npm.installed
|
dep: ./node_modules/.ldapjs.npm.installed
|
||||||
|
install: dep
|
||||||
|
|
||||||
gjslint:
|
gjslint:
|
||||||
gjslint --nojsdoc -r lib -r tst
|
gjslint --nojsdoc -r lib -r tst
|
||||||
|
|
|
@ -12,16 +12,18 @@ var Protocol = require('../protocol');
|
||||||
///--- API
|
///--- API
|
||||||
|
|
||||||
function NotFilter(options) {
|
function NotFilter(options) {
|
||||||
if (typeof(options) !== 'object')
|
if (typeof(options) === 'object') {
|
||||||
throw new TypeError('options (object) required');
|
|
||||||
if (!options.filter || !(options.filter instanceof Filter))
|
if (!options.filter || !(options.filter instanceof Filter))
|
||||||
throw new TypeError('options.filter (Filter) required');
|
throw new TypeError('options.filter (Filter) required');
|
||||||
|
|
||||||
|
} else {
|
||||||
|
options = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
this.filter = options.filter || {};
|
||||||
options.type = Protocol.FILTER_NOT;
|
options.type = Protocol.FILTER_NOT;
|
||||||
Filter.call(this, options);
|
Filter.call(this, options);
|
||||||
|
|
||||||
this.filter = options.filter;
|
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this.__defineGetter__('json', function() {
|
this.__defineGetter__('json', function() {
|
||||||
return {
|
return {
|
||||||
|
@ -34,6 +36,12 @@ util.inherits(NotFilter, Filter);
|
||||||
module.exports = NotFilter;
|
module.exports = NotFilter;
|
||||||
|
|
||||||
|
|
||||||
|
NotFilter.prototype.addFilter = function(f) {
|
||||||
|
if (!(f instanceof Filter))
|
||||||
|
throw new TypeError('filter (Filter) required');
|
||||||
|
this.filter = f;
|
||||||
|
};
|
||||||
|
|
||||||
NotFilter.prototype.toString = function() {
|
NotFilter.prototype.toString = function() {
|
||||||
return '(!' + this.filter.toString() + ')';
|
return '(!' + this.filter.toString() + ')';
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,12 +26,7 @@ test('load library', function(t) {
|
||||||
|
|
||||||
|
|
||||||
test('Construct no args', function(t) {
|
test('Construct no args', function(t) {
|
||||||
try {
|
t.ok(new NotFilter());
|
||||||
new NotFilter();
|
|
||||||
t.fail('should have thrown');
|
|
||||||
} catch (e) {
|
|
||||||
t.ok(e instanceof TypeError);
|
|
||||||
}
|
|
||||||
t.end();
|
t.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -79,3 +79,18 @@ test('* substr filter (prefix)', function(t) {
|
||||||
t.equal(f.initial, 'bar');
|
t.equal(f.initial, 'bar');
|
||||||
t.end();
|
t.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
test('GH-53 NotFilter', function(t) {
|
||||||
|
var str = '(&(objectClass=person)(!(objectClass=shadowAccount)))';
|
||||||
|
var f = parse(str);
|
||||||
|
t.ok(f);
|
||||||
|
t.equal(f.type, 'and');
|
||||||
|
t.equal(f.filters.length, 2);
|
||||||
|
t.equal(f.filters[0].type, 'equal');
|
||||||
|
t.equal(f.filters[1].type, 'not');
|
||||||
|
t.equal(f.filters[1].filter.type, 'equal');
|
||||||
|
t.equal(f.filters[1].filter.attribute, 'objectClass');
|
||||||
|
t.equal(f.filters[1].filter.value, 'shadowAccount');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue