node/test/parallel/test-https-argument-of-creating.js
Ben Noordhuis 5bfbe5ceae tls: drop NPN (next protocol negotiation) support
NPN has been superseded by ALPN.  Chrome and Firefox removed support for
NPN in 2016 and 2017 respectively to no ill effect.

Fixes: https://github.com/nodejs/node/issues/14602
PR-URL: https://github.com/nodejs/node/pull/19403
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2018-03-27 16:22:37 +02:00

46 lines
1.3 KiB
JavaScript

'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const https = require('https');
const tls = require('tls');
const dftProtocol = {};
// test for immutable `opts`
{
const opts = { foo: 'bar', ALPNProtocols: [ 'http/1.1' ] };
const server = https.createServer(opts);
tls.convertALPNProtocols([ 'http/1.1' ], dftProtocol);
assert.deepStrictEqual(opts, { foo: 'bar', ALPNProtocols: [ 'http/1.1' ] });
assert.strictEqual(server.ALPNProtocols.compare(dftProtocol.ALPNProtocols),
0);
}
// validate that `createServer` can work with the only argument requestListener
{
const mustNotCall = common.mustNotCall();
const server = https.createServer(mustNotCall);
tls.convertALPNProtocols([ 'http/1.1' ], dftProtocol);
assert.strictEqual(server.ALPNProtocols.compare(dftProtocol.ALPNProtocols),
0);
assert.strictEqual(server.listeners('request').length, 1);
assert.strictEqual(server.listeners('request')[0], mustNotCall);
}
// validate that `createServer` can work with no arguments
{
const server = https.createServer();
assert.strictEqual(server.ALPNProtocols.compare(dftProtocol.ALPNProtocols),
0);
assert.strictEqual(server.listeners('request').length, 0);
}