From 6e839ab78e7edd32b5b01ffc0a025ec64016e651 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Fri, 25 Oct 2024 15:56:46 +1100 Subject: [PATCH] fixup! chore: add localhost lookup test --- test/cli/host-test.js | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/test/cli/host-test.js b/test/cli/host-test.js index 3802dd2..05eadf2 100644 --- a/test/cli/host-test.js +++ b/test/cli/host-test.js @@ -69,28 +69,12 @@ function checkConnections (t, req, canConnect) { } } -test('localhost resolution', (t) => { - console.error('/etc/hosts\n' + fs.readFileSync('/etc/hosts', 'utf8')) - dns.lookup('localhost', (err, address, family) => { - t.error(err) - t.equal('127.0.0.1', address) - t.equal(4, family) - t.end() - }) -}) - testServer( 'Listening on all ports by default', [], null, ['127.0.0.1', 'localhost', otherAddress], [] ) -testServer( - 'Restricted to localhost', - ['--localhost'], 'localhost', - ['127.0.0.1', 'localhost'], [otherAddress] -) - testServer( 'Restricted to non-local host', ['--host', otherAddress], otherAddress, @@ -102,3 +86,14 @@ testServer( ['--host', '127.0.0.1'], '127.0.0.1', ['127.0.0.1'], ['::1'] ) + +dns.lookup('localhost', (err, address) => { + if (err) { + throw err + } + testServer( + 'Restricted to localhost', + ['--localhost'], 'localhost', + [address, 'localhost'], [otherAddress] + ) +})