aboutsummaryrefslogtreecommitdiff
path: root/test/parallel
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2018-03-17 05:13:47 +0100
committerBen Noordhuis <info@bnoordhuis.nl>2018-03-27 16:22:37 +0200
commit5bfbe5ceaecb6412b176db446caf00f77f84bae7 (patch)
tree4c3a6696de1c1116046144473cac5e1389564790 /test/parallel
parentb3f23910a25613eb289fe4b338f83783a9f731b3 (diff)
downloadandroid-node-v8-5bfbe5ceaecb6412b176db446caf00f77f84bae7.tar.gz
android-node-v8-5bfbe5ceaecb6412b176db446caf00f77f84bae7.tar.bz2
android-node-v8-5bfbe5ceaecb6412b176db446caf00f77f84bae7.zip
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>
Diffstat (limited to 'test/parallel')
-rw-r--r--test/parallel/test-https-argument-of-creating.js17
-rw-r--r--test/parallel/test-tls-alpn-server-client.js435
-rw-r--r--test/parallel/test-tls-npn-server-client.js118
-rw-r--r--test/parallel/test-tls-socket-constructor-alpn-options-parsing.js (renamed from test/parallel/test-tls-socket-constructor-alpn-npn-options-parsing.js)29
4 files changed, 51 insertions, 548 deletions
diff --git a/test/parallel/test-https-argument-of-creating.js b/test/parallel/test-https-argument-of-creating.js
index 5a4150eb1c..0630028406 100644
--- a/test/parallel/test-https-argument-of-creating.js
+++ b/test/parallel/test-https-argument-of-creating.js
@@ -12,12 +12,13 @@ const dftProtocol = {};
// test for immutable `opts`
{
- const opts = { foo: 'bar', NPNProtocols: [ 'http/1.1' ] };
+ const opts = { foo: 'bar', ALPNProtocols: [ 'http/1.1' ] };
const server = https.createServer(opts);
- tls.convertNPNProtocols([ 'http/1.1' ], dftProtocol);
- assert.deepStrictEqual(opts, { foo: 'bar', NPNProtocols: [ 'http/1.1' ] });
- assert.strictEqual(server.NPNProtocols.compare(dftProtocol.NPNProtocols), 0);
+ tls.convertALPNProtocols([ 'http/1.1' ], dftProtocol);
+ assert.deepStrictEqual(opts, { foo: 'bar', ALPNProtocols: [ 'http/1.1' ] });
+ assert.strictEqual(server.ALPNProtocols.compare(dftProtocol.ALPNProtocols),
+ 0);
}
@@ -26,8 +27,9 @@ const dftProtocol = {};
const mustNotCall = common.mustNotCall();
const server = https.createServer(mustNotCall);
- tls.convertNPNProtocols([ 'http/1.1', 'http/1.0' ], dftProtocol);
- assert.strictEqual(server.NPNProtocols.compare(dftProtocol.NPNProtocols), 0);
+ 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);
}
@@ -37,6 +39,7 @@ const dftProtocol = {};
{
const server = https.createServer();
- assert.strictEqual(server.NPNProtocols.compare(dftProtocol.NPNProtocols), 0);
+ assert.strictEqual(server.ALPNProtocols.compare(dftProtocol.ALPNProtocols),
+ 0);
assert.strictEqual(server.listeners('request').length, 0);
}
diff --git a/test/parallel/test-tls-alpn-server-client.js b/test/parallel/test-tls-alpn-server-client.js
index 44699b2053..8b8ae3e5cf 100644
--- a/test/parallel/test-tls-alpn-server-client.js
+++ b/test/parallel/test-tls-alpn-server-client.js
@@ -4,9 +4,9 @@ const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
-if (!process.features.tls_alpn || !process.features.tls_npn) {
+if (!process.features.tls_alpn) {
common.skip(
- 'Skipping because node compiled without NPN or ALPN feature of OpenSSL.');
+ 'Skipping because node compiled without ALPN feature of OpenSSL.');
}
const assert = require('assert');
@@ -21,9 +21,7 @@ const serverIP = common.localhostIPv4;
function checkResults(result, expected) {
assert.strictEqual(result.server.ALPN, expected.server.ALPN);
- assert.strictEqual(result.server.NPN, expected.server.NPN);
assert.strictEqual(result.client.ALPN, expected.client.ALPN);
- assert.strictEqual(result.client.NPN, expected.client.NPN);
}
function runTest(clientsOptions, serverOptions, cb) {
@@ -32,7 +30,7 @@ function runTest(clientsOptions, serverOptions, cb) {
const results = [];
let index = 0;
const server = tls.createServer(serverOptions, function(c) {
- results[index].server = { ALPN: c.alpnProtocol, NPN: c.npnProtocol };
+ results[index].server = { ALPN: c.alpnProtocol };
});
server.listen(0, serverIP, function() {
@@ -47,8 +45,7 @@ function runTest(clientsOptions, serverOptions, cb) {
results[index] = {};
const client = tls.connect(opt, function() {
- results[index].client = { ALPN: client.alpnProtocol,
- NPN: client.npnProtocol };
+ results[index].client = { ALPN: client.alpnProtocol };
client.destroy();
if (options.length) {
index++;
@@ -62,113 +59,42 @@ function runTest(clientsOptions, serverOptions, cb) {
}
-// Server: ALPN/NPN, Client: ALPN/NPN
+// Server: ALPN, Client: ALPN
function Test1() {
const serverOptions = {
ALPNProtocols: ['a', 'b', 'c'],
- NPNProtocols: ['a', 'b', 'c']
};
const clientsOptions = [{
ALPNProtocols: ['a', 'b', 'c'],
- NPNProtocols: ['a', 'b', 'c']
}, {
ALPNProtocols: ['c', 'b', 'e'],
- NPNProtocols: ['c', 'b', 'e']
}, {
ALPNProtocols: ['first-priority-unsupported', 'x', 'y'],
- NPNProtocols: ['first-priority-unsupported', 'x', 'y']
}];
runTest(clientsOptions, serverOptions, function(results) {
// 'a' is selected by ALPN
checkResults(results[0],
- { server: { ALPN: 'a', NPN: false },
- client: { ALPN: 'a', NPN: undefined } });
+ { server: { ALPN: 'a' },
+ client: { ALPN: 'a' } });
// 'b' is selected by ALPN
checkResults(results[1],
- { server: { ALPN: 'b', NPN: false },
- client: { ALPN: 'b', NPN: undefined } });
+ { server: { ALPN: 'b' },
+ client: { ALPN: 'b' } });
// nothing is selected by ALPN
checkResults(results[2],
- { server: { ALPN: false, NPN: 'first-priority-unsupported' },
- client: { ALPN: false, NPN: false } });
+ { server: { ALPN: false },
+ client: { ALPN: false } });
// execute next test
Test2();
});
}
-// Server: ALPN/NPN, Client: ALPN
+// Server: ALPN, Client: Nothing
function Test2() {
const serverOptions = {
ALPNProtocols: ['a', 'b', 'c'],
- NPNProtocols: ['a', 'b', 'c']
- };
-
- const clientsOptions = [{
- ALPNProtocols: ['a', 'b', 'c']
- }, {
- ALPNProtocols: ['c', 'b', 'e']
- }, {
- ALPNProtocols: ['first-priority-unsupported', 'x', 'y']
- }];
-
- runTest(clientsOptions, serverOptions, function(results) {
- // 'a' is selected by ALPN
- checkResults(results[0],
- { server: { ALPN: 'a', NPN: false },
- client: { ALPN: 'a', NPN: undefined } });
- // 'b' is selected by ALPN
- checkResults(results[1],
- { server: { ALPN: 'b', NPN: false },
- client: { ALPN: 'b', NPN: undefined } });
- // nothing is selected by ALPN
- checkResults(results[2],
- { server: { ALPN: false, NPN: 'http/1.1' },
- client: { ALPN: false, NPN: false } });
- // execute next test
- Test3();
- });
-}
-
-// Server: ALPN/NPN, Client: NPN
-function Test3() {
- const serverOptions = {
- ALPNProtocols: ['a', 'b', 'c'],
- NPNProtocols: ['a', 'b', 'c']
- };
-
- const clientsOptions = [{
- NPNProtocols: ['a', 'b', 'c']
- }, {
- NPPNProtocols: ['c', 'b', 'e']
- }, {
- NPPNProtocols: ['first-priority-unsupported', 'x', 'y']
- }];
-
- runTest(clientsOptions, serverOptions, function(results) {
- // 'a' is selected by NPN
- checkResults(results[0],
- { server: { ALPN: false, NPN: 'a' },
- client: { ALPN: false, NPN: 'a' } });
- // nothing is selected by ALPN
- checkResults(results[1],
- { server: { ALPN: false, NPN: 'http/1.1' },
- client: { ALPN: false, NPN: false } });
- // nothing is selected by ALPN
- checkResults(results[2],
- { server: { ALPN: false, NPN: 'http/1.1' },
- client: { ALPN: false, NPN: false } });
- // execute next test
- Test4();
- });
-}
-
-// Server: ALPN/NPN, Client: Nothing
-function Test4() {
- const serverOptions = {
- ALPNProtocols: ['a', 'b', 'c'],
- NPNProtocols: ['a', 'b', 'c']
};
const clientsOptions = [{}, {}, {}];
@@ -176,357 +102,66 @@ function Test4() {
runTest(clientsOptions, serverOptions, function(results) {
// nothing is selected by ALPN
checkResults(results[0],
- { server: { ALPN: false, NPN: 'http/1.1' },
- client: { ALPN: false, NPN: false } });
+ { server: { ALPN: false },
+ client: { ALPN: false } });
// nothing is selected by ALPN
checkResults(results[1],
- { server: { ALPN: false, NPN: 'http/1.1' },
- client: { ALPN: false, NPN: false } });
- // nothing is selected by ALPN
- checkResults(results[2],
- { server: { ALPN: false, NPN: 'http/1.1' },
- client: { ALPN: false, NPN: false } });
- // execute next test
- Test5();
- });
-}
-
-// Server: ALPN, Client: ALPN/NPN
-function Test5() {
- const serverOptions = {
- ALPNProtocols: ['a', 'b', 'c']
- };
-
- const clientsOptions = [{
- ALPNProtocols: ['a', 'b', 'c'],
- NPNProtocols: ['a', 'b', 'c']
- }, {
- ALPNProtocols: ['c', 'b', 'e'],
- NPNProtocols: ['c', 'b', 'e']
- }, {
- ALPNProtocols: ['first-priority-unsupported', 'x', 'y'],
- NPNProtocols: ['first-priority-unsupported', 'x', 'y']
- }];
-
- runTest(clientsOptions, serverOptions, function(results) {
- // 'a' is selected by ALPN
- checkResults(results[0], { server: { ALPN: 'a', NPN: false },
- client: { ALPN: 'a', NPN: undefined } });
- // 'b' is selected by ALPN
- checkResults(results[1], { server: { ALPN: 'b', NPN: false },
- client: { ALPN: 'b', NPN: undefined } });
- // nothing is selected by ALPN
- checkResults(results[2], { server: { ALPN: false,
- NPN: 'first-priority-unsupported' },
- client: { ALPN: false, NPN: false } });
- // execute next test
- Test6();
- });
-}
-
-// Server: ALPN, Client: ALPN
-function Test6() {
- const serverOptions = {
- ALPNProtocols: ['a', 'b', 'c']
- };
-
- const clientsOptions = [{
- ALPNProtocols: ['a', 'b', 'c']
- }, {
- ALPNProtocols: ['c', 'b', 'e']
- }, {
- ALPNProtocols: ['first-priority-unsupported', 'x', 'y']
- }];
-
- runTest(clientsOptions, serverOptions, function(results) {
- // 'a' is selected by ALPN
- checkResults(results[0], { server: { ALPN: 'a', NPN: false },
- client: { ALPN: 'a', NPN: undefined } });
- // 'b' is selected by ALPN
- checkResults(results[1], { server: { ALPN: 'b', NPN: false },
- client: { ALPN: 'b', NPN: undefined } });
- // nothing is selected by ALPN
- checkResults(results[2], { server: { ALPN: false, NPN: 'http/1.1' },
- client: { ALPN: false, NPN: false } });
- // execute next test
- Test7();
- });
-}
-
-// Server: ALPN, Client: NPN
-function Test7() {
- const serverOptions = {
- ALPNProtocols: ['a', 'b', 'c']
- };
-
- const clientsOptions = [{
- NPNProtocols: ['a', 'b', 'c']
- }, {
- NPNProtocols: ['c', 'b', 'e']
- }, {
- NPNProtocols: ['first-priority-unsupported', 'x', 'y']
- }];
-
- runTest(clientsOptions, serverOptions, function(results) {
- // nothing is selected by ALPN
- checkResults(results[0], { server: { ALPN: false, NPN: 'a' },
- client: { ALPN: false, NPN: false } });
- // nothing is selected by ALPN
- checkResults(results[1], { server: { ALPN: false, NPN: 'c' },
- client: { ALPN: false, NPN: false } });
- // nothing is selected by ALPN
- checkResults(results[2],
- { server: { ALPN: false, NPN: 'first-priority-unsupported' },
- client: { ALPN: false, NPN: false } });
- // execute next test
- Test8();
- });
-}
-
-// Server: ALPN, Client: Nothing
-function Test8() {
- const serverOptions = {
- ALPNProtocols: ['a', 'b', 'c']
- };
-
- const clientsOptions = [{}, {}, {}];
-
- runTest(clientsOptions, serverOptions, function(results) {
- // nothing is selected by ALPN
- checkResults(results[0], { server: { ALPN: false, NPN: 'http/1.1' },
- client: { ALPN: false, NPN: false } });
- // nothing is selected by ALPN
- checkResults(results[1], { server: { ALPN: false, NPN: 'http/1.1' },
- client: { ALPN: false, NPN: false } });
+ { server: { ALPN: false },
+ client: { ALPN: false } });
// nothing is selected by ALPN
checkResults(results[2],
- { server: { ALPN: false, NPN: 'http/1.1' },
- client: { ALPN: false, NPN: false } });
- // execute next test
- Test9();
- });
-}
-
-// Server: NPN, Client: ALPN/NPN
-function Test9() {
- const serverOptions = {
- NPNProtocols: ['a', 'b', 'c']
- };
-
- const clientsOptions = [{
- ALPNrotocols: ['a', 'b', 'c'],
- NPNProtocols: ['a', 'b', 'c']
- }, {
- ALPNProtocols: ['c', 'b', 'e'],
- NPNProtocols: ['c', 'b', 'e']
- }, {
- ALPNProtocols: ['first-priority-unsupported', 'x', 'y'],
- NPNProtocols: ['first-priority-unsupported', 'x', 'y']
- }];
-
- runTest(clientsOptions, serverOptions, function(results) {
- // 'a' is selected by NPN
- checkResults(results[0], { server: { ALPN: false, NPN: 'a' },
- client: { ALPN: false, NPN: 'a' } });
- // 'b' is selected by NPN
- checkResults(results[1], { server: { ALPN: false, NPN: 'b' },
- client: { ALPN: false, NPN: 'b' } });
- // nothing is selected
- checkResults(results[2],
- { server: { ALPN: false, NPN: 'first-priority-unsupported' },
- client: { ALPN: false, NPN: false } });
- // execute next test
- Test10();
- });
-}
-
-// Server: NPN, Client: ALPN
-function Test10() {
- const serverOptions = {
- NPNProtocols: ['a', 'b', 'c']
- };
-
- const clientsOptions = [{
- ALPNProtocols: ['a', 'b', 'c']
- }, {
- ALPNProtocols: ['c', 'b', 'e']
- }, {
- ALPNProtocols: ['first-priority-unsupported', 'x', 'y']
- }];
-
- runTest(clientsOptions, serverOptions, function(results) {
- // nothing is selected
- checkResults(results[0], { server: { ALPN: false, NPN: 'http/1.1' },
- client: { ALPN: false, NPN: false } });
- // nothing is selected
- checkResults(results[1], { server: { ALPN: false, NPN: 'http/1.1' },
- client: { ALPN: false, NPN: false } });
- // nothing is selected
- checkResults(results[2], { server: { ALPN: false, NPN: 'http/1.1' },
- client: { ALPN: false, NPN: false } });
+ { server: { ALPN: false },
+ client: { ALPN: false } });
// execute next test
- Test11();
- });
-}
-
-// Server: NPN, Client: NPN
-function Test11() {
- const serverOptions = {
- NPNProtocols: ['a', 'b', 'c']
- };
-
- const clientsOptions = [{
- NPNProtocols: ['a', 'b', 'c']
- }, {
- NPNProtocols: ['c', 'b', 'e']
- }, {
- NPNProtocols: ['first-priority-unsupported', 'x', 'y']
- }];
-
- runTest(clientsOptions, serverOptions, function(results) {
- // 'a' is selected by NPN
- checkResults(results[0], { server: { ALPN: false, NPN: 'a' },
- client: { ALPN: false, NPN: 'a' } });
- // 'b' is selected by NPN
- checkResults(results[1], { server: { ALPN: false, NPN: 'b' },
- client: { ALPN: false, NPN: 'b' } });
- // nothing is selected
- checkResults(results[2],
- { server: { ALPN: false, NPN: 'first-priority-unsupported' },
- client: { ALPN: false, NPN: false } });
- // execute next test
- Test12();
- });
-}
-
-// Server: NPN, Client: Nothing
-function Test12() {
- const serverOptions = {
- NPNProtocols: ['a', 'b', 'c']
- };
-
- const clientsOptions = [{}, {}, {}];
-
- runTest(clientsOptions, serverOptions, function(results) {
- // nothing is selected
- checkResults(results[0], { server: { ALPN: false, NPN: 'http/1.1' },
- client: { ALPN: false, NPN: false } });
- // nothing is selected
- checkResults(results[1], { server: { ALPN: false, NPN: 'http/1.1' },
- client: { ALPN: false, NPN: false } });
- // nothing is selected
- checkResults(results[2],
- { server: { ALPN: false, NPN: 'http/1.1' },
- client: { ALPN: false, NPN: false } });
- // execute next test
- Test13();
+ Test3();
});
}
-// Server: Nothing, Client: ALPN/NPN
-function Test13() {
+// Server: Nothing, Client: ALPN
+function Test3() {
const serverOptions = {};
const clientsOptions = [{
ALPNrotocols: ['a', 'b', 'c'],
- NPNProtocols: ['a', 'b', 'c']
}, {
ALPNProtocols: ['c', 'b', 'e'],
- NPNProtocols: ['c', 'b', 'e']
}, {
ALPNProtocols: ['first-priority-unsupported', 'x', 'y'],
- NPNProtocols: ['first-priority-unsupported', 'x', 'y']
}];
runTest(clientsOptions, serverOptions, function(results) {
// nothing is selected
- checkResults(results[0], { server: { ALPN: false, NPN: 'a' },
- client: { ALPN: false, NPN: false } });
+ checkResults(results[0], { server: { ALPN: false },
+ client: { ALPN: false } });
// nothing is selected
- checkResults(results[1], { server: { ALPN: false, NPN: 'c' },
- client: { ALPN: false, NPN: false } });
+ checkResults(results[1], { server: { ALPN: false },
+ client: { ALPN: false } });
// nothing is selected
checkResults(results[2],
- { server: { ALPN: false, NPN: 'first-priority-unsupported' },
- client: { ALPN: false, NPN: false } });
+ { server: { ALPN: false },
+ client: { ALPN: false } });
// execute next test
- Test14();
- });
-}
-
-// Server: Nothing, Client: ALPN
-function Test14() {
- const serverOptions = {};
-
- const clientsOptions = [{
- ALPNrotocols: ['a', 'b', 'c']
- }, {
- ALPNProtocols: ['c', 'b', 'e']
- }, {
- ALPNProtocols: ['first-priority-unsupported', 'x', 'y']
- }];
-
- runTest(clientsOptions, serverOptions, function(results) {
- // nothing is selected
- checkResults(results[0], { server: { ALPN: false, NPN: 'http/1.1' },
- client: { ALPN: false, NPN: false } });
- // nothing is selected
- checkResults(results[1], { server: { ALPN: false, NPN: 'http/1.1' },
- client: { ALPN: false, NPN: false } });
- // nothing is selected
- checkResults(results[2],
- { server: { ALPN: false, NPN: 'http/1.1' },
- client: { ALPN: false, NPN: false } });
- // execute next test
- Test15();
- });
-}
-
-// Server: Nothing, Client: NPN
-function Test15() {
- const serverOptions = {};
-
- const clientsOptions = [{
- NPNProtocols: ['a', 'b', 'c']
- }, {
- NPNProtocols: ['c', 'b', 'e']
- }, {
- NPNProtocols: ['first-priority-unsupported', 'x', 'y']
- }];
-
- runTest(clientsOptions, serverOptions, function(results) {
- // nothing is selected
- checkResults(results[0], { server: { ALPN: false, NPN: 'a' },
- client: { ALPN: false, NPN: false } });
- // nothing is selected
- checkResults(results[1], { server: { ALPN: false, NPN: 'c' },
- client: { ALPN: false, NPN: false } });
- // nothing is selected
- checkResults(results[2],
- { server: { ALPN: false, NPN: 'first-priority-unsupported' },
- client: { ALPN: false, NPN: false } });
- // execute next test
- Test16();
+ Test4();
});
}
// Server: Nothing, Client: Nothing
-function Test16() {
+function Test4() {
const serverOptions = {};
const clientsOptions = [{}, {}, {}];
runTest(clientsOptions, serverOptions, function(results) {
// nothing is selected
- checkResults(results[0], { server: { ALPN: false, NPN: 'http/1.1' },
- client: { ALPN: false, NPN: false } });
+ checkResults(results[0], { server: { ALPN: false },
+ client: { ALPN: false } });
// nothing is selected
- checkResults(results[1], { server: { ALPN: false, NPN: 'http/1.1' },
- client: { ALPN: false, NPN: false } });
+ checkResults(results[1], { server: { ALPN: false },
+ client: { ALPN: false } });
// nothing is selected
checkResults(results[2],
- { server: { ALPN: false, NPN: 'http/1.1' },
- client: { ALPN: false, NPN: false } });
+ { server: { ALPN: false },
+ client: { ALPN: false } });
});
}
diff --git a/test/parallel/test-tls-npn-server-client.js b/test/parallel/test-tls-npn-server-client.js
deleted file mode 100644
index 518e881f9c..0000000000
--- a/test/parallel/test-tls-npn-server-client.js
+++ /dev/null
@@ -1,118 +0,0 @@
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
-// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-// USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-'use strict';
-const common = require('../common');
-if (!common.hasCrypto)
- common.skip('missing crypto');
-
-if (!process.features.tls_npn)
- common.skip('Skipping because node compiled without NPN feature of OpenSSL.');
-
-const assert = require('assert');
-const tls = require('tls');
-const fixtures = require('../common/fixtures');
-
-function loadPEM(n) {
- return fixtures.readKey(`${n}.pem`);
-}
-
-const serverOptions = {
- key: loadPEM('agent2-key'),
- cert: loadPEM('agent2-cert'),
- crl: loadPEM('ca2-crl'),
- SNICallback: function(servername, cb) {
- cb(null, tls.createSecureContext({
- key: loadPEM('agent2-key'),
- cert: loadPEM('agent2-cert'),
- crl: loadPEM('ca2-crl'),
- }));
- },
- NPNProtocols: ['a', 'b', 'c']
-};
-
-const clientsOptions = [{
- port: undefined,
- key: serverOptions.key,
- cert: serverOptions.cert,
- crl: serverOptions.crl,
- NPNProtocols: ['a', 'b', 'c'],
- rejectUnauthorized: false
-}, {
- port: undefined,
- key: serverOptions.key,
- cert: serverOptions.cert,
- crl: serverOptions.crl,
- NPNProtocols: ['c', 'b', 'e'],
- rejectUnauthorized: false
-}, {
- port: undefined,
- key: serverOptions.key,
- cert: serverOptions.cert,
- crl: serverOptions.crl,
- rejectUnauthorized: false
-}, {
- port: undefined,
- key: serverOptions.key,
- cert: serverOptions.cert,
- crl: serverOptions.crl,
- NPNProtocols: ['first-priority-unsupported', 'x', 'y'],
- rejectUnauthorized: false
-}];
-
-const serverResults = [];
-const clientsResults = [];
-
-const server = tls.createServer(serverOptions, function(c) {
- serverResults.push(c.npnProtocol);
-});
-server.listen(0, startTest);
-
-function startTest() {
- function connectClient(options, callback) {
- options.port = server.address().port;
- const client = tls.connect(options, function() {
- clientsResults.push(client.npnProtocol);
- client.destroy();
-
- callback();
- });
- }
-
- connectClient(clientsOptions[0], function() {
- connectClient(clientsOptions[1], function() {
- connectClient(clientsOptions[2], function() {
- connectClient(clientsOptions[3], function() {
- server.close();
- });
- });
- });
- });
-}
-
-process.on('exit', function() {
- assert.strictEqual(serverResults[0], clientsResults[0]);
- assert.strictEqual(serverResults[1], clientsResults[1]);
- assert.strictEqual(serverResults[2], 'http/1.1');
- assert.strictEqual(clientsResults[2], false);
- assert.strictEqual(serverResults[3], 'first-priority-unsupported');
- assert.strictEqual(clientsResults[3], false);
-});
diff --git a/test/parallel/test-tls-socket-constructor-alpn-npn-options-parsing.js b/test/parallel/test-tls-socket-constructor-alpn-options-parsing.js
index fec06c94ee..edbc9f63cf 100644
--- a/test/parallel/test-tls-socket-constructor-alpn-npn-options-parsing.js
+++ b/test/parallel/test-tls-socket-constructor-alpn-options-parsing.js
@@ -1,7 +1,6 @@
'use strict';
-// Test that TLSSocket can take arrays of strings for ALPNProtocols and
-// NPNProtocols.
+// Test that TLSSocket can take arrays of strings for ALPNProtocols.
const common = require('../common');
@@ -12,12 +11,8 @@ const tls = require('tls');
new tls.TLSSocket(null, {
ALPNProtocols: ['http/1.1'],
- NPNProtocols: ['http/1.1']
});
-if (!process.features.tls_npn)
- common.skip('node compiled without NPN feature of OpenSSL');
-
if (!process.features.tls_alpn)
common.skip('node compiled without ALPN feature of OpenSSL');
@@ -37,17 +32,15 @@ const server = net.createServer(common.mustCall((s) => {
key,
cert,
ALPNProtocols: ['http/1.1'],
- NPNProtocols: ['http/1.1']
});
tlsSocket.on('secure', common.mustCall(() => {
protocols.push({
alpnProtocol: tlsSocket.alpnProtocol,
- npnProtocol: tlsSocket.npnProtocol
});
tlsSocket.end();
}));
-}, 2));
+}));
server.listen(0, common.mustCall(() => {
const alpnOpts = {
@@ -55,24 +48,14 @@ server.listen(0, common.mustCall(() => {
rejectUnauthorized: false,
ALPNProtocols: ['h2', 'http/1.1']
};
- const npnOpts = {
- port: server.address().port,
- rejectUnauthorized: false,
- NPNProtocols: ['h2', 'http/1.1']
- };
tls.connect(alpnOpts, function() {
this.end();
- tls.connect(npnOpts, function() {
- this.end();
-
- server.close();
+ server.close();
- assert.deepStrictEqual(protocols, [
- { alpnProtocol: 'http/1.1', npnProtocol: false },
- { alpnProtocol: false, npnProtocol: 'http/1.1' }
- ]);
- });
+ assert.deepStrictEqual(protocols, [
+ { alpnProtocol: 'http/1.1' },
+ ]);
});
}));