Also test timeout cases
This commit is contained in:
parent
c27e14960e
commit
5afa677209
|
@ -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()
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue