mirror of
https://github.com/nodejs/node.git
synced 2025-05-02 13:11:36 +00:00

we had a few ways versions of looking for support before executing a test. this commit unifies them as well as add the check for all tests that previously lacked them. found by running `./configure --without-ssl && make test`. also, produce tap skip output if the test is skipped. PR-URL: https://github.com/iojs/io.js/pull/1049 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
54 lines
1.2 KiB
JavaScript
54 lines
1.2 KiB
JavaScript
var common = require('../common');
|
|
var assert = require('assert');
|
|
|
|
if (!common.hasCrypto) {
|
|
console.log('1..0 # Skipped: missing crypto');
|
|
process.exit();
|
|
}
|
|
var tls = require('tls');
|
|
|
|
var fs = require('fs');
|
|
var net = require('net');
|
|
|
|
var common = require('../common');
|
|
|
|
var buf = new Buffer(10000);
|
|
var received = 0;
|
|
var ended = 0;
|
|
var maxChunk = 768;
|
|
|
|
var server = tls.createServer({
|
|
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
|
|
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
|
|
}, function(c) {
|
|
// Lower and upper limits
|
|
assert(!c.setMaxSendFragment(511));
|
|
assert(!c.setMaxSendFragment(16385));
|
|
|
|
// Correct fragment size
|
|
assert(c.setMaxSendFragment(maxChunk));
|
|
|
|
c.end(buf);
|
|
}).listen(common.PORT, function() {
|
|
var c = tls.connect(common.PORT, {
|
|
rejectUnauthorized: false
|
|
}, function() {
|
|
c.on('data', function(chunk) {
|
|
assert(chunk.length <= maxChunk);
|
|
received += chunk.length;
|
|
});
|
|
|
|
// Ensure that we receive 'end' event anyway
|
|
c.on('end', function() {
|
|
ended++;
|
|
c.destroy();
|
|
server.close();
|
|
});
|
|
});
|
|
});
|
|
|
|
process.on('exit', function() {
|
|
assert.equal(ended, 1);
|
|
assert.equal(received, buf.length);
|
|
});
|