Also test timeout cases

This commit is contained in:
Thomas P 2019-10-12 00:35:53 +02:00
parent c27e14960e
commit 5afa677209
No known key found for this signature in database
GPG Key ID: 722E1405F9F15F5E
1 changed files with 25 additions and 0 deletions

View File

@ -1477,3 +1477,28 @@ tap.test('connection refused', function (t) {
t.end()
})
})
tap.test('connection timeout', function (t) {
const client = ldap.createClient({
url: 'ldap://example.org',
connectTimeout: 1,
timeout: 1
})
var done = false
setTimeout(function () {
if (!done) {
throw new Error('LDAPJS waited for the server for too long')
}
}, 2000)
client.bind('cn=root', 'secret', function (err, res) {
t.true(err)
t.type(err, Error)
t.equals(err.message, 'connection timeout')
done = true
t.false(res)
t.end()
})
})