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 renamed to test/parallel/test-tls-reuse-host-from-socket.js

Lines changed: 12 additions & 6 deletions
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-
consttls=require('tls');
29-
3028
constnet=require('net');
29+
consttls=require('tls');
30+
constfixtures=require('../common/fixtures');
3131

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

0 commit comments

Comments
(0)