Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ldap-filters

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ldap-filters - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

2

package.json
{
"name": "ldap-filters",
"version": "0.1.4",
"version": "0.1.5",
"description": "Library for generating, parsing, and evaluating LDAP filters",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -87,4 +87,4 @@ node-ldap-filters

A (currently incomplete) test suite is included. To run it, you will
need to have mocha and chai installed. Mocha should be installed globally.
A complete test suite is included. To run it, you will
need to have mocha and chai installed. Mocha should be installed globally (need sudo?).

@@ -115,3 +115,3 @@ ```bash

```bash
# Install jison globally
# Install jison globally (need sudo?)
npm install -g jison

@@ -129,4 +129,4 @@

The jison parser source was originally written by
[tantaman](http://github.com/tantaman/) found in the
[DATS-DAP](/tantaman/DATS-DAP) repository.
[tantaman](https://github.com/tantaman/) found in the
[DATS-DAP](https://github.com/tantaman/DATS-DAP) repository.
var should = require('chai').should();
var Filter = require('../index');
var expect = require('chai').expect;
//var assert = require('chai').assert;

@@ -58,2 +57,54 @@ describe('Matching',function(){

it ('attribute greater than or equal',function(done){
// Numeric
var filter = Filter.attribute('age').gte('5');
expect(filter.match({age:4})).to.be.false;
expect(filter.match({age:'4'})).to.be.false;
expect(filter.match({age:5})).to.be.true;
expect(filter.match({age:'5'})).to.be.true;
expect(filter.match({age:6})).to.be.true;
expect(filter.match({age:'6'})).to.be.true;
expect(filter.match({})).to.be.false;
// Lexical
filter = Filter.attribute('sn').gte('bell');
expect(filter.match({sn:'ace'})).to.be.false;
expect(filter.match({sn:'bell'})).to.be.true;
expect(filter.match({sn:'call'})).to.be.true;
done();
});
it ('attribute less than or equal',function(done){
// Numeric
var filter = Filter.attribute('age').lte('5');
expect(filter.match({age:5})).to.be.true;
expect(filter.match({age:'5'})).to.be.true;
expect(filter.match({age:6})).to.be.false;
expect(filter.match({age:'6'})).to.be.false;
expect(filter.match({age:'4'})).to.be.true;
expect(filter.match({age:4})).to.be.true;
expect(filter.match({})).to.be.false;
// Lexical
filter = Filter.attribute('sn').lte('bell');
expect(filter.match({sn:'ace'})).to.be.true;
expect(filter.match({sn:'bell'})).to.be.true;
expect(filter.match({sn:'call'})).to.be.false;
done();
});
// IMO Soundex isn't a really intelligent underlying algorithm;
// but I don't think people really use the approximate match
// very often in real world situations. Part of the reason is
// probably due to the fact the actual behavior is not
// well defined and left up to the server implementation.
//
// See this page: https://www.ldap.com/ldap-filters
// "Many servers use a 'sounds like' mechanism with an algorithm
// based on Soundex or one of the Metaphone variants."
it('basic approx test ("sounds like")',function(done){

@@ -67,2 +118,4 @@ var filter = Filter.attribute('gn').approx('jenny');

// Aggregate filters
it('aggregate AND',function(done){

@@ -107,5 +160,7 @@ var filter = Filter.AND([

expect(filter.match({info:'(test)'})).to.be.false;
expect(filter.match({})).to.be.false;
done();
});
// This is kind of a mishmash
it('complex filter and object match',function(done){

@@ -132,2 +187,4 @@ var filter = Filter.AND([

expect(filter.match({})).to.be.false;
done();

@@ -134,0 +191,0 @@ });

@@ -8,2 +8,7 @@ var should = require('chai').should();

// To test the parsing, a correctly written filter is parsed and
// written back to a string, then compared to the original input.
// While this is probably a good way to test correct parsing, it
// doesn't test that the parsed object is exactly what is expected.
// I've concluded this type of problem is the bane of unit testing.
it('parse small filter',function(done){

@@ -23,3 +28,4 @@ var filter = '(sn=smith)';

it('perform a match against a parsed filter',function(done){
it('matching against parsed filter',function(done){
// Test for a match
var filter = '(&(sn=jensen)(gn=jenny))';

@@ -29,10 +35,7 @@ var parsed = Filter.parse(filter);

expect(parsed.match(data)).to.be.true;
done();
});
it('non-matching data does not match parsed filter',function(done){
var filter = '(&(sn=jensen)(gn=jenny))';
var parsed = Filter.parse(filter);
var data = { sn: 'Jensen' };
// Non-match
data = { sn: 'Jensen' };
expect(parsed.match(data)).to.be.false;
done();

@@ -39,0 +42,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc