Prepare LDAP server for tests (#1118)

This commit is contained in:
Xavier Guimard 2017-03-01 18:14:50 +00:00
parent 85935955bf
commit 63e2b66674
2 changed files with 33 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
node_modules

View File

@ -0,0 +1,32 @@
var ldap = require('ldapjs');
var server = ldap.createServer();
server.search('dc=example,dc=com', function(req, res, next) {
var obj = [{
dn: 'dc=example,dc=com',
attributes: {
objectclass: ['dcObject', 'organization'],
o: 'example',
dc: 'example'
}
}, {
dn: 'uid=dwho,dc=example,dc=com',
attributes: {
objectclass: ['inetOrgPerson'],
uid: 'dwho',
cn: 'Dr Who',
mail: 'dwho@badwolf.org'
}
}];
for(var i=0; i<obj.length;i++) {
console.log(obj[i]);
if (req.filter.matches(obj[i])) res.send(obj);
}
res.end();
});
server.listen(1389, function() {
console.log('LDAP server listening at %s', server.url);
});