• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4if (!common.hasCrypto)
5  common.skip('missing crypto');
6
7const assert = require('assert');
8const https = require('https');
9const tls = require('tls');
10
11const dftProtocol = {};
12
13// Test for immutable `opts`
14{
15  const opts = { foo: 'bar', ALPNProtocols: [ 'http/1.1' ] };
16  const server = https.createServer(opts);
17
18  tls.convertALPNProtocols([ 'http/1.1' ], dftProtocol);
19  assert.deepStrictEqual(opts, { foo: 'bar', ALPNProtocols: [ 'http/1.1' ] });
20  assert.strictEqual(server.ALPNProtocols.compare(dftProtocol.ALPNProtocols),
21                     0);
22}
23
24
25// Validate that `createServer` can work with the only argument requestListener
26{
27  const mustNotCall = common.mustNotCall();
28  const server = https.createServer(mustNotCall);
29
30  tls.convertALPNProtocols([ 'http/1.1' ], dftProtocol);
31  assert.strictEqual(server.ALPNProtocols.compare(dftProtocol.ALPNProtocols),
32                     0);
33  assert.strictEqual(server.listeners('request').length, 1);
34  assert.strictEqual(server.listeners('request')[0], mustNotCall);
35}
36
37
38// Validate that `createServer` can work with no arguments
39{
40  const server = https.createServer();
41
42  assert.strictEqual(server.ALPNProtocols.compare(dftProtocol.ALPNProtocols),
43                     0);
44  assert.strictEqual(server.listeners('request').length, 0);
45}
46