Skip to content

Commit 75d1612

Browse files
Trottrichardlau
authored andcommitted
test: make test-tls-reuse-host-from-socket pass without internet
Start up a TLS server on localhost rather than using example.org. PR-URL: #34953 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 2407a7a commit 75d1612

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

test/internet/test-tls-reuse-host-from-socket.js test/parallel/test-tls-reuse-host-from-socket.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,19 @@ const common = require('../common');
2525
if (!common.hasCrypto)
2626
common.skip('missing crypto');
2727

28-
const tls = require('tls');
29-
3028
const net = require('net');
29+
const tls = require('tls');
30+
const fixtures = require('../common/fixtures');
3131

32-
const socket = net.connect(443, 'www.example.org', common.mustCall(() => {
33-
const secureSocket = tls.connect({ socket }, common.mustCall(() => {
34-
secureSocket.destroy();
35-
console.log('ok');
32+
const server = tls.createServer({
33+
key: fixtures.readKey('agent1-key.pem'),
34+
cert: fixtures.readKey('agent1-cert.pem')
35+
}).listen(0, common.mustCall(() => {
36+
const socket = net.connect(server.address().port, common.mustCall(() => {
37+
const opts = { socket, rejectUnauthorized: false };
38+
const secureSocket = tls.connect(opts, common.mustCall(() => {
39+
secureSocket.destroy();
40+
server.close();
41+
}));
3642
}));
3743
}));

0 commit comments

Comments
 (0)