Tests in the disabled directory are not used by Makefile nor by the CI.
Other than a single 2015 commit that puts 'use strict' in each test,
many of them haven't been touched in years.
This removes all the disabled tests that have been unmodified since
2011 (with the exception of the 'use strict' modification mentioned
above).
PR-URL: https://github.com/nodejs/io.js/pull/2045
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Evan Lucas <evanlucas@me.com>
+++ /dev/null
-'use strict';
-var common = require('../common.js');
-var assert = require('assert');
-var http = require('http');
-
-console.log('hello world');
-
-var body = 'exports.A = function() { return "A";}';
-var server = http.createServer(function(req, res) {
- console.log('req?');
- res.sendHeader(200, {
- 'Content-Length': body.length,
- 'Content-Type': 'text/plain'
- });
- res.sendBody(body);
- res.finish();
-});
-server.listen(common.PORT);
-
-var errors = 0;
-var successes = 0;
-
-var promise = process.cat('http://localhost:' + common.PORT, 'utf8');
-
-promise.addCallback(function(content) {
- assert.equal(body, content);
- server.close();
- successes += 1;
-});
-
-promise.addErrback(function() {
- errors += 1;
-});
-
-var dirname = process.path.dirname(__filename);
-var fixtures = process.path.join(dirname, 'fixtures');
-var x = process.path.join(fixtures, 'x.txt');
-
-promise = process.cat(x, 'utf8');
-
-promise.addCallback(function(content) {
- assert.equal('xyz', content.replace(/[\r\n]/, ''));
- successes += 1;
-});
-
-promise.addErrback(function() {
- errors += 1;
-});
-
-process.on('exit', function() {
- assert.equal(2, successes);
- assert.equal(0, errors);
-});
+++ /dev/null
-'use strict';
-var common = require('../common');
-var assert = require('assert');
-
-var assert = require('assert');
-var spawn = require('child_process').spawn;
-var path = require('path');
-var fs = require('fs');
-
-function fixtPath(p) {
- return path.join(common.fixturesDir, p);
-}
-
-var expected = 'hello world';
-
-// Test the equivalent of:
-// $ /bin/echo 'hello world' > hello.txt
-var helloPath = path.join(common.tmpDir, 'hello.txt');
-
-function test1(next) {
- console.log('Test 1...');
- fs.open(helloPath, 'w', 400, function(err, fd) {
- if (err) throw err;
- var child = spawn('/bin/echo', [expected], {customFds: [-1, fd]});
-
- assert.notEqual(child.stdin, null);
- assert.equal(child.stdout, null);
- assert.notEqual(child.stderr, null);
-
- child.on('exit', function(err) {
- if (err) throw err;
- fs.close(fd, function(error) {
- if (error) throw error;
-
- fs.readFile(helloPath, function(err, data) {
- if (err) throw err;
- assert.equal(data.toString(), expected + '\n');
- console.log(' File was written.');
- next(test3);
- });
- });
- });
- });
-}
-
-// Test the equivalent of:
-// $ node ../fixture/stdio-filter.js < hello.txt
-function test2(next) {
- console.log('Test 2...');
- fs.open(helloPath, 'r', undefined, function(err, fd) {
- var child = spawn(process.argv[0],
- [fixtPath('stdio-filter.js'), 'o', 'a'],
- {customFds: [fd, -1, -1]});
-
- assert.equal(child.stdin, null);
- var actualData = '';
- child.stdout.on('data', function(data) {
- actualData += data.toString();
- });
- child.on('exit', function(code) {
- if (err) throw err;
- assert.equal(actualData, 'hella warld\n');
- console.log(' File was filtered successfully');
- fs.close(fd, function() {
- next(test3);
- });
- });
- });
-}
-
-// Test the equivalent of:
-// $ /bin/echo 'hello world' | ../stdio-filter.js a o
-function test3(next) {
- console.log('Test 3...');
- var filter = spawn(process.argv[0], [fixtPath('stdio-filter.js'), 'o', 'a']);
- var echo = spawn('/bin/echo', [expected], {customFds: [-1, filter.fds[0]]});
- var actualData = '';
- filter.stdout.on('data', function(data) {
- console.log(' Got data --> ' + data);
- actualData += data;
- });
- filter.on('exit', function(code) {
- if (code) throw 'Return code was ' + code;
- assert.equal(actualData, 'hella warld\n');
- console.log(' Talked to another process successfully');
- });
- echo.on('exit', function(code) {
- if (code) throw 'Return code was ' + code;
- filter.stdin.end();
- fs.unlinkSync(helloPath);
- });
-}
-
-test1(test2);
+++ /dev/null
-'use strict';
-var common = require('../common');
-
-var bigish = Array(200);
-
-for (var i = 0, il = bigish.length; i < il; ++i)
- bigish[i] = -1;
-
-common.spawnPwd({ customFds: bigish });
+++ /dev/null
-'use strict';
-var common = require('../common');
-var assert = require('assert');
-
-var dgram = require('dgram'),
- util = require('util'),
- assert = require('assert'),
- Buffer = require('buffer').Buffer;
-var LOCAL_BROADCAST_HOST = '224.0.0.1';
-var sendMessages = [
- new Buffer('First message to send'),
- new Buffer('Second message to send'),
- new Buffer('Third message to send'),
- new Buffer('Fourth message to send')
-];
-
-var listenSockets = [];
-
-var sendSocket = dgram.createSocket('udp4');
-
-sendSocket.on('close', function() {
- console.error('sendSocket closed');
-});
-
-sendSocket.setBroadcast(true);
-sendSocket.setMulticastTTL(1);
-sendSocket.setMulticastLoopback(true);
-
-var i = 0;
-
-sendSocket.sendNext = function() {
- var buf = sendMessages[i++];
-
- if (!buf) {
- try { sendSocket.close(); } catch (e) {}
- return;
- }
-
- sendSocket.send(buf, 0, buf.length,
- common.PORT, LOCAL_BROADCAST_HOST, function(err) {
- if (err) throw err;
- console.error('sent %s to %s', util.inspect(buf.toString()),
- LOCAL_BROADCAST_HOST + common.PORT);
- process.nextTick(sendSocket.sendNext);
- });
-};
-
-var listener_count = 0;
-
-function mkListener() {
- var receivedMessages = [];
- var listenSocket = dgram.createSocket('udp4');
- listenSocket.addMembership(LOCAL_BROADCAST_HOST);
-
- listenSocket.on('message', function(buf, rinfo) {
- console.error('received %s from %j', util.inspect(buf.toString()), rinfo);
- receivedMessages.push(buf);
-
- if (receivedMessages.length == sendMessages.length) {
- listenSocket.dropMembership(LOCAL_BROADCAST_HOST);
- process.nextTick(function() { // TODO should be changed to below.
- // listenSocket.dropMembership(LOCAL_BROADCAST_HOST, function() {
- listenSocket.close();
- });
- }
- });
-
- listenSocket.on('close', function() {
- console.error('listenSocket closed -- checking received messages');
- var count = 0;
- receivedMessages.forEach(function(buf) {
- for (var i = 0; i < sendMessages.length; ++i) {
- if (buf.toString() === sendMessages[i].toString()) {
- count++;
- break;
- }
- }
- });
- console.error('count %d', count);
- //assert.strictEqual(count, sendMessages.length);
- });
-
- listenSocket.on('listening', function() {
- listenSockets.push(listenSocket);
- if (listenSockets.length == 3) {
- sendSocket.sendNext();
- }
- });
-
- listenSocket.bind(common.PORT);
-}
-
-mkListener();
-mkListener();
-mkListener();
-
+++ /dev/null
-'use strict';
-var common = require('../common');
-var assert = require('assert');
-
-var Buffer = require('buffer').Buffer,
- fs = require('fs'),
- dgram = require('dgram'), server, client,
- server_path = '/tmp/dgram_server_sock',
- messages_to_send = [
- new Buffer('First message to send'),
- new Buffer('Second message to send'),
- new Buffer('Third message to send'),
- new Buffer('Fourth message to send')
- ],
- timer;
-
-server = dgram.createSocket('unix_dgram');
-server.bind(server_path);
-server.messages = [];
-server.on('message', function(msg, rinfo) {
- console.log('server got: ' + msg);
- assert.strictEqual(rinfo.address, ''); // anon client sending
- server.messages.push(msg.toString());
- if (server.messages.length === messages_to_send.length) {
- server.messages.forEach(function(m, i) {
- assert.strictEqual(m, messages_to_send[i].toString());
- });
- server.close();
- client.close();
- }
-});
-server.on('listening', function() {
- console.log('server is listening');
- client = dgram.createSocket('unix_dgram');
- messages_to_send.forEach(function(m) {
- client.send(m, 0, m.length, server_path, function(err, bytes) {
- if (err) {
- console.log('Caught error in client send.');
- throw err;
- }
- console.log('client wrote ' + bytes + ' bytes.');
- });
- });
- client.on('close', function() {
- if (server.fd === null) {
- clearTimeout(timer);
- }
- });
-});
-server.on('close', function() {
- if (client.fd === null) {
- clearTimeout(timer);
- }
-});
-
-timer = setTimeout(function() {
- throw new Error('Timeout');
-}, 500);
+++ /dev/null
-'use strict';
-var common = require('../common');
-var assert = require('assert');
-
-var fs = require('fs');
-var dgram = require('dgram');
-
-// TODO use common.tmpDir here
-var serverPath = '/tmp/dgram_server_sock';
-var clientPath = '/tmp/dgram_client_sock';
-
-var msgToSend = new Buffer('A message to send');
-
-var server = dgram.createSocket('unix_dgram');
-server.on('message', function(msg, rinfo) {
- console.log('server got: ' + msg + ' from ' + rinfo.address);
- assert.strictEqual(rinfo.address, clientPath);
- assert.strictEqual(msg.toString(), msgToSend.toString());
- server.send(msg, 0, msg.length, rinfo.address);
-});
-
-server.on('listening', function() {
- console.log('server is listening');
-
- var client = dgram.createSocket('unix_dgram');
-
- client.on('message', function(msg, rinfo) {
- console.log('client got: ' + msg + ' from ' + rinfo.address);
- assert.strictEqual(rinfo.address, serverPath);
- assert.strictEqual(msg.toString(), msgToSend.toString());
- client.close();
- server.close();
- });
-
- client.on('listening', function() {
- console.log('client is listening');
- client.send(msgToSend, 0, msgToSend.length, serverPath,
- function(err, bytes) {
- if (err) {
- console.log('Caught error in client send.');
- throw err;
- }
- console.log('client wrote ' + bytes + ' bytes.');
- assert.strictEqual(bytes, msgToSend.length);
- });
- });
-
-
- client.bind(clientPath);
-});
-
-server.bind(serverPath);
+++ /dev/null
-'use strict';
-var common = require('../common');
-var assert = require('assert');
-var path = require('path');
-var testTxt = path.join(common.fixturesDir, 'x.txt');
-var fs = require('fs');
-
-setTimeout(function() {
- // put this in a timeout, just so it doesn't get bunched up with the
- // require() calls..
- var N = 30;
- for (var i = 0; i < N; i++) {
- console.log('start ' + i);
- fs.readFile(testTxt, function(err, data) {
- if (err) {
- console.log('error! ' + e);
- process.exit(1);
- } else {
- console.log('finish');
- }
- });
- }
-}, 100);
+++ /dev/null
-'use strict';
-/* XXX Can this test be modified to not call the now-removed wait()? */
-
-var common = require('../common');
-var assert = require('assert');
-
-
-console.log('first stat ...');
-
-fs.stat(__filename)
- .addCallback(function(stats) {
- console.log('second stat ...');
- fs.stat(__filename)
- .timeout(1000)
- .wait();
- console.log('test passed');
- })
- .addErrback(function() {
- throw new Exception();
- });
+++ /dev/null
-'use strict';
-var common = require('../common');
-var assert = require('assert');
-var fs = require('fs');
-var N = 100;
-var j = 0;
-
-for (var i = 0; i < N; i++) {
- // these files don't exist
- fs.stat('does-not-exist-' + i, function(err) {
- if (err) {
- j++; // only makes it to about 17
- console.log('finish ' + j);
- } else {
- throw new Error('this shouldn\'t be called');
- }
- });
-}
-
-process.on('exit', function() {
- assert.equal(N, j);
-});
+++ /dev/null
-'use strict';
-var common = require('../common');
-var assert = require('assert');
-var http = require('http');
-
-var reqEndCount = 0;
-
-var server = http.Server(function(req, res) {
- res.writeHead(200);
- res.end('hello world\n');
-
- var buffer = '';
-
- req.setEncoding('utf8');
-
- req.on('data', function(s) {
- buffer += s;
- });
-
- req.on('end', function() {
- reqEndCount++;
- assert.equal(body, buffer);
- });
-});
-
-var responses = 0;
-var N = 10;
-var M = 10;
-
-var body = '';
-for (var i = 0; i < 1000; i++) {
- body += 'hello world';
-}
-
-var options = {
- port: common.PORT,
- path: '/',
- method: 'PUT'
-};
-
-server.listen(common.PORT, function() {
- for (var i = 0; i < N; i++) {
- setTimeout(function() {
- for (var j = 0; j < M; j++) {
-
- var req = http.request(options, function(res) {
- console.log(res.statusCode);
- if (++responses == N * M) server.close();
- }).on('error', function(e) {
- console.log(e.message);
- process.exit(1);
- });
-
- req.end(body);
- }
- }, i);
- }
-});
-
-
-process.on('exit', function() {
- assert.equal(N * M, responses);
- assert.equal(N * M, reqEndCount);
-});
+++ /dev/null
-'use strict';
-var common = require('../common');
-var assert = require('assert');
-var util = require('util'),
- fs = require('fs'),
- http = require('http'),
- url = require('url');
-
-var chunk = '01234567890123456789';
-
-// Produce a very large response.
-var chargen = http.createServer(function(req, res) {
- var len = parseInt(req.headers['x-len'], 10);
- assert.ok(len > 0);
- res.writeHead(200, {'transfer-encoding': 'chunked'});
- for (var i = 0; i < len; i++) {
- if (i % 1000 == 0) common.print(',');
- res.write(chunk);
- }
- res.end();
-});
-chargen.listen(9000, ready);
-
-// Proxy to the chargen server.
-var proxy = http.createServer(function(req, res) {
- var len = parseInt(req.headers['x-len'], 10);
- assert.ok(len > 0);
-
- var sent = 0;
-
-
- function onError(e) {
- console.log('proxy client error. sent ' + sent);
- throw e;
- }
-
- var proxy_req = http.request({
- host: 'localhost',
- port: 9000,
- method: req.method,
- path: req.url,
- headers: req.headers
- }, function(proxy_res) {
- res.writeHead(proxy_res.statusCode, proxy_res.headers);
-
- var count = 0;
-
- proxy_res.on('data', function(d) {
- if (count++ % 1000 == 0) common.print('.');
- res.write(d);
- sent += d.length;
- assert.ok(sent <= (len * chunk.length));
- });
-
- proxy_res.on('end', function() {
- res.end();
- });
-
- });
- proxy_req.on('error', onError);
- proxy_req.end();
-});
-proxy.listen(9001, ready);
-
-var done = false;
-
-function call_chargen(list) {
- if (list.length > 0) {
- var len = list.shift();
-
- common.debug('calling chargen for ' + len + ' chunks.');
-
- var recved = 0;
-
- var req = http.request({
- port: 9001,
- host: 'localhost',
- path: '/',
- headers: {'x-len': len}
- }, function(res) {
-
- res.on('data', function(d) {
- recved += d.length;
- assert.ok(recved <= (len * chunk.length));
- });
-
- res.on('end', function() {
- assert.ok(recved <= (len * chunk.length));
- common.debug('end for ' + len + ' chunks.');
- call_chargen(list);
- });
-
- });
- req.end();
-
- } else {
- console.log('End of list. closing servers');
- proxy.close();
- chargen.close();
- done = true;
- }
-}
-
-var serversRunning = 0;
-function ready() {
- if (++serversRunning < 2) return;
- call_chargen([100, 1000, 10000, 100000, 1000000]);
-}
-
-process.on('exit', function() {
- assert.ok(done);
-});
+++ /dev/null
-'use strict';
-var common = require('../common');
-var assert = require('assert');
-
-var assert = require('assert');
-var http = require('http');
-var util = require('util');
-
-var body = 'hello world';
-
-var server = http.createServer(function(req, res) {
- res.writeHeader(200,
- {'Content-Length': body.length.toString(),
- 'Content-Type': 'text/plain'
- });
- console.log('method: ' + req.method);
- if (req.method != 'HEAD') res.write(body);
- res.end();
-});
-server.listen(common.PORT);
-
-var gotEnd = false;
-
-server.on('listening', function() {
- var request = http.request({
- port: common.PORT,
- method: 'HEAD',
- path: '/'
- }, function(response) {
- console.log('got response');
- response.on('data', function() {
- process.exit(2);
- });
- response.on('end', function() {
- process.exit(0);
- });
- });
- request.end();
-});
-
-//give a bit of time for the server to respond before we check it
-setTimeout(function() {
- process.exit(1);
-}, 2000);
+++ /dev/null
-'use strict';
-var common = require('../common');
-var assert = require('assert');
-
-var http = require('http');
-
-var request_count = 1000;
-var body = '{"ok": true}';
-
-var server = http.createServer(function(req, res) {
- res.writeHead(200, {'Content-Type': 'text/javascript'});
- res.write(body);
- res.end();
-});
-server.listen(common.PORT);
-
-var requests_ok = 0;
-var requests_complete = 0;
-
-server.on('listening', function() {
- for (var i = 0; i < request_count; i++) {
- http.cat('http://localhost:' + common.PORT + '/', 'utf8',
- function(err, content) {
- requests_complete++;
- if (err) {
- common.print('-');
- } else {
- assert.equal(body, content);
- common.print('.');
- requests_ok++;
- }
- if (requests_complete == request_count) {
- console.log('\nrequests ok: ' + requests_ok);
- server.close();
- }
- });
- }
-});
-
-process.on('exit', function() {
- assert.equal(request_count, requests_complete);
- assert.equal(request_count, requests_ok);
-});
+++ /dev/null
-'use strict';
-var common = require('../common');
-var assert = require('assert');
-
-var net = require('net');
-var http = require('http');
-var url = require('url');
-var qs = require('querystring');
-var fs = require('fs');
-
-var have_openssl;
-try {
- var crypto = require('crypto');
- var dummy_server = http.createServer(function() {});
- dummy_server.setSecure();
- have_openssl = true;
-} catch (e) {
- have_openssl = false;
- console.log('Not compiled with OPENSSL support.');
- process.exit();
-}
-
-var request_number = 0;
-var requests_sent = 0;
-var server_response = '';
-var client_got_eof = false;
-var caPem = fs.readFileSync(common.fixturesDir + '/test_ca.pem', 'ascii');
-var certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii');
-var keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii');
-
-try {
- var credentials = crypto.createCredentials(
- { key: keyPem,
- cert: certPem,
- ca: caPem
- });
-} catch (e) {
- console.log('Not compiled with OPENSSL support.');
- process.exit();
-}
-
-
-var https_server = http.createServer(function(req, res) {
- res.id = request_number;
- req.id = request_number++;
-
- var verified = res.connection.verifyPeer();
- var peerDN = JSON.stringify(req.connection.getPeerCertificate());
- assert.equal(verified, true);
- assert.equal(peerDN,
- '{"subject":"/C=UK/ST=Acknack Ltd/L=Rhys Jones' +
- '/O=node.js/OU=Test TLS Certificate/CN=localhost",' +
- '"issuer":"/C=UK/ST=Acknack Ltd/L=Rhys Jones/O=node.js' +
- '/OU=Test TLS Certificate/CN=localhost",' +
- '"valid_from":"Nov 11 09:52:22 2009 GMT",' +
- '"valid_to":"Nov 6 09:52:22 2029 GMT",' +
- '"fingerprint":"2A:7A:C2:DD:E5:F9:CC:53:72:35:99:7A:02:' +
- '5A:71:38:52:EC:8A:DF"}');
-
- if (req.id == 0) {
- assert.equal('GET', req.method);
- assert.equal('/hello', url.parse(req.url).pathname);
- assert.equal('world', qs.parse(url.parse(req.url).query).hello);
- assert.equal('b==ar', qs.parse(url.parse(req.url).query).foo);
- }
-
- if (req.id == 1) {
- assert.equal('POST', req.method);
- assert.equal('/quit', url.parse(req.url).pathname);
- }
-
- if (req.id == 2) {
- assert.equal('foo', req.headers['x-x']);
- }
-
- if (req.id == 3) {
- assert.equal('bar', req.headers['x-x']);
- this.close();
- //console.log('server closed');
- }
- setTimeout(function() {
- res.writeHead(200, {'Content-Type': 'text/plain'});
- res.write(url.parse(req.url).pathname);
- res.end();
- }, 1);
-
-});
-https_server.setSecure(credentials);
-https_server.listen(common.PORT);
-
-https_server.on('listening', function() {
- var c = net.createConnection(common.PORT);
-
- c.setEncoding('utf8');
-
- c.on('connect', function() {
- c.setSecure(credentials);
- });
-
- c.on('secure', function() {
- var verified = c.verifyPeer();
- var peerDN = JSON.stringify(c.getPeerCertificate());
- assert.equal(verified, true);
- assert.equal(peerDN,
- '{"subject":"/C=UK/ST=Acknack Ltd/L=Rhys Jones' +
- '/O=node.js/OU=Test TLS Certificate/CN=localhost",' +
- '"issuer":"/C=UK/ST=Acknack Ltd/L=Rhys Jones/O=node.js' +
- '/OU=Test TLS Certificate/CN=localhost",' +
- '"valid_from":"Nov 11 09:52:22 2009 GMT",' +
- '"valid_to":"Nov 6 09:52:22 2029 GMT",' +
- '"fingerprint":"2A:7A:C2:DD:E5:F9:CC:53:72:35:99:7A:02:' +
- '5A:71:38:52:EC:8A:DF"}');
- c.write('GET /hello?hello=world&foo=b==ar HTTP/1.1\r\n\r\n');
- requests_sent += 1;
- });
-
- c.on('data', function(chunk) {
- server_response += chunk;
-
- if (requests_sent == 1) {
- c.write('POST /quit HTTP/1.1\r\n\r\n');
- requests_sent += 1;
- }
-
- if (requests_sent == 2) {
- c.write('GET / HTTP/1.1\r\nX-X: foo\r\n\r\n' +
- 'GET / HTTP/1.1\r\nX-X: bar\r\n\r\n');
- c.end();
- assert.equal(c.readyState, 'readOnly');
- requests_sent += 2;
- }
-
- });
-
- c.on('end', function() {
- client_got_eof = true;
- });
-
- c.on('close', function() {
- assert.equal(c.readyState, 'closed');
- });
-});
-
-process.on('exit', function() {
- assert.equal(4, request_number);
- assert.equal(4, requests_sent);
-
- var hello = new RegExp('/hello');
- assert.equal(true, hello.exec(server_response) != null);
-
- var quit = new RegExp('/quit');
- assert.equal(true, quit.exec(server_response) != null);
-
- assert.equal(true, client_got_eof);
-});
+++ /dev/null
-'use strict';
-var common = require('../common');
-var assert = require('assert');
-
-var complete = false;
-var idle = new process.IdleWatcher();
-idle.callback = function() {
- complete = true;
- idle.stop();
-};
-idle.setPriority(process.EVMAXPRI);
-idle.start();
-
-process.on('exit', function() {
- assert.ok(complete);
-});
+++ /dev/null
-'use strict';
-var common = require('../common');
-var assert = require('assert');
-var net = require('net');
-
-var tests_run = 0;
-
-function fdPassingTest(path, port) {
- var greeting = 'howdy';
- var message = 'beep toot';
- var expectedData = ['[greeting] ' + greeting, '[echo] ' + message];
-
- var receiverArgs = [common.fixturesDir + '/net-fd-passing-receiver.js',
- path,
- greeting];
- var receiver = process.createChildProcess(process.ARGV[0], receiverArgs);
-
- var initializeSender = function() {
- var fdHighway = new net.Socket();
-
- fdHighway.on('connect', function() {
- var sender = net.createServer(function(socket) {
- fdHighway.sendFD(socket);
- socket.flush();
- socket.forceClose(); // want to close() the fd, not shutdown()
- });
-
- sender.on('listening', function() {
- var client = net.createConnection(port);
-
- client.on('connect', function() {
- client.write(message);
- });
-
- client.on('data', function(data) {
- assert.equal(expectedData[0], data);
- if (expectedData.length > 1) {
- expectedData.shift();
- }
- else {
- // time to shut down
- fdHighway.close();
- sender.close();
- client.forceClose();
- }
- });
- });
-
- tests_run += 1;
- sender.listen(port);
- });
-
- fdHighway.connect(path);
-
-
- };
-
- receiver.on('output', function(data) {
- var initialized = false;
- if ((! initialized) && (data == 'ready')) {
- initializeSender();
- initialized = true;
- }
- });
-}
-
-fdPassingTest('/tmp/passing-socket-test', 31075);
-
-process.on('exit', function() {
- assert.equal(1, tests_run);
-});
+++ /dev/null
-'use strict';
-var common = require('../common');
-var assert = require('assert');
-
-var net = require('net');
-var fs = require('fs');
-
-var tests_run = 0;
-
-function tlsTest(port, host, caPem, keyPem, certPem) {
- var N = 50;
- var count = 0;
- var sent_final_ping = false;
-
- var server = net.createServer(function(socket) {
- assert.equal(true, socket.remoteAddress !== null);
- assert.equal(true, socket.remoteAddress !== undefined);
- if (host === '127.0.0.1')
- assert.equal(socket.remoteAddress, '127.0.0.1');
- else if (host == null)
- assert.equal(socket.remoteAddress, '127.0.0.1');
-
- socket.setEncoding('utf8');
- socket.setNoDelay();
- socket.timeout = 0;
-
- socket.on('data', function(data) {
- var verified = socket.verifyPeer();
- var peerDN = socket.getPeerCertificate('DNstring');
- assert.equal(verified, 1);
- assert.equal(peerDN,
- 'C=UK,ST=Acknack Ltd,L=Rhys Jones,O=node.js,' +
- 'OU=Test TLS Certificate,CN=localhost');
- console.log('server got: ' + JSON.stringify(data));
- assert.equal('open', socket.readyState);
- assert.equal(true, count <= N);
- if (/PING/.exec(data)) {
- socket.write('PONG');
- }
- });
-
- socket.on('end', function() {
- assert.equal('writeOnly', socket.readyState);
- socket.end();
- });
-
- socket.on('close', function(had_error) {
- assert.equal(false, had_error);
- assert.equal('closed', socket.readyState);
- socket.server.close();
- });
- });
-
- server.setSecure('X509_PEM', caPem, 0, keyPem, certPem);
- server.listen(port, host);
-
- var client = net.createConnection(port, host);
-
- client.setEncoding('utf8');
- client.setSecure('X509_PEM', caPem, 0, keyPem, caPem);
-
- client.on('connect', function() {
- assert.equal('open', client.readyState);
- var verified = client.verifyPeer();
- var peerDN = client.getPeerCertificate('DNstring');
- assert.equal(verified, 1);
- assert.equal(peerDN,
- 'C=UK,ST=Acknack Ltd,L=Rhys Jones,O=node.js,' +
- 'OU=Test TLS Certificate,CN=localhost');
- client.write('PING');
- });
-
- client.on('data', function(data) {
- assert.equal('PONG', data);
- count += 1;
-
- console.log('client got PONG');
-
- if (sent_final_ping) {
- assert.equal('readOnly', client.readyState);
- return;
- } else {
- assert.equal('open', client.readyState);
- }
-
- if (count < N) {
- client.write('PING');
- } else {
- sent_final_ping = true;
- client.write('PING');
- client.end();
- }
- });
-
- client.on('close', function() {
- assert.equal(N + 1, count);
- assert.equal(true, sent_final_ping);
- tests_run += 1;
- });
-}
-
-
-var have_tls;
-try {
- var dummy_server = net.createServer();
- dummy_server.setSecure();
- have_tls = true;
-} catch (e) {
- have_tls = false;
-}
-
-if (have_tls) {
- var caPem = fs.readFileSync(common.fixturesDir + '/test_ca.pem');
- var certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem');
- var keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem');
-
- /* All are run at once, so run on different ports */
- tlsTest(common.PORT, 'localhost', caPem, keyPem, certPem);
- tlsTest(common.PORT + 1, null, caPem, keyPem, certPem);
-
- process.on('exit', function() {
- assert.equal(2, tests_run);
- });
-} else {
- console.log('Not compiled with TLS support -- skipping test');
- process.exit(0);
-}
+++ /dev/null
-'use strict';
-var common = require('../common');
-var assert = require('assert');
-var fs = require('fs');
-var net = require('net');
-
-var have_openssl;
-try {
- var crypto = require('crypto');
- have_openssl = true;
-} catch (e) {
- have_openssl = false;
- console.log('Not compiled with OPENSSL support.');
- process.exit();
-}
-
-var caPem = fs.readFileSync(common.fixturesDir + '/test_ca.pem', 'ascii');
-var certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii');
-var keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii');
-
-try {
- var credentials = crypto.createCredentials(
- { key: keyPem,
- cert: certPem,
- ca: caPem
- });
-} catch (e) {
- console.log('Not compiled with OPENSSL support.');
- process.exit();
-}
-
-var testData = 'TEST123';
-var serverData = '';
-var clientData = '';
-var gotSecureServer = false;
-var gotSecureClient = false;
-
-var secureServer = net.createServer(function(connection) {
- var self = this;
- connection.setSecure(credentials);
- connection.setEncoding('UTF8');
-
- connection.on('secure', function() {
- gotSecureServer = true;
- var verified = connection.verifyPeer();
- var peerDN = JSON.stringify(connection.getPeerCertificate());
- assert.equal(verified, true);
- assert.equal(peerDN,
- '{"subject":"/C=UK/ST=Acknack Ltd/L=Rhys Jones' +
- '/O=node.js/OU=Test TLS Certificate/CN=localhost",' +
- '"issuer":"/C=UK/ST=Acknack Ltd/L=Rhys Jones/O=node.js' +
- '/OU=Test TLS Certificate/CN=localhost",' +
- '"valid_from":"Nov 11 09:52:22 2009 GMT",' +
- '"valid_to":"Nov 6 09:52:22 2029 GMT",' +
- '"fingerprint":"2A:7A:C2:DD:E5:F9:CC:53:72:35:99:7A:02:' +
- '5A:71:38:52:EC:8A:DF"}');
-
- });
-
- connection.on('data', function(chunk) {
- serverData += chunk;
- connection.write(chunk);
- });
-
- connection.on('end', function() {
- assert.equal(serverData, testData);
- connection.end();
- self.close();
- });
-});
-secureServer.listen(common.PORT);
-
-secureServer.on('listening', function() {
- var secureClient = net.createConnection(common.PORT);
-
- secureClient.setEncoding('UTF8');
- secureClient.on('connect', function() {
- secureClient.setSecure(credentials);
- });
-
- secureClient.on('secure', function() {
- gotSecureClient = true;
- var verified = secureClient.verifyPeer();
- var peerDN = JSON.stringify(secureClient.getPeerCertificate());
- assert.equal(verified, true);
- assert.equal(peerDN,
- '{"subject":"/C=UK/ST=Acknack Ltd/L=Rhys Jones' +
- '/O=node.js/OU=Test TLS Certificate/CN=localhost",' +
- '"issuer":"/C=UK/ST=Acknack Ltd/L=Rhys Jones/O=node.js' +
- '/OU=Test TLS Certificate/CN=localhost",' +
- '"valid_from":"Nov 11 09:52:22 2009 GMT",' +
- '"valid_to":"Nov 6 09:52:22 2029 GMT",' +
- '"fingerprint":"2A:7A:C2:DD:E5:F9:CC:53:72:35:99:7A:02:' +
- '5A:71:38:52:EC:8A:DF"}');
-
- secureClient.write(testData);
- secureClient.end();
- });
-
- secureClient.on('data', function(chunk) {
- clientData += chunk;
- });
-
- secureClient.on('end', function() {
- assert.equal(clientData, testData);
- });
-});
-
-process.on('exit', function() {
- assert.ok(gotSecureServer, 'Did not get secure event for server');
- assert.ok(gotSecureClient, 'Did not get secure event for client');
-});
+++ /dev/null
-'use strict';
-var common = require('../common');
-var assert = require('assert');
-var spawn = require('child_process').spawn;
-
-if (process.title === '') {
- console.log('skipping test -- not implemented for the host platform');
- //return;
-}
-
-// disabled because of two things
-// - not tested on linux (can ps show process title on Linux?)
-// - unable to verify effect on Darwin/OS X (only avail through GUI tools AFAIK)
-
-function verifyProcessName(str, callback) {
- process.title = str;
- var buf = '';
- ps = spawn('ps');
- ps.stdout.setEncoding('utf8');
- ps.stdout.on('data', function(s) { buf += s; });
- ps.on('exit', function(c) {
- try {
- assert.equal(0, c);
- assert.ok(new RegExp(process.pid + ' ', 'm').test(buf));
- assert.ok(new RegExp(str, 'm').test(buf));
- callback();
- } catch (err) {
- callback(err);
- }
- });
-}
-
-verifyProcessName('3kd023mslkfp--unique-string--sksdf', function(err) {
- if (err) throw err;
- console.log('title is now %j', process.title);
- verifyProcessName('3kd023mslxxx--unique-string--xxx', function(err) {
- if (err) throw err;
- console.log('title is now %j', process.title);
- });
-});
+++ /dev/null
-'use strict';
-var common = require('../common');
-var assert = require('assert');
-
-var http = require('http');
-var util = require('util');
-var url = require('url');
-var modulesLoaded = 0;
-
-var server = http.createServer(function(req, res) {
- var body = 'exports.httpPath = function() {' +
- 'return ' + JSON.stringify(url.parse(req.url).pathname) + ';' +
- '};';
- res.writeHead(200, {'Content-Type': 'text/javascript'});
- res.write(body);
- res.end();
-});
-server.listen(common.PORT);
-
-assert.throws(function() {
- var httpModule = require('http://localhost:' + common.PORT + '/moduleA.js');
- assert.equal('/moduleA.js', httpModule.httpPath());
- modulesLoaded++;
-});
-
-var nodeBinary = process.ARGV[0];
-var cmd = 'NODE_PATH=' + common.libDir + ' ' + nodeBinary +
- ' http://localhost:' + common.PORT + '/moduleB.js';
-
-util.exec(cmd, function(err, stdout, stderr) {
- if (err) throw err;
- console.log('success!');
- modulesLoaded++;
- server.close();
-});
-
-process.on('exit', function() {
- assert.equal(1, modulesLoaded);
-});
+++ /dev/null
-/* eslint-disable no-debugger */
-'use strict';
-// Server sends a large string. Client counts bytes and pauses every few
-// seconds. Makes sure that pause and resume work properly.
-var common = require('../common');
-var assert = require('assert');
-var tls = require('tls');
-var fs = require('fs');
-
-
-var body = '';
-
-process.stdout.write('build body...');
-for (var i = 0; i < 10 * 1024 * 1024; i++) {
- body += 'hello world\n';
-}
-process.stdout.write('done\n');
-
-
-var options = {
- key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'),
- cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem')
-};
-
-var connections = 0;
-
-
-var server = tls.Server(options, function(socket) {
- socket.end(body);
- connections++;
-});
-
-var recvCount = 0;
-
-server.listen(common.PORT, function() {
- var client = tls.connect(common.PORT);
-
- client.on('data', function(d) {
- process.stdout.write('.');
- recvCount += d.length;
-
- /*
- client.pause();
- process.nextTick(function() {
- client.resume();
- });
- */
- });
-
-
- client.on('close', function() {
- debugger;
- console.log('close');
- server.close();
- });
-});
-
-
-
-process.on('exit', function() {
- assert.equal(1, connections);
- console.log('body.length: %d', body.length);
- console.log(' recvCount: %d', recvCount);
- assert.equal(body.length, recvCount);
-});
+++ /dev/null
-'use strict';
-// Example of new TLS API. Test with:
-//
-// $> openssl s_client -connect localhost:12346 \
-// -key test/fixtures/agent.key -cert test/fixtures/agent.crt
-//
-// $> openssl s_client -connect localhost:12346
-//
-var common = require('../common');
-var tls = require('tls');
-var fs = require('fs');
-var join = require('path').join;
-
-var key = fs.readFileSync(join(common.fixturesDir, 'agent.key')).toString();
-var cert = fs.readFileSync(join(common.fixturesDir, 'agent.crt')).toString();
-
-s = tls.Server({ key: key,
- cert: cert,
- ca: [],
- requestCert: true,
- rejectUnauthorized: true });
-
-s.listen(common.PORT, function() {
- console.log('TLS server on 127.0.0.1:%d', common.PORT);
-});
-
-
-s.on('authorized', function(c) {
- console.log('authed connection');
- c.end('bye authorized friend.\n');
-});
-
-s.on('unauthorized', function(c, e) {
- console.log('unauthed connection: %s', e);
- c.end('bye unauthorized person.\n');
-});
+++ /dev/null
-'use strict';
-// Can't test this when 'make test' doesn't assign a tty to the stdout.
-var common = require('../common');
-var assert = require('assert');
-var tty = require('tty');
-
-assert.ok(process.stdin instanceof tty.ReadStream);
-assert.ok(process.stdin.readable);
-assert.ok(!process.stdin.writable);
-
-assert.ok(process.stdout instanceof tty.WriteStream);
-assert.ok(!process.stdout.readable);
-assert.ok(process.stdout.writable);
+++ /dev/null
-'use strict';
-var common = require('../common');
-var tls = require('tls');
-var fs = require('fs');
-
-
-// most servers don't require certificates
-
-var options = {
- key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem')
-};
-
-
-var s = tls.connect(443, 'joyent.com', options, function() {
- if (!s.authorized) {
- console.error('CONNECTED: ' + s.authorizationError);
- s.destroy();
- return;
- }
- s.pipe(process.stdout);
- process.openStdin().pipe(s);
-});
-
+++ /dev/null
-'use strict';
-var common = require('../common');
-var assert = require('assert');
-
-var util = require('util');
-var net = require('net');
-var fs = require('fs');
-var crypto = require('crypto');
-
-//var client = net.createConnection(4443, 'localhost');
-var client = net.createConnection(443, 'www.microsoft.com');
-//var client = net.createConnection(443, 'www.google.com');
-
-var caPem = fs.readFileSync(common.fixturesDir + '/msca.pem');
-//var caPem = fs.readFileSync('ca.pem');
-
-try {
- var credentials = crypto.createCredentials({ca: caPem});
-} catch (e) {
- console.log('Not compiled with OPENSSL support.');
- process.exit();
-}
-
-client.setEncoding('UTF8');
-client.on('connect', function() {
- console.log('client connected.');
- client.setSecure(credentials);
-});
-
-client.on('secure', function() {
- console.log('client secure : ' + JSON.stringify(client.getCipher()));
- console.log(JSON.stringify(client.getPeerCertificate()));
- console.log('verifyPeer : ' + client.verifyPeer());
- client.write('GET / HTTP/1.0\r\n\r\n');
-});
-
-client.on('data', function(chunk) {
- common.error(chunk);
-});
-
-client.on('end', function() {
- console.log('client disconnected.');
-});
-