Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.

Commit 534e3dd

Browse files
authored
test for multithreading support
tests for multithreading support via non-ldapjs-server and via hook into ldapjs server
1 parent 6cce4f6 commit 534e3dd

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

test/server.test.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,3 +331,49 @@ tap.test('close passes error to callback', function (t) {
331331
t.end()
332332
})
333333
})
334+
335+
tap.test('multithreading support via external server', function (t) {
336+
let serverOptions = { }
337+
const server = ldap.createServer(serverOptions)
338+
const fauxServer = net.createServer(serverOptions, (connection) => {
339+
server.newConnection(connection)
340+
})
341+
fauxServer.log = serverOptions.log
342+
fauxServer.ldap = {
343+
config: serverOptions
344+
}
345+
t.ok(server)
346+
fauxServer.listen(5555, 'localhost', function () {
347+
t.ok(true, 'server listening on ' + server.url)
348+
349+
t.ok(fauxServer)
350+
const client = ldap.createClient({ url: 'ldap://127.0.0.1:5555' })
351+
client.on('connect', function () {
352+
t.ok(client)
353+
client.unbind()
354+
fauxServer.close(() => t.end())
355+
})
356+
})
357+
})
358+
359+
tap.test('multithreading support via hook', function (t) {
360+
let serverOptions = {
361+
connectionRouter: (connection) => {
362+
server.newConnection(connection)
363+
}
364+
}
365+
const server = ldap.createServer(serverOptions)
366+
const fauxServer = ldap.createServer(serverOptions)
367+
t.ok(server)
368+
fauxServer.listen(0, 'localhost', function () {
369+
t.ok(true, 'server listening on ' + server.url)
370+
371+
t.ok(fauxServer)
372+
const client = ldap.createClient({ url: fauxServer.url })
373+
client.on('connect', function () {
374+
t.ok(client)
375+
client.unbind()
376+
fauxServer.close(() => t.end())
377+
})
378+
})
379+
})

0 commit comments

Comments
 (0)