summaryrefslogtreecommitdiff
path: root/test/parallel/test-tls-junk-server.js
blob: 9b5ab6fdcc649d880cbf73506c639fc2467d8472 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'use strict';
const common = require('../common');

if (!common.hasCrypto) {
  common.skip('missing crypto');
  return;
}

const assert = require('assert');
const https = require('https');
const net = require('net');

const server = net.createServer(function(s) {
  s.once('data', function() {
    s.end('I was waiting for you, hello!', function() {
      s.destroy();
    });
  });
});

server.listen(0, function() {
  const req = https.request({ port: this.address().port });
  req.end();

  req.once('error', common.mustCall(function(err) {
    assert(/unknown protocol/.test(err.message));
    server.close();
  }));
});