node/test/parallel/test-tls-empty-sni-context.js
Sakthipriyan Vairamani (thefourtheye) 5d4273d122 test: skip tests with common.skip
The `common.skip` function adds proper message in TAP format to skipped
tests. It is better not to have the message rewritten in the tests.

PR-URL: https://github.com/nodejs/node/pull/11585
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
2017-03-01 07:48:18 -08:00

40 lines
942 B
JavaScript

'use strict';
const common = require('../common');
if (!process.features.tls_sni) {
common.skip('node compiled without OpenSSL or with old OpenSSL version.');
return;
}
const assert = require('assert');
if (!common.hasCrypto) {
return common.skip('missing crypto');
}
const tls = require('tls');
const options = {
SNICallback: (name, callback) => {
callback(null, tls.createSecureContext());
}
};
const server = tls.createServer(options, (c) => {
common.fail('Should not be called');
}).on('tlsClientError', common.mustCall((err, c) => {
assert(/SSL_use_certificate:passed a null parameter/i.test(err.message));
server.close();
})).listen(0, common.mustCall(() => {
const c = tls.connect({
port: server.address().port,
rejectUnauthorized: false,
servername: 'any.name'
}, common.mustNotCall());
c.on('error', common.mustCall((err) => {
assert(/socket hang up/.test(err.message));
}));
}));