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

Commit 5afa677

Browse files
committed
Also test timeout cases
1 parent c27e149 commit 5afa677

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/client.test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,3 +1477,28 @@ tap.test('connection refused', function (t) {
14771477
t.end()
14781478
})
14791479
})
1480+
1481+
tap.test('connection timeout', function (t) {
1482+
const client = ldap.createClient({
1483+
url: 'ldap://example.org',
1484+
connectTimeout: 1,
1485+
timeout: 1
1486+
})
1487+
1488+
var done = false
1489+
1490+
setTimeout(function () {
1491+
if (!done) {
1492+
throw new Error('LDAPJS waited for the server for too long')
1493+
}
1494+
}, 2000)
1495+
1496+
client.bind('cn=root', 'secret', function (err, res) {
1497+
t.true(err)
1498+
t.type(err, Error)
1499+
t.equals(err.message, 'connection timeout')
1500+
done = true
1501+
t.false(res)
1502+
t.end()
1503+
})
1504+
})

0 commit comments

Comments
 (0)