test for multithreading support
tests for multithreading support via non-ldapjs-server and via hook into ldapjs server
This commit is contained in:
parent
6cce4f60cc
commit
534e3dd542
|
@ -331,3 +331,49 @@ tap.test('close passes error to callback', function (t) {
|
|||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
tap.test('multithreading support via external server', function (t) {
|
||||
let serverOptions = { }
|
||||
const server = ldap.createServer(serverOptions)
|
||||
const fauxServer = net.createServer(serverOptions, (connection) => {
|
||||
server.newConnection(connection)
|
||||
})
|
||||
fauxServer.log = serverOptions.log
|
||||
fauxServer.ldap = {
|
||||
config: serverOptions
|
||||
}
|
||||
t.ok(server)
|
||||
fauxServer.listen(5555, 'localhost', function () {
|
||||
t.ok(true, 'server listening on ' + server.url)
|
||||
|
||||
t.ok(fauxServer)
|
||||
const client = ldap.createClient({ url: 'ldap://127.0.0.1:5555' })
|
||||
client.on('connect', function () {
|
||||
t.ok(client)
|
||||
client.unbind()
|
||||
fauxServer.close(() => t.end())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
tap.test('multithreading support via hook', function (t) {
|
||||
let serverOptions = {
|
||||
connectionRouter: (connection) => {
|
||||
server.newConnection(connection)
|
||||
}
|
||||
}
|
||||
const server = ldap.createServer(serverOptions)
|
||||
const fauxServer = ldap.createServer(serverOptions)
|
||||
t.ok(server)
|
||||
fauxServer.listen(0, 'localhost', function () {
|
||||
t.ok(true, 'server listening on ' + server.url)
|
||||
|
||||
t.ok(fauxServer)
|
||||
const client = ldap.createClient({ url: fauxServer.url })
|
||||
client.on('connect', function () {
|
||||
t.ok(client)
|
||||
client.unbind()
|
||||
fauxServer.close(() => t.end())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue