Properly dispatch unbind requests

Fix mcavage/node-ldapjs#197
This commit is contained in:
Patrick Mooney 2014-06-06 14:05:08 -05:00
parent 5a6e781293
commit d9b2b1378e
2 changed files with 36 additions and 10 deletions

View File

@ -795,16 +795,17 @@ Server.prototype._getHandlerChain = function _getHandlerChain(req, res) {
}
} else if (req.protocolOp === Protocol.LDAP_REQ_UNBIND) {
route = routes['unbind'];
return {
backend: route ? route.backend : self,
handlers: function getUnbindChain() {
if (route && route[op])
return route[op];
self.log.debug('%s unbind request %j', req.logId, req.json);
return [defaultNoOpHandler];
}
};
if (route) {
return {
backend: route.backend,
handlers: route[op]
};
} else {
return {
backend: self,
handlers: [defaultNoOpHandler]
};
}
} else if (req.protocolOp === Protocol.LDAP_REQ_ABANDON) {
return {
backend: self,

View File

@ -169,3 +169,28 @@ test('route absent', function (t) {
});
});
});
test('route unbind', function (t) {
t.plan(4);
server = ldap.createServer();
sock = getSock();
server.unbind(function (req, res, next) {
t.ok(true, 'server unbind successful');
res.end();
return next();
});
server.listen(sock, function () {
t.ok(true, 'server startup');
client = ldap.createClient({ socketPath: sock });
client.bind('', '', function (err) {
t.ifError(err, 'client bind error');
client.unbind(function (err) {
t.ifError(err, 'client unbind error');
server.close();
t.end();
});
});
});
});