0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-tls-regr-gh-5108.js
Jeremiah Senkpiel 52bae222a3 test: abstract skip functionality to common
The tap skipping output is so prevalent yet obscure in nature that we
ought to move it into it's own function in test/common.js

PR-URL: https://github.com/nodejs/node/pull/6697
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
2016-05-12 16:43:35 -04:00

43 lines
855 B
JavaScript

'use strict';
const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
const assert = require('assert');
const tls = require('tls');
const fs = require('fs');
const options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
};
const server = tls.createServer(options, function(s) {
s.end('hello');
}).listen(common.PORT, function() {
const opts = {
port: common.PORT,
rejectUnauthorized: false
};
const client = tls.connect(opts, function() {
putImmediate(client);
});
});
function putImmediate(client) {
setImmediate(function() {
if (client.ssl) {
const fd = client.ssl.fd;
assert(!!fd);
putImmediate(client);
} else {
server.close();
}
});
}