Lint all the JavaScripts.
This commit is contained in:
parent
31721da4b1
commit
0cdf85e28d
@ -112,8 +112,8 @@ Protocol.prototype.execute = function(d) {
|
||||
|
||||
this.state = 'body';
|
||||
|
||||
if (Buffer.byteLength(res.raw, 'utf8') - this.bodyStartByteIndex
|
||||
< this.contentLength) {
|
||||
var len = Buffer.byteLength(res.raw, 'utf8');
|
||||
if (len - this.bodyStartByteIndex < this.contentLength) {
|
||||
break;
|
||||
}
|
||||
// pass thru
|
||||
@ -125,16 +125,16 @@ Protocol.prototype.execute = function(d) {
|
||||
buf.write(res.raw, 0, resRawByteLength, 'utf8');
|
||||
res.body =
|
||||
buf.slice(this.bodyStartByteIndex,
|
||||
this.bodyStartByteIndex
|
||||
+ this.contentLength).toString('utf8');
|
||||
this.bodyStartByteIndex +
|
||||
this.contentLength).toString('utf8');
|
||||
// JSON parse body?
|
||||
res.body = res.body.length ? JSON.parse(res.body) : {};
|
||||
|
||||
// Done!
|
||||
this.onResponse(res);
|
||||
|
||||
this._newRes(buf.slice(this.bodyStartByteIndex
|
||||
+ this.contentLength).toString('utf8'));
|
||||
this._newRes(buf.slice(this.bodyStartByteIndex +
|
||||
this.contentLength).toString('utf8'));
|
||||
}
|
||||
break;
|
||||
|
||||
@ -149,8 +149,8 @@ Protocol.prototype.serialize = function(req) {
|
||||
req.type = 'request';
|
||||
req.seq = this.reqSeq++;
|
||||
var json = JSON.stringify(req);
|
||||
return 'Content-Length: ' + Buffer.byteLength(json,'utf8') + '\r\n\r\n'
|
||||
+ json;
|
||||
return 'Content-Length: ' + Buffer.byteLength(json, 'utf8') +
|
||||
'\r\n\r\n' + json;
|
||||
};
|
||||
|
||||
|
||||
|
@ -115,7 +115,7 @@ function setupChannel(target, channel) {
|
||||
throw new TypeError('message cannot be undefined');
|
||||
}
|
||||
|
||||
if (!this.connected) throw new Error("channel closed");
|
||||
if (!this.connected) throw new Error('channel closed');
|
||||
|
||||
// For overflow protection don't write if channel queue is too deep.
|
||||
if (channel.writeQueueSize > 1024 * 1024) {
|
||||
|
@ -32,7 +32,7 @@ function errnoException(errorno, syscall) {
|
||||
|
||||
// For backwards compatibility. libuv returns ENOENT on NXDOMAIN.
|
||||
if (errorno == 'ENOENT') {
|
||||
errorno = 'ENOTFOUND'
|
||||
errorno = 'ENOTFOUND';
|
||||
}
|
||||
|
||||
e.errno = e.code = errorno;
|
||||
|
20
lib/fs.js
20
lib/fs.js
@ -262,7 +262,9 @@ fs.open = function(path, flags, mode, callback) {
|
||||
|
||||
mode = modeNum(mode, 438 /*=0666*/);
|
||||
|
||||
binding.open(pathModule._makeLong(path), stringToFlags(flags), mode,
|
||||
binding.open(pathModule._makeLong(path),
|
||||
stringToFlags(flags),
|
||||
mode,
|
||||
callback);
|
||||
};
|
||||
|
||||
@ -363,7 +365,8 @@ fs.writeSync = function(fd, buffer, offset, length, position) {
|
||||
};
|
||||
|
||||
fs.rename = function(oldPath, newPath, callback) {
|
||||
binding.rename(pathModule._makeLong(oldPath), pathModule._makeLong(newPath),
|
||||
binding.rename(pathModule._makeLong(oldPath),
|
||||
pathModule._makeLong(newPath),
|
||||
callback || noop);
|
||||
};
|
||||
|
||||
@ -477,7 +480,8 @@ fs.symlinkSync = function(destination, path, type) {
|
||||
};
|
||||
|
||||
fs.link = function(srcpath, dstpath, callback) {
|
||||
binding.link(pathModule._makeLong(srcpath), pathModule._makeLong(dstpath),
|
||||
binding.link(pathModule._makeLong(srcpath),
|
||||
pathModule._makeLong(dstpath),
|
||||
callback || noop);
|
||||
};
|
||||
|
||||
@ -637,7 +641,10 @@ function writeAll(fd, buffer, offset, length, position, callback) {
|
||||
if (written === length) {
|
||||
fs.close(fd, callback);
|
||||
} else {
|
||||
writeAll(fd, buffer, offset + written, length - written, position + written, callback);
|
||||
offset += written;
|
||||
length -= written;
|
||||
position += written;
|
||||
writeAll(fd, buffer, offset, length, position, callback);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -1462,7 +1469,8 @@ function SyncWriteStream(fd) {
|
||||
this.fd = fd;
|
||||
this.writable = true;
|
||||
this.readable = false;
|
||||
};
|
||||
}
|
||||
|
||||
util.inherits(SyncWriteStream, Stream);
|
||||
|
||||
|
||||
@ -1481,7 +1489,7 @@ SyncWriteStream.prototype.write = function(data, arg1, arg2) {
|
||||
} else if (typeof arg1 === 'function') {
|
||||
cb = arg1;
|
||||
} else {
|
||||
throw new Error("bad arg");
|
||||
throw new Error('bad arg');
|
||||
}
|
||||
}
|
||||
|
||||
|
39
lib/http.js
39
lib/http.js
@ -549,13 +549,16 @@ OutgoingMessage.prototype._storeHeader = function(firstLine, headers) {
|
||||
|
||||
// Date header
|
||||
if (this.sendDate == true && sentDateHeader == false) {
|
||||
messageHeader += "Date: " + utcDate() + CRLF;
|
||||
messageHeader += 'Date: ' + utcDate() + CRLF;
|
||||
}
|
||||
|
||||
// keep-alive logic
|
||||
if (sentConnectionHeader === false) {
|
||||
if (this.shouldKeepAlive &&
|
||||
(sentContentLengthHeader || this.useChunkedEncodingByDefault || this.agent)) {
|
||||
var shouldSendKeepAlive = this.shouldKeepAlive &&
|
||||
(sentContentLengthHeader ||
|
||||
this.useChunkedEncodingByDefault ||
|
||||
this.agent);
|
||||
if (shouldSendKeepAlive) {
|
||||
messageHeader += 'Connection: keep-alive\r\n';
|
||||
} else {
|
||||
this._last = true;
|
||||
@ -588,11 +591,11 @@ OutgoingMessage.prototype._storeHeader = function(firstLine, headers) {
|
||||
|
||||
OutgoingMessage.prototype.setHeader = function(name, value) {
|
||||
if (arguments.length < 2) {
|
||||
throw new Error("`name` and `value` are required for setHeader().");
|
||||
throw new Error('`name` and `value` are required for setHeader().');
|
||||
}
|
||||
|
||||
if (this._header) {
|
||||
throw new Error("Can't set headers after they are sent.");
|
||||
throw new Error('Can\'t set headers after they are sent.');
|
||||
}
|
||||
|
||||
var key = name.toLowerCase();
|
||||
@ -605,7 +608,7 @@ OutgoingMessage.prototype.setHeader = function(name, value) {
|
||||
|
||||
OutgoingMessage.prototype.getHeader = function(name) {
|
||||
if (arguments.length < 1) {
|
||||
throw new Error("`name` is required for getHeader().");
|
||||
throw new Error('`name` is required for getHeader().');
|
||||
}
|
||||
|
||||
if (!this._headers) return;
|
||||
@ -617,11 +620,11 @@ OutgoingMessage.prototype.getHeader = function(name) {
|
||||
|
||||
OutgoingMessage.prototype.removeHeader = function(name) {
|
||||
if (arguments.length < 1) {
|
||||
throw new Error("`name` is required for removeHeader().");
|
||||
throw new Error('`name` is required for removeHeader().');
|
||||
}
|
||||
|
||||
if (this._header) {
|
||||
throw new Error("Can't remove headers after they are sent.");
|
||||
throw new Error('Can\'t remove headers after they are sent.');
|
||||
}
|
||||
|
||||
if (!this._headers) return;
|
||||
@ -634,7 +637,7 @@ OutgoingMessage.prototype.removeHeader = function(name) {
|
||||
|
||||
OutgoingMessage.prototype._renderHeaders = function() {
|
||||
if (this._header) {
|
||||
throw new Error("Can't render headers after they are sent to the client.");
|
||||
throw new Error('Can\'t render headers after they are sent to the client.');
|
||||
}
|
||||
|
||||
if (!this._headers) return {};
|
||||
@ -1037,7 +1040,7 @@ Agent.prototype.createSocket = function(name, host, port) {
|
||||
}
|
||||
s.on('close', onClose);
|
||||
var onRemove = function() {
|
||||
// We need this function for cases like HTTP "upgrade"
|
||||
// We need this function for cases like HTTP 'upgrade'
|
||||
// (defined by WebSockets) where we need to remove a socket from the pool
|
||||
// because it'll be locked up indefinitely
|
||||
self.removeSocket(s, name, host, port);
|
||||
@ -1145,10 +1148,11 @@ function ClientRequest(options, cb) {
|
||||
self._last = true;
|
||||
self.shouldKeepAlive = false;
|
||||
if (options.createConnection) {
|
||||
self.onSocket(options.createConnection(options.port, options.host, options));
|
||||
var conn = options.createConnection(options.port, options.host, options);
|
||||
} else {
|
||||
self.onSocket(net.createConnection(options.port, options.host));
|
||||
var conn = net.createConnection(options.port, options.host);
|
||||
}
|
||||
self.onSocket(conn);
|
||||
}
|
||||
|
||||
self._deferToConnect(null, null, function() {
|
||||
@ -1161,7 +1165,8 @@ util.inherits(ClientRequest, OutgoingMessage);
|
||||
exports.ClientRequest = ClientRequest;
|
||||
|
||||
ClientRequest.prototype._implicitHeader = function() {
|
||||
this._storeHeader(this.method + ' ' + this.path + ' HTTP/1.1\r\n', this._renderHeaders());
|
||||
this._storeHeader(this.method + ' ' + this.path + ' HTTP/1.1\r\n',
|
||||
this._renderHeaders());
|
||||
};
|
||||
|
||||
ClientRequest.prototype.abort = function() {
|
||||
@ -1204,7 +1209,7 @@ ClientRequest.prototype.onSocket = function(socket) {
|
||||
}
|
||||
|
||||
socket._httpMessage = req;
|
||||
// Setup "drain" propogation.
|
||||
// Setup 'drain' propogation.
|
||||
httpSocketSetup(socket);
|
||||
|
||||
var freeParser = function() {
|
||||
@ -1290,7 +1295,7 @@ ClientRequest.prototype.onSocket = function(socket) {
|
||||
debug('HTTP socket close');
|
||||
req.emit('close');
|
||||
if (req.res && req.res.readable) {
|
||||
// Socket closed before we emitted "end" below.
|
||||
// Socket closed before we emitted 'end' below.
|
||||
req.res.emit('aborted');
|
||||
req.res.emit('end');
|
||||
req.res.emit('close');
|
||||
@ -1661,7 +1666,7 @@ Client.prototype.request = function(method, path, headers) {
|
||||
c.on('error', function(e) {
|
||||
self.emit('error', e);
|
||||
});
|
||||
// The old Client interface emitted "end" on socket end.
|
||||
// The old Client interface emitted 'end' on socket end.
|
||||
// This doesn't map to how we want things to operate in the future
|
||||
// but it will get removed when we remove this legacy interface.
|
||||
c.on('socket', function(s) {
|
||||
@ -1675,7 +1680,7 @@ Client.prototype.request = function(method, path, headers) {
|
||||
exports.Client = Client;
|
||||
|
||||
// TODO http.Client can be removed in v0.9. Until then leave this message.
|
||||
module.deprecate('Client', 'It will be removed in the near future. Do not use it.');
|
||||
module.deprecate('Client', 'It will be removed soon. Do not use it.');
|
||||
|
||||
exports.createClient = function(port, host) {
|
||||
return new Client(port, host);
|
||||
|
@ -55,12 +55,12 @@ function createConnection(port, host, options) {
|
||||
options.port = port;
|
||||
options.host = host;
|
||||
return tls.connect(options);
|
||||
};
|
||||
}
|
||||
|
||||
function Agent(options) {
|
||||
http.Agent.call(this, options);
|
||||
this.createConnection = createConnection;
|
||||
};
|
||||
}
|
||||
inherits(Agent, http.Agent);
|
||||
Agent.prototype.defaultPort = 443;
|
||||
|
||||
|
21
lib/net.js
21
lib/net.js
@ -25,7 +25,7 @@ var timers = require('timers');
|
||||
var util = require('util');
|
||||
var assert = require('assert');
|
||||
|
||||
function noop() {};
|
||||
function noop() {}
|
||||
|
||||
// constructor for lazy loading
|
||||
function createPipe() {
|
||||
@ -178,7 +178,7 @@ Socket.prototype.setTimeout = function(msecs, callback) {
|
||||
|
||||
|
||||
Socket.prototype._onTimeout = function() {
|
||||
debug("_onTimeout");
|
||||
debug('_onTimeout');
|
||||
this.emit('timeout');
|
||||
};
|
||||
|
||||
@ -449,7 +449,7 @@ Socket.prototype.write = function(data, arg1, arg2) {
|
||||
} else if (typeof arg1 === 'function') {
|
||||
cb = arg1;
|
||||
} else {
|
||||
throw new Error("bad arg");
|
||||
throw new Error('bad arg');
|
||||
}
|
||||
}
|
||||
|
||||
@ -457,7 +457,7 @@ Socket.prototype.write = function(data, arg1, arg2) {
|
||||
if (typeof data === 'string') {
|
||||
data = new Buffer(data, encoding);
|
||||
} else if (!Buffer.isBuffer(data)) {
|
||||
throw new TypeError("First argument must be a buffer or a string.");
|
||||
throw new TypeError('First argument must be a buffer or a string.');
|
||||
}
|
||||
|
||||
this.bytesWritten += data.length;
|
||||
@ -782,12 +782,13 @@ Server.prototype._listen2 = function(address, port, addressType) {
|
||||
process.nextTick(function() {
|
||||
self.emit('listening');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
function listen(self, address, port, addressType) {
|
||||
if (process.env.NODE_UNIQUE_ID) {
|
||||
require('cluster')._getServer(self, address, port, addressType, function(handle) {
|
||||
var cluster = require('cluster');
|
||||
cluster._getServer(self, address, port, addressType, function(handle) {
|
||||
self._handle = handle;
|
||||
self._listen2(address, port, addressType);
|
||||
});
|
||||
@ -958,14 +959,14 @@ if (process.platform === 'win32') {
|
||||
|
||||
if (typeof simultaneousAccepts === 'undefined') {
|
||||
simultaneousAccepts = (process.env.NODE_MANY_ACCEPTS &&
|
||||
process.env.NODE_MANY_ACCEPTS != '0') ? true : false;
|
||||
process.env.NODE_MANY_ACCEPTS !== '0');
|
||||
}
|
||||
|
||||
if (handle._simultaneousAccepts != simultaneousAccepts) {
|
||||
if (handle._simultaneousAccepts !== simultaneousAccepts) {
|
||||
handle.setSimultaneousAccepts(simultaneousAccepts);
|
||||
handle._simultaneousAccepts = simultaneousAccepts;
|
||||
}
|
||||
}
|
||||
};
|
||||
} else {
|
||||
exports._setSimultaneousAccepts = function(handle) {}
|
||||
exports._setSimultaneousAccepts = function(handle) {};
|
||||
}
|
||||
|
@ -40,4 +40,5 @@ exports.platform = function() {
|
||||
exports.getNetworkInterfaces = function() {
|
||||
return exports.networkInterfaces();
|
||||
};
|
||||
module.deprecate('getNetworkInterfaces', 'It is now called `os.networkInterfaces`.');
|
||||
module.deprecate('getNetworkInterfaces',
|
||||
'It is now called `os.networkInterfaces`.');
|
||||
|
20
lib/path.js
20
lib/path.js
@ -62,7 +62,8 @@ if (isWindows) {
|
||||
/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?([\\\/])?([\s\S]*?)$/;
|
||||
|
||||
// Regex to split the tail part of the above into [*, dir, basename, ext]
|
||||
var splitTailRe = /^([\s\S]+[\\\/](?!$)|[\\\/])?((?:\.{1,2}$|[\s\S]+?)?(\.[^.\/\\]*)?)$/;
|
||||
var splitTailRe =
|
||||
/^([\s\S]+[\\\/](?!$)|[\\\/])?((?:\.{1,2}$|[\s\S]+?)?(\.[^.\/\\]*)?)$/;
|
||||
|
||||
// Function to split a filename into [root, dir, basename, ext]
|
||||
// windows version
|
||||
@ -262,7 +263,8 @@ if (isWindows) {
|
||||
|
||||
// Split a filename into [root, dir, basename, ext], unix version
|
||||
// 'root' is just a slash, or nothing.
|
||||
var splitPathRe = /^(\/?)([\s\S]+\/(?!$)|\/)?((?:\.{1,2}$|[\s\S]+?)?(\.[^.\/]*)?)$/;
|
||||
var splitPathRe =
|
||||
/^(\/?)([\s\S]+\/(?!$)|\/)?((?:\.{1,2}$|[\s\S]+?)?(\.[^.\/]*)?)$/;
|
||||
var splitPath = function(filename) {
|
||||
var result = splitPathRe.exec(filename);
|
||||
return [result[1] || '', result[2] || '', result[3] || '', result[4] || ''];
|
||||
@ -420,11 +422,11 @@ exports.existsSync = function(path) {
|
||||
module.deprecate('existsSync', 'It is now called `fs.existsSync`.');
|
||||
|
||||
|
||||
exports._makeLong = isWindows ?
|
||||
function(path) {
|
||||
path = "" + path;
|
||||
if (isWindows) {
|
||||
exports._makeLong = function(path) {
|
||||
path = '' + path;
|
||||
if (!path) {
|
||||
return "";
|
||||
return '';
|
||||
}
|
||||
|
||||
var resolvedPath = exports.resolve(path);
|
||||
@ -440,7 +442,9 @@ exports._makeLong = isWindows ?
|
||||
}
|
||||
|
||||
return path;
|
||||
} :
|
||||
function(path) {
|
||||
};
|
||||
} else {
|
||||
exports._makeLong = function(path) {
|
||||
return path;
|
||||
};
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ QueryString.parse = QueryString.decode = function(qs, sep, eq, options) {
|
||||
throw 'has +';
|
||||
}
|
||||
k = decodeURIComponent(x[0]);
|
||||
v = decodeURIComponent(x.slice(1).join(eq) || "");
|
||||
v = decodeURIComponent(x.slice(1).join(eq) || '');
|
||||
} catch (e) {
|
||||
k = QueryString.unescape(x[0], true);
|
||||
v = QueryString.unescape(x.slice(1).join(eq), true);
|
||||
|
18
lib/repl.js
18
lib/repl.js
@ -285,9 +285,13 @@ REPLServer.prototype.resetContext = function(force) {
|
||||
};
|
||||
|
||||
REPLServer.prototype.displayPrompt = function(preserveCursor) {
|
||||
this.rli.setPrompt(this.bufferedCommand.length ?
|
||||
'...' + new Array(this.lines.level.length).join('..') + ' ' :
|
||||
this.prompt);
|
||||
var prompt = this.prompt;
|
||||
if (this.bufferedCommand.length) {
|
||||
prompt = '...';
|
||||
var levelInd = new Array(this.lines.level.length).join('..');
|
||||
prompt += levelInd + ' ';
|
||||
}
|
||||
this.rli.setPrompt(prompt);
|
||||
this.rli.prompt(preserveCursor);
|
||||
};
|
||||
|
||||
@ -674,9 +678,11 @@ REPLServer.prototype.memory = function memory (cmd) {
|
||||
// "function()
|
||||
// {" but nothing should break, only tab completion for local
|
||||
// scope will not work for this function.
|
||||
self.lines.level.push({ line: self.lines.length - 1,
|
||||
self.lines.level.push({
|
||||
line: self.lines.length - 1,
|
||||
depth: depth,
|
||||
isFunction: /\s*function\s*/.test(cmd)});
|
||||
isFunction: /\s*function\s*/.test(cmd)
|
||||
});
|
||||
} else if (depth < 0) {
|
||||
// going... up.
|
||||
var curr = self.lines.level.pop();
|
||||
@ -763,7 +769,7 @@ function defineDefaultCommands(repl) {
|
||||
fs.writeFileSync(file, this.lines.join('\n') + '\n');
|
||||
this.outputStream.write('Session saved to:' + file + '\n');
|
||||
} catch (e) {
|
||||
this.outputStream.write('Failed to save:' + file+ '\n')
|
||||
this.outputStream.write('Failed to save:' + file + '\n');
|
||||
}
|
||||
this.displayPrompt();
|
||||
}
|
||||
|
@ -903,6 +903,8 @@ function Server(/* [options], listener */) {
|
||||
|
||||
if (!(this instanceof Server)) return new Server(options, listener);
|
||||
|
||||
this._contexts = [];
|
||||
|
||||
var self = this;
|
||||
|
||||
// Handle option defaults:
|
||||
@ -1018,7 +1020,6 @@ Server.prototype.setOptions = function(options) {
|
||||
};
|
||||
|
||||
// SNI Contexts High-Level API
|
||||
Server.prototype._contexts = [];
|
||||
Server.prototype.addContext = function(servername, credentials) {
|
||||
if (!servername) {
|
||||
throw 'Servername is required parameter for Server.addContext';
|
||||
|
@ -54,8 +54,9 @@ exports.indirectInstanceOf = function(obj, cls) {
|
||||
|
||||
exports.ddCommand = function(filename, kilobytes) {
|
||||
if (process.platform == 'win32') {
|
||||
return '"' + process.argv[0] + '" "' + path.resolve(exports.fixturesDir,
|
||||
'create-file.js') + '" "' + filename + '" ' + (kilobytes * 1024);
|
||||
var p = path.resolve(exports.fixturesDir, 'create-file.js');
|
||||
return '"' + process.argv[0] + '" "' + p + '" "' +
|
||||
filename + '" ' + (kilobytes * 1024);
|
||||
} else {
|
||||
return 'dd if=/dev/zero of="' + filename + '" bs=1024 count=' + kilobytes;
|
||||
}
|
||||
|
@ -28,6 +28,6 @@ var assert = require('assert');
|
||||
common.error('before');
|
||||
|
||||
// custom error throwing
|
||||
throw { name: 'MyCustomError', message: 'This is a custom message' };
|
||||
throw ({ name: 'MyCustomError', message: 'This is a custom message' });
|
||||
|
||||
common.error('after');
|
||||
|
@ -28,6 +28,6 @@ var assert = require('assert');
|
||||
common.error('before');
|
||||
|
||||
// custom error throwing
|
||||
throw { foo: 'bar' };
|
||||
throw ({ foo: 'bar' });
|
||||
|
||||
common.error('after');
|
||||
|
@ -29,7 +29,7 @@ var fs = require('fs');
|
||||
var LIMITS = [0, 1, 2, 3, 5, 10, 16];
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
console.log("Skipping test, you probably don't have openssl installed.");
|
||||
console.log('Skipping test, you probably don\'t have openssl installed.');
|
||||
process.exit();
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ function test(next) {
|
||||
// simulate renegotiation attack
|
||||
function spam() {
|
||||
if (closed) return;
|
||||
child.stdin.write("R\n");
|
||||
child.stdin.write('R\n');
|
||||
setTimeout(spam, 250);
|
||||
}
|
||||
});
|
||||
|
@ -214,7 +214,7 @@ threw = false;
|
||||
try {
|
||||
assert.throws(
|
||||
function() {
|
||||
throw {};
|
||||
throw ({});
|
||||
},
|
||||
Array
|
||||
);
|
||||
|
@ -33,7 +33,8 @@ var grep = spawn('grep', ['o']),
|
||||
echo;
|
||||
|
||||
if (is_windows) {
|
||||
echo = spawn('cmd.exe', ['/c', 'echo', 'hello&&', 'echo',
|
||||
echo = spawn('cmd.exe',
|
||||
['/c', 'echo', 'hello&&', 'echo',
|
||||
'node&&', 'echo', 'and&&', 'echo', 'world']);
|
||||
} else {
|
||||
echo = spawn('echo', ['hello\nnode\nand\nworld\n']);
|
||||
|
@ -52,7 +52,8 @@ if (process.argv[2] === 'pipetest') {
|
||||
// testcase | start parent && child IPC test
|
||||
|
||||
// testing: is stderr and stdout piped to parent
|
||||
var parent = childProcess.spawn(process.execPath, [process.argv[1], 'parent']);
|
||||
var args = [process.argv[1], 'parent'];
|
||||
var parent = childProcess.spawn(process.execPath, args);
|
||||
|
||||
//got any stderr or std data
|
||||
var stdoutData = false;
|
||||
|
@ -125,8 +125,10 @@ if (cluster.isWorker) {
|
||||
});
|
||||
|
||||
process.once('exit', function() {
|
||||
assert.ok(existMaster, 'The master did not die after an error was throwed');
|
||||
assert.ok(existWorker, 'The workers did not die after an error in the master');
|
||||
var m = 'The master did not die after an error was throwed';
|
||||
assert.ok(existMaster, m);
|
||||
m = 'The workers did not die after an error in the master';
|
||||
assert.ok(existWorker, m);
|
||||
});
|
||||
|
||||
}
|
||||
|
@ -83,7 +83,8 @@ if (cluster.isWorker) {
|
||||
process.once('exit', function() {
|
||||
assert.ok(checks.args, 'The arguments was noy send to the worker');
|
||||
assert.ok(checks.setupEvent, 'The setup event was never emitted');
|
||||
assert.ok(checks.settingsObject, 'The settingsObject do not have correct properties');
|
||||
var m = 'The settingsObject do not have correct properties';
|
||||
assert.ok(checks.settingsObject, m);
|
||||
});
|
||||
|
||||
}
|
||||
|
@ -47,14 +47,25 @@ var CIPHER_NAME = 'aes-128-cbc';
|
||||
* Expected result data
|
||||
*/
|
||||
|
||||
// echo -n 'Hello node world!' | openssl enc -aes-128-cbc -e -K 5333632e722e652e742e4b2e652e5921 -iv 626c616846697a7a3230313142757a7a | xxd -p -c256
|
||||
var ODD_LENGTH_ENCRYPTED = '7f57859550d4d2fdb9806da2a750461a9fe77253cd1cbd4b07beee4e070d561f';
|
||||
// echo -n 'Hello node world!' | \
|
||||
// openssl enc -aes-128-cbc -e -K 5333632e722e652e742e4b2e652e5921 \
|
||||
// -iv 626c616846697a7a3230313142757a7a | xxd -p -c256
|
||||
var ODD_LENGTH_ENCRYPTED =
|
||||
'7f57859550d4d2fdb9806da2a750461a9fe77253cd1cbd4b07beee4e070d561f';
|
||||
|
||||
// echo -n 'Hello node world!AbC09876dDeFgHi' | openssl enc -aes-128-cbc -e -K 5333632e722e652e742e4b2e652e5921 -iv 626c616846697a7a3230313142757a7a | xxd -p -c256
|
||||
var EVEN_LENGTH_ENCRYPTED = '7f57859550d4d2fdb9806da2a750461ab46e71b3d78ebe2d9684dfc87f7575b9886119866912cb8c7bcaf76c5ebc2378';
|
||||
// echo -n 'Hello node world!AbC09876dDeFgHi' | \
|
||||
// openssl enc -aes-128-cbc -e -K 5333632e722e652e742e4b2e652e5921 \
|
||||
// -iv 626c616846697a7a3230313142757a7a | xxd -p -c256
|
||||
var EVEN_LENGTH_ENCRYPTED =
|
||||
'7f57859550d4d2fdb9806da2a750461ab46e71b3d78ebe2d9684dfc87f7575b988' +
|
||||
'6119866912cb8c7bcaf76c5ebc2378';
|
||||
|
||||
// echo -n 'Hello node world!AbC09876dDeFgHi' | openssl enc -aes-128-cbc -e -K 5333632e722e652e742e4b2e652e5921 -iv 626c616846697a7a3230313142757a7a -nopad | xxd -p -c256
|
||||
var EVEN_LENGTH_ENCRYPTED_NOPAD = '7f57859550d4d2fdb9806da2a750461ab46e71b3d78ebe2d9684dfc87f7575b9';
|
||||
// echo -n 'Hello node world!AbC09876dDeFgHi' | \
|
||||
// openssl enc -aes-128-cbc -e -K 5333632e722e652e742e4b2e652e5921 \
|
||||
// -iv 626c616846697a7a3230313142757a7a -nopad | xxd -p -c256
|
||||
var EVEN_LENGTH_ENCRYPTED_NOPAD =
|
||||
'7f57859550d4d2fdb9806da2a750461ab46e' +
|
||||
'71b3d78ebe2d9684dfc87f7575b9';
|
||||
|
||||
|
||||
/*
|
||||
|
@ -69,44 +69,80 @@ var rfc4231 = [
|
||||
data: new Buffer('4869205468657265', 'hex'), // 'Hi There'
|
||||
hmac: {
|
||||
sha224: '896fb1128abbdf196832107cd49df33f47b4b1169912ba4f53684b22',
|
||||
sha256: 'b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7',
|
||||
sha384: 'afd03944d84895626b0825f4ab46907f15f9dadbe4101ec682aa034c7cebc59cfaea9ea9076ede7f4af152e8b2fa9cb6',
|
||||
sha512: '87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cdedaa833b7d6b8a702038b274eaea3f4e4be9d914eeb61f1702e696c203a126854'
|
||||
sha256:
|
||||
'b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c' +
|
||||
'2e32cff7',
|
||||
sha384:
|
||||
'afd03944d84895626b0825f4ab46907f15f9dadbe4101ec682aa034c' +
|
||||
'7cebc59cfaea9ea9076ede7f4af152e8b2fa9cb6',
|
||||
sha512:
|
||||
'87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b305' +
|
||||
'45e17cdedaa833b7d6b8a702038b274eaea3f4e4be9d914eeb61f170' +
|
||||
'2e696c203a126854'
|
||||
}
|
||||
},
|
||||
{
|
||||
key: new Buffer('4a656665', 'hex'), // 'Jefe'
|
||||
data: new Buffer('7768617420646f2079612077616e7420666f72206e6f7468696e673f', 'hex'), // 'what do ya want for nothing?'
|
||||
data: new Buffer('7768617420646f2079612077616e7420666f72206e6f74686' +
|
||||
'96e673f', 'hex'), // 'what do ya want for nothing?'
|
||||
hmac: {
|
||||
sha224: 'a30e01098bc6dbbf45690f3a7e9e6d0f8bbea2a39e6148008fd05e44',
|
||||
sha256: '5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843',
|
||||
sha384: 'af45d2e376484031617f78d2b58a6b1b9c7ef464f5a01b47e42ec3736322445e8e2240ca5e69e2c78b3239ecfab21649',
|
||||
sha512: '164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b636e070a38bce737'
|
||||
sha256:
|
||||
'5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b9' +
|
||||
'64ec3843',
|
||||
sha384:
|
||||
'af45d2e376484031617f78d2b58a6b1b9c7ef464f5a01b47e42ec373' +
|
||||
'6322445e8e2240ca5e69e2c78b3239ecfab21649',
|
||||
sha512:
|
||||
'164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7' +
|
||||
'ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b' +
|
||||
'636e070a38bce737'
|
||||
}
|
||||
},
|
||||
{
|
||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
||||
data: new Buffer('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd', 'hex'),
|
||||
data: new Buffer('ddddddddddddddddddddddddddddddddddddddddddddddddd' +
|
||||
'ddddddddddddddddddddddddddddddddddddddddddddddddddd',
|
||||
'hex'),
|
||||
hmac: {
|
||||
sha224: '7fb3cb3588c6c1f6ffa9694d7d6ad2649365b0c1f65d69d1ec8333ea',
|
||||
sha256: '773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fe',
|
||||
sha384: '88062608d3e6ad8a0aa2ace014c8a86f0aa635d947ac9febe83ef4e55966144b2a5ab39dc13814b94e3ab6e101a34f27',
|
||||
sha512: 'fa73b0089d56a284efb0f0756c890be9b1b5dbdd8ee81a3655f83e33b2279d39bf3e848279a722c806b485a47e67c807b946a337bee8942674278859e13292fb'
|
||||
sha256:
|
||||
'773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514' +
|
||||
'ced565fe',
|
||||
sha384:
|
||||
'88062608d3e6ad8a0aa2ace014c8a86f0aa635d947ac9febe83ef4e5' +
|
||||
'5966144b2a5ab39dc13814b94e3ab6e101a34f27',
|
||||
sha512:
|
||||
'fa73b0089d56a284efb0f0756c890be9b1b5dbdd8ee81a3655f83e33' +
|
||||
'b2279d39bf3e848279a722c806b485a47e67c807b946a337bee89426' +
|
||||
'74278859e13292fb'
|
||||
}
|
||||
},
|
||||
{
|
||||
key: new Buffer('0102030405060708090a0b0c0d0e0f10111213141516171819', 'hex'),
|
||||
data: new Buffer('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd', 'hex'),
|
||||
key: new Buffer('0102030405060708090a0b0c0d0e0f10111213141516171819',
|
||||
'hex'),
|
||||
data: new Buffer('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdc' +
|
||||
'dcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd',
|
||||
'hex'),
|
||||
hmac: {
|
||||
sha224: '6c11506874013cac6a2abc1bb382627cec6a90d86efc012de7afec5a',
|
||||
sha256: '82558a389a443c0ea4cc819899f2083a85f0faa3e578f8077a2e3ff46729665b',
|
||||
sha384: '3e8a69b7783c25851933ab6290af6ca77a9981480850009cc5577c6e1f573b4e6801dd23c4a7d679ccf8a386c674cffb',
|
||||
sha512: 'b0ba465637458c6990e5a8c5f61d4af7e576d97ff94b872de76f8050361ee3dba91ca5c11aa25eb4d679275cc5788063a5f19741120c4f2de2adebeb10a298dd'
|
||||
sha256:
|
||||
'82558a389a443c0ea4cc819899f2083a85f0faa3e578f8077a2e3ff4' +
|
||||
'6729665b',
|
||||
sha384:
|
||||
'3e8a69b7783c25851933ab6290af6ca77a9981480850009cc5577c6e' +
|
||||
'1f573b4e6801dd23c4a7d679ccf8a386c674cffb',
|
||||
sha512:
|
||||
'b0ba465637458c6990e5a8c5f61d4af7e576d97ff94b872de76f8050' +
|
||||
'361ee3dba91ca5c11aa25eb4d679275cc5788063a5f19741120c4f2d' +
|
||||
'e2adebeb10a298dd'
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
key: new Buffer('0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c', 'hex'),
|
||||
data: new Buffer('546573742057697468205472756e636174696f6e', 'hex'), // 'Test With Truncation'
|
||||
// 'Test With Truncation'
|
||||
data: new Buffer('546573742057697468205472756e636174696f6e', 'hex'),
|
||||
hmac: {
|
||||
sha224: '0e2aea68a90c8d37c988bcdb9fca6fa8',
|
||||
sha256: 'a3b6167473100ee06e0c796c2955552b',
|
||||
@ -116,23 +152,59 @@ var rfc4231 = [
|
||||
truncate: true
|
||||
},
|
||||
{
|
||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
||||
data: new Buffer('54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374', 'hex'), // 'Test Using Larger Than Block-Size Key - Hash Key First'
|
||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
|
||||
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
|
||||
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
|
||||
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
|
||||
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
|
||||
'aaaaaaaaaaaa', 'hex'),
|
||||
// 'Test Using Larger Than Block-Size Key - Hash Key First'
|
||||
data: new Buffer('54657374205573696e67204c6172676572205468616e20426' +
|
||||
'c6f636b2d53697a65204b6579202d2048617368204b657920' +
|
||||
'4669727374', 'hex'),
|
||||
hmac: {
|
||||
sha224: '95e9a0db962095adaebe9b2d6f0dbce2d499f112f2d2b7273fa6870e',
|
||||
sha256: '60e431591ee0b67f0d8a26aacbf5b77f8e0bc6213728c5140546040f0ee37f54',
|
||||
sha384: '4ece084485813e9088d2c63a041bc5b44f9ef1012a2b588f3cd11f05033ac4c60c2ef6ab4030fe8296248df163f44952',
|
||||
sha512: '80b24263c7c1a3ebb71493c1dd7be8b49b46d1f41b4aeec1121b013783f8f3526b56d037e05f2598bd0fd2215d6a1e5295e64f73f63f0aec8b915a985d786598'
|
||||
sha256:
|
||||
'60e431591ee0b67f0d8a26aacbf5b77f8e0bc6213728c5140546040f' +
|
||||
'0ee37f54',
|
||||
sha384:
|
||||
'4ece084485813e9088d2c63a041bc5b44f9ef1012a2b588f3cd11f05' +
|
||||
'033ac4c60c2ef6ab4030fe8296248df163f44952',
|
||||
sha512:
|
||||
'80b24263c7c1a3ebb71493c1dd7be8b49b46d1f41b4aeec1121b0137' +
|
||||
'83f8f3526b56d037e05f2598bd0fd2215d6a1e5295e64f73f63f0aec' +
|
||||
'8b915a985d786598'
|
||||
}
|
||||
},
|
||||
{
|
||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
||||
data: new Buffer('5468697320697320612074657374207573696e672061206c6172676572207468616e20626c6f636b2d73697a65206b657920616e642061206c6172676572207468616e20626c6f636b2d73697a6520646174612e20546865206b6579206e6565647320746f20626520686173686564206265666f7265206265696e6720757365642062792074686520484d414320616c676f726974686d2e', 'hex'), // 'This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm.'
|
||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
|
||||
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
|
||||
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
|
||||
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
|
||||
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
|
||||
'aaaaaaaaaaaa', 'hex'),
|
||||
// 'This is a test using a larger than block-size key and a larger ' +
|
||||
// 'than block-size data. The key needs to be hashed before being ' +
|
||||
// 'used by the HMAC algorithm.'
|
||||
data: new Buffer('5468697320697320612074657374207573696e672061206c6' +
|
||||
'172676572207468616e20626c6f636b2d73697a65206b6579' +
|
||||
'20616e642061206c6172676572207468616e20626c6f636b2' +
|
||||
'd73697a6520646174612e20546865206b6579206e65656473' +
|
||||
'20746f20626520686173686564206265666f7265206265696' +
|
||||
'e6720757365642062792074686520484d414320616c676f72' +
|
||||
'6974686d2e', 'hex'),
|
||||
hmac: {
|
||||
sha224: '3a854166ac5d9f023f54d517d0b39dbd946770db9c2b95c9f6f565d1',
|
||||
sha256: '9b09ffa71b942fcb27635fbcd5b0e944bfdc63644f0713938a7f51535c3a35e2',
|
||||
sha384: '6617178e941f020d351e2f254e8fd32c602420feb0b8fb9adccebb82461e99c5a678cc31e799176d3860e6110c46523e',
|
||||
sha512: 'e37b6a775dc87dbaa4dfa9f96e5e3ffddebd71f8867289865df5a32d20cdc944b6022cac3c4982b10d5eeb55c3e4de15134676fb6de0446065c97440fa8c6a58'
|
||||
sha256:
|
||||
'9b09ffa71b942fcb27635fbcd5b0e944bfdc63644f0713938a7f5153' +
|
||||
'5c3a35e2',
|
||||
sha384:
|
||||
'6617178e941f020d351e2f254e8fd32c602420feb0b8fb9adccebb82' +
|
||||
'461e99c5a678cc31e799176d3860e6110c46523e',
|
||||
sha512:
|
||||
'e37b6a775dc87dbaa4dfa9f96e5e3ffddebd71f8867289865df5a32d' +
|
||||
'20cdc944b6022cac3c4982b10d5eeb55c3e4de15134676fb6de04460' +
|
||||
'65c97440fa8c6a58'
|
||||
}
|
||||
}
|
||||
];
|
||||
@ -165,12 +237,18 @@ var rfc2202_md5 = [
|
||||
},
|
||||
{
|
||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
||||
data: new Buffer('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd', 'hex'),
|
||||
data: new Buffer('ddddddddddddddddddddddddddddddddddddddddddddddddd' +
|
||||
'ddddddddddddddddddddddddddddddddddddddddddddddddddd',
|
||||
'hex'),
|
||||
hmac: '56be34521d144c88dbb8c733f0e8b3f6'
|
||||
},
|
||||
{
|
||||
key: new Buffer('0102030405060708090a0b0c0d0e0f10111213141516171819', 'hex'),
|
||||
data: new Buffer('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd', 'hex'),
|
||||
key: new Buffer('0102030405060708090a0b0c0d0e0f10111213141516171819',
|
||||
'hex'),
|
||||
data: new Buffer('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdc' +
|
||||
'dcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd' +
|
||||
'cdcdcdcdcd',
|
||||
'hex'),
|
||||
hmac: '697eaf0aca3a3aea3a75164746ffaa79'
|
||||
},
|
||||
{
|
||||
@ -179,13 +257,23 @@ var rfc2202_md5 = [
|
||||
hmac: '56461ef2342edc00f9bab995690efd4c'
|
||||
},
|
||||
{
|
||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
|
||||
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
|
||||
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
|
||||
'aaaaaaaaaaaaaaaaaaaaaa',
|
||||
'hex'),
|
||||
data: 'Test Using Larger Than Block-Size Key - Hash Key First',
|
||||
hmac: '6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd'
|
||||
},
|
||||
{
|
||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
||||
data: 'Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data',
|
||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
|
||||
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
|
||||
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
|
||||
'aaaaaaaaaaaaaaaaaaaaaa',
|
||||
'hex'),
|
||||
data:
|
||||
'Test Using Larger Than Block-Size Key and Larger Than One ' +
|
||||
'Block-Size Data',
|
||||
hmac: '6f630fad67cda0ee1fb1f562db3aa53e'
|
||||
}
|
||||
];
|
||||
@ -202,12 +290,19 @@ var rfc2202_sha1 = [
|
||||
},
|
||||
{
|
||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
||||
data: new Buffer('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd', 'hex'),
|
||||
data: new Buffer('ddddddddddddddddddddddddddddddddddddddddddddd' +
|
||||
'ddddddddddddddddddddddddddddddddddddddddddddd' +
|
||||
'dddddddddd',
|
||||
'hex'),
|
||||
hmac: '125d7342b9ac11cd91a39af48aa17b4f63f175d3'
|
||||
},
|
||||
{
|
||||
key: new Buffer('0102030405060708090a0b0c0d0e0f10111213141516171819', 'hex'),
|
||||
data: new Buffer('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd', 'hex'),
|
||||
key: new Buffer('0102030405060708090a0b0c0d0e0f10111213141516171819',
|
||||
'hex'),
|
||||
data: new Buffer('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdc' +
|
||||
'dcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd' +
|
||||
'cdcdcdcdcd',
|
||||
'hex'),
|
||||
hmac: '4c9007f4026250c6bc8414f9bf50c86c2d7235da'
|
||||
},
|
||||
{
|
||||
@ -216,13 +311,23 @@ var rfc2202_sha1 = [
|
||||
hmac: '4c1a03424b55e07fe7f27be1d58bb9324a9a5a04'
|
||||
},
|
||||
{
|
||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
|
||||
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
|
||||
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
|
||||
'aaaaaaaaaaaaaaaaaaaaaa',
|
||||
'hex'),
|
||||
data: 'Test Using Larger Than Block-Size Key - Hash Key First',
|
||||
hmac: 'aa4ae5e15272d00e95705637ce8a3b55ed402112'
|
||||
},
|
||||
{
|
||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'),
|
||||
data: 'Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data',
|
||||
key: new Buffer('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
|
||||
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
|
||||
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
|
||||
'aaaaaaaaaaaaaaaaaaaaaa',
|
||||
'hex'),
|
||||
data:
|
||||
'Test Using Larger Than Block-Size Key and Larger Than One ' +
|
||||
'Block-Size Data',
|
||||
hmac: 'e8e99d0f45237d786d6bbaa7965c7808bbff1a91'
|
||||
}
|
||||
];
|
||||
@ -402,7 +507,12 @@ assert.ok(rsaVerify);
|
||||
|
||||
rsaSign.update(rsaPubPem);
|
||||
var rsaSignature = rsaSign.sign(rsaKeyPem, 'hex');
|
||||
assert.equal(rsaSignature, '5c50e3145c4e2497aadb0eabc83b342d0b0021ece0d4c4a064b7c8f020d7e2688b122bfb54c724ac9ee169f83f66d2fe90abeb95e8e1290e7e177152a4de3d944cf7d4883114a20ed0f78e70e25ef0f60f06b858e6af42a2f276ede95bbc6bc9a9bbdda15bd663186a6f40819a7af19e577bb2efa5e579a1f5ce8a0d4ca8b8f6');
|
||||
assert.equal(rsaSignature,
|
||||
'5c50e3145c4e2497aadb0eabc83b342d0b0021ece0d4c4a064b7c' +
|
||||
'8f020d7e2688b122bfb54c724ac9ee169f83f66d2fe90abeb95e8' +
|
||||
'e1290e7e177152a4de3d944cf7d4883114a20ed0f78e70e25ef0f' +
|
||||
'60f06b858e6af42a2f276ede95bbc6bc9a9bbdda15bd663186a6f' +
|
||||
'40819a7af19e577bb2efa5e579a1f5ce8a0d4ca8b8f6');
|
||||
|
||||
rsaVerify.update(rsaPubPem);
|
||||
assert.strictEqual(rsaVerify.verify(rsaPubPem, rsaSignature, 'hex'), true);
|
||||
@ -420,7 +530,12 @@ assert.strictEqual(rsaVerify.verify(rsaPubPem, rsaSignature, 'hex'), true);
|
||||
|
||||
var input = 'I AM THE WALRUS';
|
||||
|
||||
var signature = '79d59d34f56d0e94aa6a3e306882b52ed4191f07521f25f505a078dc2f89396e0c8ac89e996fde5717f4cb89199d8fec249961fcb07b74cd3d2a4ffa235417b69618e4bcd76b97e29975b7ce862299410e1b522a328e44ac9bb28195e0268da7eda23d9825ac43c724e86ceeee0d0d4465678652ccaf65010ddfb299bedeb1ad';
|
||||
var signature =
|
||||
'79d59d34f56d0e94aa6a3e306882b52ed4191f07521f25f505a078dc2f89' +
|
||||
'396e0c8ac89e996fde5717f4cb89199d8fec249961fcb07b74cd3d2a4ffa' +
|
||||
'235417b69618e4bcd76b97e29975b7ce862299410e1b522a328e44ac9bb2' +
|
||||
'8195e0268da7eda23d9825ac43c724e86ceeee0d0d4465678652ccaf6501' +
|
||||
'0ddfb299bedeb1ad';
|
||||
|
||||
var sign = crypto.createSign('RSA-SHA256');
|
||||
sign.update(input);
|
||||
@ -464,23 +579,42 @@ assert.strictEqual(rsaVerify.verify(rsaPubPem, rsaSignature, 'hex'), true);
|
||||
// Test PBKDF2 with RFC 6070 test vectors (except #4)
|
||||
//
|
||||
crypto.pbkdf2('password', 'salt', 1, 20, function(err, result) {
|
||||
assert.equal(result, '\x0c\x60\xc8\x0f\x96\x1f\x0e\x71\xf3\xa9\xb5\x24\xaf\x60\x12\x06\x2f\xe0\x37\xa6', 'pbkdf1 test vector 1');
|
||||
assert.equal(result,
|
||||
'\x0c\x60\xc8\x0f\x96\x1f\x0e\x71\xf3\xa9\xb5\x24' +
|
||||
'\xaf\x60\x12\x06\x2f\xe0\x37\xa6',
|
||||
'pbkdf1 test vector 1');
|
||||
});
|
||||
|
||||
crypto.pbkdf2('password', 'salt', 2, 20, function(err, result) {
|
||||
assert.equal(result, '\xea\x6c\x01\x4d\xc7\x2d\x6f\x8c\xcd\x1e\xd9\x2a\xce\x1d\x41\xf0\xd8\xde\x89\x57', 'pbkdf1 test vector 2');
|
||||
assert.equal(result,
|
||||
'\xea\x6c\x01\x4d\xc7\x2d\x6f\x8c\xcd\x1e\xd9\x2a' +
|
||||
'\xce\x1d\x41\xf0\xd8\xde\x89\x57',
|
||||
'pbkdf1 test vector 2');
|
||||
});
|
||||
|
||||
crypto.pbkdf2('password', 'salt', 4096, 20, function(err, result) {
|
||||
assert.equal(result, '\x4b\x00\x79\x01\xb7\x65\x48\x9a\xbe\xad\x49\xd9\x26\xf7\x21\xd0\x65\xa4\x29\xc1', 'pbkdf1 test vector 3');
|
||||
assert.equal(result,
|
||||
'\x4b\x00\x79\x01\xb7\x65\x48\x9a\xbe\xad\x49\xd9\x26' +
|
||||
'\xf7\x21\xd0\x65\xa4\x29\xc1',
|
||||
'pbkdf1 test vector 3');
|
||||
});
|
||||
|
||||
crypto.pbkdf2('passwordPASSWORDpassword', 'saltSALTsaltSALTsaltSALTsaltSALTsalt', 4096, 25, function(err, result) {
|
||||
assert.equal(result, '\x3d\x2e\xec\x4f\xe4\x1c\x84\x9b\x80\xc8\xd8\x36\x62\xc0\xe4\x4a\x8b\x29\x1a\x96\x4c\xf2\xf0\x70\x38', 'pbkdf1 test vector 5');
|
||||
crypto.pbkdf2(
|
||||
'passwordPASSWORDpassword',
|
||||
'saltSALTsaltSALTsaltSALTsaltSALTsalt',
|
||||
4096,
|
||||
25, function(err, result) {
|
||||
assert.equal(result,
|
||||
'\x3d\x2e\xec\x4f\xe4\x1c\x84\x9b\x80\xc8\xd8\x36\x62' +
|
||||
'\xc0\xe4\x4a\x8b\x29\x1a\x96\x4c\xf2\xf0\x70\x38',
|
||||
'pbkdf1 test vector 5');
|
||||
});
|
||||
|
||||
crypto.pbkdf2('pass\0word', 'sa\0lt', 4096, 16, function(err, result) {
|
||||
assert.equal(result, '\x56\xfa\x6a\xa7\x55\x48\x09\x9d\xcc\x37\xd7\xf0\x34\x25\xe0\xc3', 'pbkdf1 test vector 6');
|
||||
assert.equal(result,
|
||||
'\x56\xfa\x6a\xa7\x55\x48\x09\x9d\xcc\x37\xd7\xf0\x34' +
|
||||
'\x25\xe0\xc3',
|
||||
'pbkdf1 test vector 6');
|
||||
});
|
||||
|
||||
// Error path should not leak memory (check with valgrind).
|
||||
|
@ -56,14 +56,15 @@ parts.push('{"seq":12,"type":"event","event":"break","body":' +
|
||||
assert.equal(78, parts[2].length);
|
||||
bodyLength += parts[2].length;
|
||||
|
||||
parts.push('.[anonymous](req=#<an IncomingMessage>, res=#<a ServerResponse>)",' +
|
||||
'"sourceLine"');
|
||||
parts.push('.[anonymous](req=#<an IncomingMessage>, ' +
|
||||
'res=#<a ServerResponse>)","sourceLine"');
|
||||
assert.equal(78, parts[3].length);
|
||||
bodyLength += parts[3].length;
|
||||
|
||||
parts.push(':45,"sourceColumn":4,"sourceLineText":" debugger;","script":' +
|
||||
'{"id":24,"name":"/home/ryan/projects/node/benchmark/http_simple.js",' +
|
||||
'"lineOffset":0,"columnOffset":0,"lineCount":98}}}');
|
||||
parts.push(':45,"sourceColumn":4,"sourceLineText":" debugger;",' +
|
||||
'"script":{"id":24,"name":"/home/ryan/projects/node/' +
|
||||
'benchmark/http_simple.js","lineOffset":0,"columnOffset":0,' +
|
||||
'"lineCount":98}}}');
|
||||
assert.equal(180, parts[4].length);
|
||||
bodyLength += parts[4].length;
|
||||
|
||||
@ -80,10 +81,12 @@ assert.equal(2, resCount);
|
||||
var d = 'Content-Length: 466\r\n\r\n' +
|
||||
'{"seq":10,"type":"event","event":"afterCompile","success":true,' +
|
||||
'"body":{"script":{"handle":1,"type":"script","name":"dns.js",' +
|
||||
'"id":34,"lineOffset":0,"columnOffset":0,"lineCount":241,"sourceStart":' +
|
||||
'"(function (module, exports, require) {var dns = process.binding(\'cares\')' +
|
||||
'"id":34,"lineOffset":0,"columnOffset":0,"lineCount":241,' +
|
||||
'"sourceStart":"(function (module, exports, require) {' +
|
||||
'var dns = process.binding(\'cares\')' +
|
||||
';\\nvar ne","sourceLength":6137,"scriptType":2,"compilationType":0,' +
|
||||
'"context":{"ref":0},"text":"dns.js (lines: 241)"}},"refs":[{"handle":0' +
|
||||
'"context":{"ref":0},"text":"dns.js (lines: 241)"}},"refs":' +
|
||||
'[{"handle":0' +
|
||||
',"type":"context","text":"#<a ContextMirror>"}],"running":true}' +
|
||||
'Content-Length: 119\r\n\r\n' +
|
||||
'{"seq":11,"type":"event","event":"scriptCollected","success":true,' +
|
||||
|
@ -46,7 +46,8 @@ if (process.argv[2] !== 'child') {
|
||||
|
||||
//exit the test if it doesn't succeed within TIMEOUT
|
||||
timer = setTimeout(function() {
|
||||
console.error('[PARENT] Responses were not received within %d ms.', TIMEOUT);
|
||||
console.error('[PARENT] Responses were not received within %d ms.',
|
||||
TIMEOUT);
|
||||
console.error('[PARENT] Fail');
|
||||
|
||||
killChildren(workers);
|
||||
@ -64,14 +65,18 @@ if (process.argv[2] !== 'child') {
|
||||
|
||||
//handle the death of workers
|
||||
worker.on('exit', function(code, signal) {
|
||||
//don't consider this the true death if the worker has finished successfully
|
||||
// don't consider this the true death if the worker
|
||||
// has finished successfully
|
||||
// or if the exit code is 0
|
||||
if (worker.isDone || code == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
dead += 1;
|
||||
console.error('[PARENT] Worker %d died. %d dead of %d', worker.pid, dead, listeners);
|
||||
console.error('[PARENT] Worker %d died. %d dead of %d',
|
||||
worker.pid,
|
||||
dead,
|
||||
listeners);
|
||||
|
||||
if (dead === listeners) {
|
||||
console.error('[PARENT] All workers have died.');
|
||||
@ -98,13 +103,15 @@ if (process.argv[2] !== 'child') {
|
||||
if (worker.messagesReceived.length === messages.length) {
|
||||
done += 1;
|
||||
worker.isDone = true;
|
||||
console.error('[PARENT] %d received %d messages total.', worker.pid,
|
||||
console.error('[PARENT] %d received %d messages total.',
|
||||
worker.pid,
|
||||
worker.messagesReceived.length);
|
||||
}
|
||||
|
||||
if (done === listeners) {
|
||||
console.error('[PARENT] All workers have received the required number of '
|
||||
+ 'messages. Will now compare.');
|
||||
console.error('[PARENT] All workers have received the ' +
|
||||
'required number of ' +
|
||||
'messages. Will now compare.');
|
||||
|
||||
Object.keys(workers).forEach(function(pid) {
|
||||
var worker = workers[pid];
|
||||
@ -120,11 +127,12 @@ if (process.argv[2] !== 'child') {
|
||||
}
|
||||
});
|
||||
|
||||
console.error('[PARENT] %d received %d matching messges.', worker.pid
|
||||
, count);
|
||||
console.error('[PARENT] %d received %d matching messges.',
|
||||
worker.pid,
|
||||
count);
|
||||
|
||||
assert.equal(count, messages.length
|
||||
,'A worker received an invalid multicast message');
|
||||
assert.equal(count, messages.length,
|
||||
'A worker received an invalid multicast message');
|
||||
});
|
||||
|
||||
clearTimeout(timer);
|
||||
@ -158,8 +166,9 @@ if (process.argv[2] !== 'child') {
|
||||
|
||||
if (err) throw err;
|
||||
|
||||
console.error('[PARENT] sent %s to %s:%s', util.inspect(buf.toString())
|
||||
, LOCAL_BROADCAST_HOST, common.PORT);
|
||||
console.error('[PARENT] sent %s to %s:%s',
|
||||
util.inspect(buf.toString()),
|
||||
LOCAL_BROADCAST_HOST, common.PORT);
|
||||
|
||||
process.nextTick(sendSocket.sendNext);
|
||||
});
|
||||
@ -178,8 +187,10 @@ if (process.argv[2] === 'child') {
|
||||
var listenSocket = dgram.createSocket('udp4');
|
||||
|
||||
listenSocket.on('message', function(buf, rinfo) {
|
||||
console.error('[CHILD] %s received %s from %j', process.pid
|
||||
, util.inspect(buf.toString()), rinfo);
|
||||
console.error('[CHILD] %s received %s from %j',
|
||||
process.pid,
|
||||
util.inspect(buf.toString()),
|
||||
rinfo);
|
||||
|
||||
receivedMessages.push(buf);
|
||||
|
||||
|
@ -46,7 +46,8 @@ if (process.argv[2] !== 'child') {
|
||||
|
||||
//exit the test if it doesn't succeed within TIMEOUT
|
||||
timer = setTimeout(function() {
|
||||
console.error('[PARENT] Responses were not received within %d ms.', TIMEOUT);
|
||||
console.error('[PARENT] Responses were not received within %d ms.',
|
||||
TIMEOUT);
|
||||
console.error('[PARENT] Fail');
|
||||
|
||||
killChildren(workers);
|
||||
@ -64,7 +65,8 @@ if (process.argv[2] !== 'child') {
|
||||
|
||||
//handle the death of workers
|
||||
worker.on('exit', function(code, signal) {
|
||||
//don't consider this the true death if the worker has finished successfully
|
||||
// don't consider this the true death if the
|
||||
// worker has finished successfully
|
||||
|
||||
// or if the exit code is 0
|
||||
if (worker.isDone || code === 0) {
|
||||
@ -72,7 +74,10 @@ if (process.argv[2] !== 'child') {
|
||||
}
|
||||
|
||||
dead += 1;
|
||||
console.error('[PARENT] Worker %d died. %d dead of %d', worker.pid, dead, listeners);
|
||||
console.error('[PARENT] Worker %d died. %d dead of %d',
|
||||
worker.pid,
|
||||
dead,
|
||||
listeners);
|
||||
|
||||
if (dead === listeners) {
|
||||
console.error('[PARENT] All workers have died.');
|
||||
@ -99,13 +104,14 @@ if (process.argv[2] !== 'child') {
|
||||
if (worker.messagesReceived.length === messages.length) {
|
||||
done += 1;
|
||||
worker.isDone = true;
|
||||
console.error('[PARENT] %d received %d messages total.', worker.pid,
|
||||
console.error('[PARENT] %d received %d messages total.',
|
||||
worker.pid,
|
||||
worker.messagesReceived.length);
|
||||
}
|
||||
|
||||
if (done === listeners) {
|
||||
console.error('[PARENT] All workers have received the required number of '
|
||||
+ 'messages. Will now compare.');
|
||||
console.error('[PARENT] All workers have received the ' +
|
||||
'required number of messages. Will now compare.');
|
||||
|
||||
Object.keys(workers).forEach(function(pid) {
|
||||
var worker = workers[pid];
|
||||
@ -121,11 +127,11 @@ if (process.argv[2] !== 'child') {
|
||||
}
|
||||
});
|
||||
|
||||
console.error('[PARENT] %d received %d matching messages.', worker.pid
|
||||
, count);
|
||||
console.error('[PARENT] %d received %d matching messages.',
|
||||
worker.pid, count);
|
||||
|
||||
assert.equal(count, messages.length
|
||||
,'A worker received an invalid multicast message');
|
||||
assert.equal(count, messages.length,
|
||||
'A worker received an invalid multicast message');
|
||||
});
|
||||
|
||||
clearTimeout(timer);
|
||||
@ -138,9 +144,10 @@ if (process.argv[2] !== 'child') {
|
||||
}
|
||||
|
||||
var sendSocket = dgram.createSocket('udp4');
|
||||
sendSocket.bind(); // FIXME a libuv limitation makes it necessary to bind()
|
||||
// FIXME a libuv limitation makes it necessary to bind()
|
||||
// before calling any of the set*() functions - the bind()
|
||||
// call is what creates the actual socket...
|
||||
sendSocket.bind();
|
||||
|
||||
sendSocket.setTTL(1);
|
||||
sendSocket.setBroadcast(true);
|
||||
@ -162,7 +169,8 @@ if (process.argv[2] !== 'child') {
|
||||
sendSocket.send(buf, 0, buf.length,
|
||||
common.PORT, LOCAL_BROADCAST_HOST, function(err) {
|
||||
if (err) throw err;
|
||||
console.error('[PARENT] sent %s to %s:%s', util.inspect(buf.toString()),
|
||||
console.error('[PARENT] sent %s to %s:%s',
|
||||
util.inspect(buf.toString()),
|
||||
LOCAL_BROADCAST_HOST, common.PORT);
|
||||
process.nextTick(sendSocket.sendNext);
|
||||
});
|
||||
@ -181,8 +189,8 @@ if (process.argv[2] === 'child') {
|
||||
var listenSocket = dgram.createSocket('udp4');
|
||||
|
||||
listenSocket.on('message', function(buf, rinfo) {
|
||||
console.error('[CHILD] %s received %s from %j', process.pid
|
||||
,util.inspect(buf.toString()), rinfo);
|
||||
console.error('[CHILD] %s received %s from %j', process.pid,
|
||||
util.inspect(buf.toString()), rinfo);
|
||||
|
||||
receivedMessages.push(buf);
|
||||
|
||||
|
@ -26,7 +26,7 @@ var assert = require('assert'),
|
||||
|
||||
function repeat(fn) {
|
||||
if (started != 0) {
|
||||
assert.ok(started - done < 100)
|
||||
assert.ok(started - done < 100);
|
||||
}
|
||||
|
||||
process.nextTick(function() {
|
||||
|
@ -54,7 +54,8 @@ fs.appendFileSync(filename2, data);
|
||||
|
||||
var fileData2 = fs.readFileSync(filename2);
|
||||
|
||||
assert.equal(Buffer.byteLength(data) + currentFileData.length, fileData2.length);
|
||||
assert.equal(Buffer.byteLength(data) + currentFileData.length,
|
||||
fileData2.length);
|
||||
|
||||
// test that appendFileSync accepts buffers
|
||||
var filename3 = join(common.fixturesDir, 'append-sync3.txt');
|
||||
@ -78,7 +79,8 @@ fs.appendFileSync(filename4, num);
|
||||
|
||||
var fileData4 = fs.readFileSync(filename4);
|
||||
|
||||
assert.equal(Buffer.byteLength('' + num) + currentFileData.length, fileData4.length);
|
||||
assert.equal(Buffer.byteLength('' + num) + currentFileData.length,
|
||||
fileData4.length);
|
||||
|
||||
//exit logic for cleanup
|
||||
|
||||
|
@ -111,7 +111,8 @@ fs.appendFile(filename4, n, function(e) {
|
||||
if (e) throw e;
|
||||
common.error('file4 read');
|
||||
ncallbacks++;
|
||||
assert.equal(Buffer.byteLength('' + n) + currentFileData.length, buffer.length);
|
||||
assert.equal(Buffer.byteLength('' + n) + currentFileData.length,
|
||||
buffer.length);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -1,31 +1,50 @@
|
||||
var common = require("../common");
|
||||
var assert = require('assert');
|
||||
var http = require("http");
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
// persons to whom the Software is furnished to do so, subject to the
|
||||
// following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
var testResBody = "other stuff!\n";
|
||||
var common = require('../common');
|
||||
var assert = require('assert');
|
||||
var http = require('http');
|
||||
|
||||
var testResBody = 'other stuff!\n';
|
||||
|
||||
var server = http.createServer(function(req, res) {
|
||||
assert.ok(! ("date" in req.headers),
|
||||
"Request headers contained a Date."
|
||||
);
|
||||
assert.ok(! ('date' in req.headers),
|
||||
'Request headers contained a Date.');
|
||||
res.writeHead(200, {
|
||||
'Content-Type' : 'text/plain',
|
||||
'Content-Type': 'text/plain'
|
||||
});
|
||||
res.end(testResBody);
|
||||
});
|
||||
server.listen(common.PORT);
|
||||
|
||||
|
||||
server.addListener("listening", function() {
|
||||
server.addListener('listening', function() {
|
||||
var options = {
|
||||
port: common.PORT,
|
||||
path: "/",
|
||||
method: "GET"
|
||||
}
|
||||
path: '/',
|
||||
method: 'GET'
|
||||
};
|
||||
var req = http.request(options, function(res) {
|
||||
assert.ok("date" in res.headers,
|
||||
"Response headers didn't contain a Date."
|
||||
);
|
||||
assert.ok('date' in res.headers,
|
||||
'Response headers didn\'t contain a Date.');
|
||||
res.addListener('end', function() {
|
||||
server.close();
|
||||
process.exit();
|
||||
|
@ -35,7 +35,7 @@ for (var i = 0; i < N; ++i) {
|
||||
var maxAndExpected = [ // for server
|
||||
[50, 50],
|
||||
[1500, 1500],
|
||||
[0, N + 2], // Host and Connection
|
||||
[0, N + 2] // Host and Connection
|
||||
];
|
||||
var max = maxAndExpected[requests][0];
|
||||
var expected = maxAndExpected[requests][1];
|
||||
@ -56,7 +56,7 @@ server.listen(common.PORT, function() {
|
||||
var maxAndExpected = [ // for client
|
||||
[20, 20],
|
||||
[1200, 1200],
|
||||
[0, N + 3], // Connection, Date and Transfer-Encoding
|
||||
[0, N + 3] // Connection, Date and Transfer-Encoding
|
||||
];
|
||||
doRequest();
|
||||
|
||||
|
@ -29,7 +29,7 @@ function demoBug(part1, part2) {
|
||||
|
||||
parser.onHeadersComplete = function(info) {
|
||||
headersComplete++;
|
||||
console.log("url", info.url);
|
||||
console.log('url', info.url);
|
||||
};
|
||||
|
||||
parser.onBody = function(b, start, len) { };
|
||||
@ -45,7 +45,7 @@ function demoBug(part1, part2) {
|
||||
var b = Buffer(part1);
|
||||
flushPool();
|
||||
|
||||
console.log("parse the first part of the message");
|
||||
console.log('parse the first part of the message');
|
||||
parser.execute(b, 0, b.length);
|
||||
})();
|
||||
|
||||
@ -54,7 +54,7 @@ function demoBug(part1, part2) {
|
||||
(function() {
|
||||
var b = Buffer(part2);
|
||||
|
||||
console.log("parse the second part of the message");
|
||||
console.log('parse the second part of the message');
|
||||
parser.execute(b, 0, b.length);
|
||||
parser.finish();
|
||||
})();
|
||||
@ -76,5 +76,5 @@ demoBug('POST /1/22 HTTP/1.1\r\n' +
|
||||
process.on('exit', function() {
|
||||
assert.equal(2, headersComplete);
|
||||
assert.equal(2, messagesComplete);
|
||||
console.log("done!");
|
||||
console.log('done!');
|
||||
});
|
||||
|
@ -24,7 +24,7 @@ var assert = require('assert');
|
||||
|
||||
var HTTPParser = process.binding('http_parser').HTTPParser;
|
||||
|
||||
var CRLF = "\r\n";
|
||||
var CRLF = '\r\n';
|
||||
var REQUEST = HTTPParser.REQUEST;
|
||||
var RESPONSE = HTTPParser.RESPONSE;
|
||||
|
||||
@ -88,8 +88,7 @@ function expectBody(expected) {
|
||||
(function() {
|
||||
var request = Buffer(
|
||||
'GET /hello HTTP/1.1' + CRLF +
|
||||
CRLF
|
||||
);
|
||||
CRLF);
|
||||
|
||||
var parser = newParser(REQUEST);
|
||||
|
||||
@ -128,8 +127,7 @@ function expectBody(expected) {
|
||||
'Content-Type: text/plain' + CRLF +
|
||||
'Content-Length: 4' + CRLF +
|
||||
CRLF +
|
||||
'pong'
|
||||
);
|
||||
'pong');
|
||||
|
||||
var parser = newParser(RESPONSE);
|
||||
|
||||
@ -155,8 +153,7 @@ function expectBody(expected) {
|
||||
(function() {
|
||||
var request = Buffer(
|
||||
'HTTP/1.0 200 Connection established' + CRLF +
|
||||
CRLF
|
||||
);
|
||||
CRLF);
|
||||
|
||||
var parser = newParser(RESPONSE);
|
||||
|
||||
@ -185,8 +182,7 @@ function expectBody(expected) {
|
||||
'0' + CRLF +
|
||||
'Vary: *' + CRLF +
|
||||
'Content-Type: text/plain' + CRLF +
|
||||
CRLF
|
||||
);
|
||||
CRLF);
|
||||
|
||||
var seen_body = false;
|
||||
|
||||
@ -226,8 +222,7 @@ function expectBody(expected) {
|
||||
'X-Filler: 1337' + CRLF +
|
||||
'X-Filler: 42' + CRLF +
|
||||
'X-Filler2: 42' + CRLF +
|
||||
CRLF
|
||||
);
|
||||
CRLF);
|
||||
|
||||
var parser = newParser(REQUEST);
|
||||
|
||||
@ -256,8 +251,7 @@ function expectBody(expected) {
|
||||
var request = Buffer(
|
||||
'GET /foo/bar/baz?quux=42#1337 HTTP/1.0' + CRLF +
|
||||
lots_of_headers +
|
||||
CRLF
|
||||
);
|
||||
CRLF);
|
||||
|
||||
var parser = newParser(REQUEST);
|
||||
|
||||
@ -289,8 +283,7 @@ function expectBody(expected) {
|
||||
'Content-Type: application/x-www-form-urlencoded' + CRLF +
|
||||
'Content-Length: 15' + CRLF +
|
||||
CRLF +
|
||||
'foo=42&bar=1337'
|
||||
);
|
||||
'foo=42&bar=1337');
|
||||
|
||||
var parser = newParser(REQUEST);
|
||||
|
||||
@ -325,8 +318,7 @@ function expectBody(expected) {
|
||||
'123456' + CRLF +
|
||||
'A' + CRLF +
|
||||
'1234567890' + CRLF +
|
||||
'0' + CRLF
|
||||
);
|
||||
'0' + CRLF);
|
||||
|
||||
var parser = newParser(REQUEST);
|
||||
|
||||
@ -337,7 +329,8 @@ function expectBody(expected) {
|
||||
assert.equal(info.versionMinor, 1);
|
||||
});
|
||||
|
||||
var body_part = 0, body_parts = ['123', '123456', '1234567890'];
|
||||
var body_part = 0,
|
||||
body_parts = ['123', '123456', '1234567890'];
|
||||
|
||||
function onBody(buf, start, len) {
|
||||
var body = '' + buf.slice(start, start + len);
|
||||
@ -361,8 +354,7 @@ function expectBody(expected) {
|
||||
'3' + CRLF +
|
||||
'123' + CRLF +
|
||||
'6' + CRLF +
|
||||
'123456' + CRLF
|
||||
);
|
||||
'123456' + CRLF);
|
||||
|
||||
var parser = newParser(REQUEST);
|
||||
|
||||
@ -373,7 +365,8 @@ function expectBody(expected) {
|
||||
assert.equal(info.versionMinor, 1);
|
||||
});
|
||||
|
||||
var body_part = 0, body_parts = [
|
||||
var body_part = 0,
|
||||
body_parts = [
|
||||
'123', '123456', '123456789',
|
||||
'123456789ABC', '123456789ABCDEF'];
|
||||
|
||||
@ -392,8 +385,7 @@ function expectBody(expected) {
|
||||
'123456789ABC' + CRLF +
|
||||
'F' + CRLF +
|
||||
'123456789ABCDEF' + CRLF +
|
||||
'0' + CRLF
|
||||
);
|
||||
'0' + CRLF);
|
||||
|
||||
parser.execute(request, 0, request.length);
|
||||
})();
|
||||
@ -418,8 +410,7 @@ function expectBody(expected) {
|
||||
'123456789ABC' + CRLF +
|
||||
'F' + CRLF +
|
||||
'123456789ABCDEF' + CRLF +
|
||||
'0' + CRLF
|
||||
);
|
||||
'0' + CRLF);
|
||||
|
||||
function test(a, b) {
|
||||
var parser = newParser(REQUEST);
|
||||
@ -447,9 +438,11 @@ function expectBody(expected) {
|
||||
|
||||
for (var i = 1; i < request.length - 1; ++i) {
|
||||
var a = request.slice(0, i);
|
||||
console.error("request.slice(0, " + i + ") = ", JSON.stringify(a.toString()));
|
||||
console.error('request.slice(0, ' + i + ') = ',
|
||||
JSON.stringify(a.toString()));
|
||||
var b = request.slice(i);
|
||||
console.error("request.slice(" + i + ") = ", JSON.stringify(b.toString()));
|
||||
console.error('request.slice(' + i + ') = ',
|
||||
JSON.stringify(b.toString()));
|
||||
test(a, b);
|
||||
}
|
||||
})();
|
||||
@ -474,8 +467,7 @@ function expectBody(expected) {
|
||||
'123456789ABC' + CRLF +
|
||||
'F' + CRLF +
|
||||
'123456789ABCDEF' + CRLF +
|
||||
'0' + CRLF
|
||||
);
|
||||
'0' + CRLF);
|
||||
|
||||
var parser = newParser(REQUEST);
|
||||
|
||||
@ -516,16 +508,14 @@ function expectBody(expected) {
|
||||
CRLF +
|
||||
'4' + CRLF +
|
||||
'ping' + CRLF +
|
||||
'0' + CRLF
|
||||
);
|
||||
'0' + CRLF);
|
||||
|
||||
var req2 = Buffer(
|
||||
'POST /that HTTP/1.0' + CRLF +
|
||||
'Content-Type: text/plain' + CRLF +
|
||||
'Content-Length: 4' + CRLF +
|
||||
CRLF +
|
||||
'pong'
|
||||
);
|
||||
'pong');
|
||||
|
||||
function onHeadersComplete1(info) {
|
||||
assert.equal(info.method, 'PUT');
|
||||
|
@ -30,7 +30,7 @@ var SERVER_RESPONSES = [
|
||||
'HTTP/1.0 200 ok\r\nContent-Length: 0\r\nConnection: close\r\n\r\n',
|
||||
'HTTP/1.1 200 ok\r\nContent-Length: 0\r\n\r\n',
|
||||
'HTTP/1.1 200 ok\r\nContent-Length: 0\r\nConnection: keep-alive\r\n\r\n',
|
||||
'HTTP/1.1 200 ok\r\nContent-Length: 0\r\nConnection: close\r\n\r\n',
|
||||
'HTTP/1.1 200 ok\r\nContent-Length: 0\r\nConnection: close\r\n\r\n'
|
||||
];
|
||||
var SHOULD_KEEP_ALIVE = [
|
||||
false, // HTTP/1.0, default
|
||||
@ -38,7 +38,7 @@ var SHOULD_KEEP_ALIVE = [
|
||||
false, // HTTP/1.0, Connection: close
|
||||
true, // HTTP/1.1, default
|
||||
true, // HTTP/1.1, Connection: keep-alive
|
||||
false, // HTTP/1.1, Connection: close
|
||||
false // HTTP/1.1, Connection: close
|
||||
];
|
||||
var requests = 0;
|
||||
var responses = 0;
|
||||
|
@ -71,7 +71,7 @@ tcp.listen(common.PORT, function() {
|
||||
1,
|
||||
1.0,
|
||||
1 / 0,
|
||||
+Infinity
|
||||
+Infinity,
|
||||
-Infinity,
|
||||
[],
|
||||
{}
|
||||
|
@ -31,12 +31,9 @@ process.on('exit', function() {
|
||||
|
||||
var server = net.createServer(function(socket) {
|
||||
setTimeout(function() {
|
||||
assert.throws(
|
||||
function() {
|
||||
assert.throws(function() {
|
||||
socket.write('test');
|
||||
},
|
||||
/This socket is closed/
|
||||
);
|
||||
}, /This socket is closed/);
|
||||
server.close();
|
||||
gotError = true;
|
||||
}, 250);
|
||||
|
@ -186,8 +186,7 @@ assert.deepEqual({}, qs.parse());
|
||||
// Test limiting
|
||||
assert.equal(
|
||||
Object.keys(qs.parse('a=1&b=1&c=1', null, null, { maxKeys: 1 })).length,
|
||||
1
|
||||
);
|
||||
1);
|
||||
|
||||
// Test removing limit
|
||||
function testUnlimitedKeys() {
|
||||
@ -200,8 +199,7 @@ function testUnlimitedKeys() {
|
||||
|
||||
assert.equal(
|
||||
Object.keys(qs.parse(url, null, null, { maxKeys: 0 })).length,
|
||||
2000
|
||||
);
|
||||
2000);
|
||||
}
|
||||
testUnlimitedKeys();
|
||||
|
||||
|
@ -65,7 +65,7 @@ function isTypeError(o) {
|
||||
return o instanceof TypeError;
|
||||
}
|
||||
|
||||
[undefined, null, 0, 0.0, '', {}, []].forEach(function(e) {
|
||||
([undefined, null, 0, 0.0, '', {}, []].forEach(function(e) {
|
||||
assert.throws(function() { script.runInContext(e); }, isTypeError);
|
||||
assert.throws(function() { vm.runInContext('', e); }, isTypeError);
|
||||
});
|
||||
}));
|
||||
|
@ -59,7 +59,8 @@ server.listen(common.PORT, function() {
|
||||
client1.on('close', function() {
|
||||
console.log('close1');
|
||||
|
||||
var client2 = tls.connect({'session': session1, port: common.PORT}, function() {
|
||||
var opts = { 'session': session1, port: common.PORT };
|
||||
var client2 = tls.connect(opts, function() {
|
||||
console.log('connect2');
|
||||
assert.ok(client2.isSessionReused(), 'Session *should* be reused.');
|
||||
});
|
||||
|
@ -49,7 +49,7 @@ var options = {
|
||||
var server = https.createServer(options, function(req, res) {
|
||||
console.log('SERVER: got request');
|
||||
res.writeHead(200, {
|
||||
'content-type': 'text/plain',
|
||||
'content-type': 'text/plain'
|
||||
});
|
||||
console.log('SERVER: sending response');
|
||||
res.end('hello world\n');
|
||||
@ -133,7 +133,7 @@ proxy.listen(proxyPort, function() {
|
||||
key: key,
|
||||
cert: cert,
|
||||
socket: res.socket, // reuse the socket
|
||||
agent: false,
|
||||
agent: false
|
||||
}, function(res) {
|
||||
assert.equal(200, res.statusCode);
|
||||
|
||||
|
@ -36,10 +36,10 @@ assert.equal(orig, after);
|
||||
|
||||
// test for sparse array
|
||||
var a = ['foo', 'bar', 'baz'];
|
||||
assert.equal(util.inspect(a), "[ 'foo', 'bar', 'baz' ]");
|
||||
assert.equal(util.inspect(a), '[ \'foo\', \'bar\', \'baz\' ]');
|
||||
delete a[1];
|
||||
assert.equal(util.inspect(a), "[ 'foo', , 'baz' ]");
|
||||
assert.equal(util.inspect(a, true), "[ 'foo', , 'baz', [length]: 3 ]");
|
||||
assert.equal(util.inspect(a), '[ \'foo\', , \'baz\' ]');
|
||||
assert.equal(util.inspect(a, true), '[ \'foo\', , \'baz\', [length]: 3 ]');
|
||||
assert.equal(util.inspect(new Array(5)), '[ , , , , ]');
|
||||
|
||||
// test for property descriptors
|
||||
@ -51,7 +51,7 @@ var getter = Object.create(null, {
|
||||
var setter = Object.create(null, {
|
||||
b: {
|
||||
set: function() {}
|
||||
},
|
||||
}
|
||||
});
|
||||
var getterAndSetter = Object.create(null, {
|
||||
c: {
|
||||
@ -59,11 +59,11 @@ var getterAndSetter = Object.create(null, {
|
||||
set: function() {}
|
||||
}
|
||||
});
|
||||
assert.equal(util.inspect(getter, true), "{ [a]: [Getter] }");
|
||||
assert.equal(util.inspect(setter, true), "{ [b]: [Setter] }");
|
||||
assert.equal(util.inspect(getterAndSetter, true), "{ [c]: [Getter/Setter] }");
|
||||
assert.equal(util.inspect(getter, true), '{ [a]: [Getter] }');
|
||||
assert.equal(util.inspect(setter, true), '{ [b]: [Setter] }');
|
||||
assert.equal(util.inspect(getterAndSetter, true), '{ [c]: [Getter/Setter] }');
|
||||
|
||||
// exceptions should print the error message, not "{}"
|
||||
// exceptions should print the error message, not '{}'
|
||||
assert.equal(util.inspect(new Error()), '[Error]');
|
||||
assert.equal(util.inspect(new Error('FAIL')), '[Error: FAIL]');
|
||||
assert.equal(util.inspect(new TypeError('FAIL')), '[TypeError: FAIL]');
|
||||
|
Loading…
x
Reference in New Issue
Block a user