summaryrefslogtreecommitdiff
path: root/test/parallel/test-tls-alpn-server-client.js
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/test-tls-alpn-server-client.js
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/test-tls-alpn-server-client.js')
-rw-r--r--test/parallel/test-tls-alpn-server-client.js435
1 files changed, 35 insertions, 400 deletions
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 } });
});
}