0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-http-invalid-urls.js
Anna Henningsen 15cd45c6fc
test: fix tests for non-crypto builds
Fix running the tests when node was compiled without crypto
support. Some of these are cleanup after 52bae222a3, where
common was used before it was required.

PR-URL: https://github.com/nodejs/node/pull/7056
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-06-08 11:42:28 +02:00

25 lines
621 B
JavaScript

'use strict';
const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
const assert = require('assert');
const http = require('http');
const https = require('https');
const error = 'Unable to determine the domain name';
function test(host) {
['get', 'request'].forEach((method) => {
[http, https].forEach((module) => {
assert.throws(() => module[method](host, () => {
throw new Error(`${module}.${method} should not connect to ${host}`);
}), error);
});
});
}
['www.nodejs.org', 'localhost', '127.0.0.1', 'http://:80/'].forEach(test);