node/test/parallel/test-tls-zero-clear-in.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

53 lines
1.0 KiB
JavaScript

'use strict';
var common = require('../common');
var assert = require('assert');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
var tls = require('tls');
var fs = require('fs');
var path = require('path');
var cert = fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'));
var key = fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem'));
var errorEmitted = false;
var server = tls.createServer({
cert: cert,
key: key
}, function(c) {
// Nop
setTimeout(function() {
c.end();
server.close();
}, 20);
}).listen(common.PORT, function() {
var conn = tls.connect({
cert: cert,
key: key,
rejectUnauthorized: false,
port: common.PORT
}, function() {
setTimeout(function() {
conn.destroy();
}, 20);
});
// SSL_write() call's return value, when called 0 bytes, should not be
// treated as error.
conn.end('');
conn.on('error', function(err) {
console.log(err);
errorEmitted = true;
});
});
process.on('exit', function() {
assert.ok(!errorEmitted);
});