diff --git a/test/cli/host-test.js b/test/cli/host-test.js index 780c6bc..8469552 100644 --- a/test/cli/host-test.js +++ b/test/cli/host-test.js @@ -1,4 +1,5 @@ const os = require('os') +const dns = require('dns') let { test, fail, comment } = require('tap') const { serve } = require('./common') const port = 1338 @@ -73,12 +74,6 @@ testServer( ['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, @@ -90,3 +85,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] + ) +}) diff --git a/test/multi-mount.js b/test/multi-mount.js index 10e71cc..bd86060 100644 --- a/test/multi-mount.js +++ b/test/multi-mount.js @@ -90,7 +90,7 @@ test('setup middleware server', function (t) { }) }) }) - middlewareServer.listen(port, '127.0.0.1', function () { + middlewareServer.listen(port, 'localhost', function () { t.pass('listening') t.end() }) @@ -103,7 +103,7 @@ test('setup regular server', function (t) { return res.end(`Not a match: ${req.url}`) } }) - server.listen(port + 1, '127.0.0.1', function () { + server.listen(port + 1, 'localhost', function () { t.pass('listening') t.end() }) @@ -114,6 +114,7 @@ const stExpect = fs.readFileSync(require.resolve('../st.js')).toString() test('/test/st.js', function (t) { req('/test/st.js', function (er, res, body) { + t.error(er) t.equal(res.statusCode, 200) t.ok(res.headers.etag) stEtag = res.headers.etag