Merge pull request #615 from rkaw92/612-tests-unused-tcp-port

This commit is contained in:
James Sumners 2020-05-21 08:05:42 -04:00 committed by GitHub
commit d8c428f1d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 27 deletions

View File

@ -27,6 +27,7 @@
"verror": "^1.8.1"
},
"devDependencies": {
"get-port": "^5.1.1",
"husky": "^3.0.4",
"snazzy": "^8.0.0",
"standard": "^14.0.2",

View File

@ -5,6 +5,7 @@ const assert = require('assert')
const tap = require('tap')
const uuid = require('uuid')
const vasync = require('vasync')
const getPort = require('get-port')
const { getSock } = require('./utils')
const ldap = require('../lib')
const { Attribute, Change } = ldap
@ -1495,8 +1496,9 @@ tap.test('resultError handling', function (t) {
})
tap.test('connection refused', function (t) {
getPort().then(function (unusedPortNumber) {
const client = ldap.createClient({
url: 'ldap://0.0.0.0'
url: `ldap://0.0.0.0:${unusedPortNumber}`
})
client.bind('cn=root', 'secret', function (err, res) {
@ -1506,11 +1508,13 @@ tap.test('connection refused', function (t) {
t.false(res)
t.end()
})
})
})
tap.test('connection timeout', function (t) {
getPort().then(function (unusedPortNumber) {
const client = ldap.createClient({
url: 'ldap://example.org',
url: `ldap://example.org:${unusedPortNumber}`,
connectTimeout: 1,
timeout: 1
})
@ -1531,4 +1535,5 @@ tap.test('connection timeout', function (t) {
t.false(res)
t.end()
})
})
})