Merge remote branch 'upstream/master'

This commit is contained in:
Trent Mick 2011-08-26 11:01:01 -07:00
commit a2cb56506e
4 changed files with 98 additions and 3 deletions

View File

@ -24,7 +24,7 @@
<div id="fadeout"></div>
<div id="header">
<span id="logo">
<a id="homelink" href="http://ldapjs.org">ldap</a>
<a id="homelink" href="http://ldapjs.org">ldapjs</a>
</span>
<a class="navbutton" href="guide.html">Guide</a>

View File

@ -245,7 +245,7 @@ The sample record above maps to:
||/home/jsmith||the user's home directory.||
||/bin/sh||the user's shell.||
Let's some handlers to parse that and transform it into an LDAP search
Let's write some handlers to parse that and transform it into an LDAP search
record (note, you'll need to add `var fs = require('fs');` at the top of the
source file).

View File

@ -50,7 +50,7 @@ ldapjs implements most of the common operations in the LDAP v3 RFC(s), for
both client and server. It is 100% wire-compatible with the LDAP protocol
itself, and is interoperable with [OpenLDAP](http://openldap.org) and any other
LDAPv3-compliant implementation. ldapjs gives you a powerful routing and
intercepting filter" pattern for implementing server(s). It is intended
"intercepting filter" pattern for implementing server(s). It is intended
that you can build LDAP over anything you want, not just traditional databases.
# Getting started

95
tst/laundry.test.js Normal file
View File

@ -0,0 +1,95 @@
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
var test = require('tap').test;
var uuid = require('node-uuid');
var ldap = require('../lib/index');
///--- Globals
var SOCKET = '/tmp/.' + uuid();
var client;
var server;
///--- Tests
test('setup', function(t) {
server = ldap.createServer();
t.ok(server);
server.listen(SOCKET, function() {
client = client = ldap.createClient({
socketPath: SOCKET
});
t.ok(client);
// client.log4js.setLevel('Debug');
t.end();
});
});
test('Evolution search filter (GH-3)', function(t) {
var suffix = 'dc=' + uuid();
var entry = {
dn: 'cn=foo, ' + suffix,
attributes: {
objectclass: ['person', 'top'],
cn: 'Pogo Stick',
sn: 'Stick',
givenname: 'ogo',
mail: uuid() + '@pogostick.org'
}
};
server.search(suffix, function(req, res, next) {
console.log(req.filter.toString());
if (req.filter.matches(entry.attributes))
res.send(entry);
res.end();
});
// This is what Evolution sends, when searching for a contact 'ogo'. Wow.
var filter =
'(|(cn=ogo*)(givenname=ogo*)(sn=ogo*)(mail=ogo*)(member=ogo*)' +
'(primaryphone=ogo*)(telephonenumber=ogo*)(homephone=ogo*)(mobile=ogo*)' +
'(carphone=ogo*)(facsimiletelephonenumber=ogo*)' +
'(homefacsimiletelephonenumber=ogo*)(otherphone=ogo*)' +
'(otherfacsimiletelephonenumber=ogo*)(internationalisdnnumber=ogo*)' +
'(pager=ogo*)(radio=ogo*)(telex=ogo*)(assistantphone=ogo*)' +
'(companyphone=ogo*)(callbackphone=ogo*)(tty=ogo*)(o=ogo*)(ou=ogo*)' +
'(roomnumber=ogo*)(title=ogo*)(businessrole=ogo*)(managername=ogo*)' +
'(assistantname=ogo*)(postaladdress=ogo*)(l=ogo*)(st=ogo*)' +
'(postofficebox=ogo*)(postalcode=ogo*)(c=ogo*)(homepostaladdress=ogo*)' +
'(mozillahomelocalityname=ogo*)(mozillahomestate=ogo*)' +
'(mozillahomepostalcode=ogo*)(mozillahomecountryname=ogo*)' +
'(otherpostaladdress=ogo*)(jpegphoto=ogo*)(usercertificate=ogo*)' +
'(labeleduri=ogo*)(displayname=ogo*)(spousename=ogo*)(note=ogo*)' +
'(anniversary=ogo*)(birthdate=ogo*)(mailer=ogo*)(fileas=ogo*)' +
'(category=ogo*)(calcaluri=ogo*)(calfburl=ogo*)(icscalendar=ogo*))';
client.search(suffix, filter, function(err, res) {
t.ifError(err);
t.ok(res);
var found = false;
res.on('searchEntry', function(entry) {
t.ok(entry);
found = true;
});
res.on('end', function() {
t.ok(found);
t.end();
});
});
});
test('shutdown', function(t) {
client.unbind(function() {
server.on('close', function() {
t.end();
});
server.close();
});
});