feat: 초기 프로젝트 설정 및 룰.md 파일 추가
This commit is contained in:
72
api.hyungi.net/node_modules/nssocket/test/create-server-test.js
generated
vendored
Normal file
72
api.hyungi.net/node_modules/nssocket/test/create-server-test.js
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* create-server-test.js : namespace socket unit test for TLS.
|
||||
*
|
||||
* (C) 2011, Charlie Robbins, Paolo Fragomeni, & the Contributors.
|
||||
*
|
||||
*/
|
||||
|
||||
var assert = require('assert'),
|
||||
fs = require('fs'),
|
||||
net = require('net'),
|
||||
path = require('path'),
|
||||
tls = require('tls'),
|
||||
vows = require('vows'),
|
||||
nssocket = require('../lib/nssocket');
|
||||
|
||||
|
||||
function getBatch() {
|
||||
var args = Array.prototype.slice.call(arguments),
|
||||
res = {};
|
||||
|
||||
return {
|
||||
"the createServer() method": {
|
||||
topic: function () {
|
||||
var outbound = new nssocket.NsSocket(),
|
||||
server = nssocket.createServer(this.callback.bind(null, null, outbound));
|
||||
|
||||
server.listen.apply(server, args.concat(function () {
|
||||
outbound.connect.apply(outbound, args);
|
||||
}));
|
||||
},
|
||||
"should create a full-duplex namespaced socket": {
|
||||
topic: function (outbound, inbound) {
|
||||
outbound.on(['data', 'here', 'is'], this.callback.bind(outbound, null));
|
||||
inbound.send(['here', 'is'], 'something.');
|
||||
},
|
||||
"should handle namespaced events": function (_, data) {
|
||||
assert.isArray(this.event);
|
||||
assert.lengthOf(this.event, 3);
|
||||
assert.isString(this.event[0]);
|
||||
assert.isString(this.event[1]);
|
||||
assert.isString(this.event[2]);
|
||||
assert.isString(data);
|
||||
assert.equal(this.event[0], 'data');
|
||||
assert.equal(this.event[1], 'here');
|
||||
assert.equal(this.event[2], 'is');
|
||||
assert.equal(data, 'something.');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var PORT = 9564,
|
||||
HOST = "127.0.0.1",
|
||||
PIPE = path.join(__dirname, "fixtures", "nssocket.sock"),
|
||||
HOSTNAME = "localhost";
|
||||
|
||||
vows.describe('nssocket/create-server').addBatch({
|
||||
"When using NsSocket": {
|
||||
"with `(PORT)` argument": getBatch(PORT),
|
||||
"with `(PORT, HOST)` arguments": getBatch(PORT + 1, HOST),
|
||||
"with `(PORT, HOSTNAME)` argument": getBatch(PORT + 2, HOSTNAME),
|
||||
"with `(PIPE)` argument": getBatch(PIPE)
|
||||
}
|
||||
}).addBatch({
|
||||
"When tests are finished": {
|
||||
"`PIPE` should be removed": function () {
|
||||
fs.unlinkSync(PIPE);
|
||||
}
|
||||
}
|
||||
}).export(module);
|
||||
|
||||
16
api.hyungi.net/node_modules/nssocket/test/fixtures/ryans-cert.pem
generated
vendored
Normal file
16
api.hyungi.net/node_modules/nssocket/test/fixtures/ryans-cert.pem
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICfzCCAegCCQCE5Xuxkur1mjANBgkqhkiG9w0BAQUFADCBgzELMAkGA1UEBhMC
|
||||
VVMxCzAJBgNVBAgMAk5ZMQswCQYDVQQHDAJOWTEVMBMGA1UECgwMSW50ZXJuZXQu
|
||||
Y29tMRgwFgYDVQQLDA9JbnRlcm5ldCBOaW5qYXMxDjAMBgNVBAMMBU51am9vMRkw
|
||||
FwYJKoZIhvcNAQkBFgpudUBqb28uY29tMB4XDTExMTAxMzIxNDgxOVoXDTExMTEx
|
||||
MjIxNDgxOVowgYMxCzAJBgNVBAYTAlVTMQswCQYDVQQIDAJOWTELMAkGA1UEBwwC
|
||||
TlkxFTATBgNVBAoMDEludGVybmV0LmNvbTEYMBYGA1UECwwPSW50ZXJuZXQgTmlu
|
||||
amFzMQ4wDAYDVQQDDAVOdWpvbzEZMBcGCSqGSIb3DQEJARYKbnVAam9vLmNvbTCB
|
||||
nzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA2hKAVOtI/mNUpOkuHgBDaIu0EelR
|
||||
SdEc5GoqfIeH+59VkJqkIf+lAgRJk7PSJuwGY5Kzq6DwD/RStzk+S/Z+5h/61YQX
|
||||
D28SOf9d53+hSn6NpetOa0f9gL+ouc0MkSL9fOW8geD07Yv0N8XpdgiSQG6jp6Wd
|
||||
yo2R7xJaoBjRfP8CAwEAATANBgkqhkiG9w0BAQUFAAOBgQC7DFd1pWGVwzGGYAq0
|
||||
KkJYCJQoq6NgthHQ206U/3cFlelSG2NqbnjfAxPX1N7waT2FIa2yE/Ax6AMZDw8A
|
||||
v3hxwo+c0j5YzCBfFXXbP/8jZtWEUuj5bDa0rplqP1JwDa0JTqxuIdpgVANa8FLE
|
||||
NkLSqWOjovXCdekT/LaN84s5aw==
|
||||
-----END CERTIFICATE-----
|
||||
12
api.hyungi.net/node_modules/nssocket/test/fixtures/ryans-csr.pem
generated
vendored
Normal file
12
api.hyungi.net/node_modules/nssocket/test/fixtures/ryans-csr.pem
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
-----BEGIN CERTIFICATE REQUEST-----
|
||||
MIIBxDCCAS0CAQAwgYMxCzAJBgNVBAYTAlVTMQswCQYDVQQIDAJOWTELMAkGA1UE
|
||||
BwwCTlkxFTATBgNVBAoMDEludGVybmV0LmNvbTEYMBYGA1UECwwPSW50ZXJuZXQg
|
||||
TmluamFzMQ4wDAYDVQQDDAVOdWpvbzEZMBcGCSqGSIb3DQEJARYKbnVAam9vLmNv
|
||||
bTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA2hKAVOtI/mNUpOkuHgBDaIu0
|
||||
EelRSdEc5GoqfIeH+59VkJqkIf+lAgRJk7PSJuwGY5Kzq6DwD/RStzk+S/Z+5h/6
|
||||
1YQXD28SOf9d53+hSn6NpetOa0f9gL+ouc0MkSL9fOW8geD07Yv0N8XpdgiSQG6j
|
||||
p6Wdyo2R7xJaoBjRfP8CAwEAAaAAMA0GCSqGSIb3DQEBBQUAA4GBADdnMH2brmA/
|
||||
pYWleVBOd1ZhkkXoTns0Lv0KNWpdjKT6mVxSsiiuKc8MBtWTFseM/kDxRm1VCjPL
|
||||
YcNZRtKVLOUn3cwwtYGJm9EMmvn0EzHr6p2IO6Z7JBETOHoJT9zXszbcvUFaRb+9
|
||||
7jTr6wsDY/raS3FdCBGp1nK8EVw8QT0r
|
||||
-----END CERTIFICATE REQUEST-----
|
||||
15
api.hyungi.net/node_modules/nssocket/test/fixtures/ryans-key.pem
generated
vendored
Normal file
15
api.hyungi.net/node_modules/nssocket/test/fixtures/ryans-key.pem
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICXQIBAAKBgQDaEoBU60j+Y1Sk6S4eAENoi7QR6VFJ0Rzkaip8h4f7n1WQmqQh
|
||||
/6UCBEmTs9Im7AZjkrOroPAP9FK3OT5L9n7mH/rVhBcPbxI5/13nf6FKfo2l605r
|
||||
R/2Av6i5zQyRIv185byB4PTti/Q3xel2CJJAbqOnpZ3KjZHvElqgGNF8/wIDAQAB
|
||||
AoGAX9PnfumRvu/pXzp0oIxfEs7pR0GvDfANcTZSCz0HfYQL9qpt297aJOO7bWOE
|
||||
wsPPHux1dcMYGvqzan6GKJ1eL3OzGDWdgVgMGLlp0mZj74QWCJDyBrAKseNJc/vV
|
||||
YXqq2nfb44yLVvFzZnJmD59FpDVgEdUw/KtVoA7Qg3MNnlECQQD/ITXaukRiCHMk
|
||||
/yJBbcyt7hb/M3gdknr1ophCnwIcoKFrJUUzY0LF5NXbA7OMDgK7Fg63blc8KEEi
|
||||
L7gZYdBJAkEA2tDuTElF2awoY791vrfaOhIpMcqTtn/glojhO9XYDt3iAY+o6LW3
|
||||
o2FZxt+7jwoQSUxN68lwc+1MXc1IafRzBwJAZPNzJ9VEcbX+OclqeJFFyBzJpLls
|
||||
8eagGMn5jYL1hvZYaNkahLbmGP/vTvYr+WMh2X1k3Vgf1IHpI+nV4tU9YQJBANl0
|
||||
Mq07UCBO92CRf8kF2uhE7g1eXUdLc/0FkJgvHuU/Wf/lLZ3+IL5L27VI2JMBFEhT
|
||||
fUhqSsfaNj8t593sIXcCQQDtWaKRz2QPAjhtM29xVihOBVPppdXdm1jSk25EciJX
|
||||
x4lrUXyNTeyQif0Hezp4WaYhVOS8uRGYnKH9eJzXQ5Pv
|
||||
-----END RSA PRIVATE KEY-----
|
||||
106
api.hyungi.net/node_modules/nssocket/test/msgpack-tcp-test.js
generated
vendored
Normal file
106
api.hyungi.net/node_modules/nssocket/test/msgpack-tcp-test.js
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* msgpack-tcp-test.js : namespace socket unit test for Messagepack encoder/decoder.
|
||||
*
|
||||
* (C) 2011, Charlie Robbins, Paolo Fragomeni, & the Contributors.
|
||||
*
|
||||
*/
|
||||
|
||||
var assert = require('assert'),
|
||||
fs = require('fs'),
|
||||
msgpack = require('msgpack'),
|
||||
net = require('net'),
|
||||
path = require('path'),
|
||||
vows = require('vows'),
|
||||
NsSocket = require('../lib/nssocket').NsSocket;
|
||||
|
||||
var TCP_PORT = 30109;
|
||||
|
||||
var tcpServer = net.createServer(),
|
||||
tcpOpt;
|
||||
|
||||
tcpOpt = {
|
||||
type : 'tcp4',
|
||||
delimiter: '.}',
|
||||
encode: function (data) {
|
||||
return msgpack.pack(data).toString('binary');
|
||||
},
|
||||
decode: function (data) {
|
||||
return msgpack.unpack(new Buffer(data.toString('binary'), 'binary'));
|
||||
}
|
||||
};
|
||||
|
||||
tcpServer.listen(TCP_PORT);
|
||||
|
||||
vows.describe('nssocket/msgpack').addBatch({
|
||||
"When using NsSocket with msgpack encoder/decoder": {
|
||||
topic: new NsSocket(tcpOpt),
|
||||
"should create a wrapped socket": function (outbound) {
|
||||
assert.instanceOf(outbound, NsSocket);
|
||||
},
|
||||
"should have the proper configuration settings": function (outbound) {
|
||||
assert.equal(outbound._type, tcpOpt.type);
|
||||
assert.equal(outbound._delimiter, tcpOpt.delimiter);
|
||||
},
|
||||
"the connect() method": {
|
||||
topic: function (outbound) {
|
||||
var that = this;
|
||||
tcpServer.on('connection', this.callback.bind(null, null, outbound));
|
||||
outbound.connect(TCP_PORT);
|
||||
},
|
||||
"should actually connect": function (_, outbound, inbound) {
|
||||
assert.instanceOf(outbound, NsSocket);
|
||||
assert.instanceOf(inbound, net.Socket);
|
||||
},
|
||||
"the on() method": {
|
||||
topic: function (outbound, inbound) {
|
||||
outbound.on('data.}here.}is', this.callback.bind(outbound, null));
|
||||
inbound.write(tcpOpt.encode(['here', 'is', 'something.']) + '\n');
|
||||
},
|
||||
"should handle namespaced events": function (_, data) {
|
||||
assert.isArray(this.event);
|
||||
assert.lengthOf(this.event, 3);
|
||||
assert.isString(this.event[0]);
|
||||
assert.isString(this.event[1]);
|
||||
assert.isString(this.event[2]);
|
||||
assert.isString(data);
|
||||
assert.equal(this.event[0], 'data');
|
||||
assert.equal(this.event[1], 'here');
|
||||
assert.equal(this.event[2], 'is');
|
||||
assert.equal(data, 'something.');
|
||||
},
|
||||
"once idle": {
|
||||
topic: function (_, outbound, inbound) {
|
||||
outbound.once('idle', this.callback.bind(null, null, outbound, inbound));
|
||||
outbound.setIdle(100);
|
||||
},
|
||||
"it should emit `idle`": function (_, outbound, inbound) {
|
||||
assert.isNull(_);
|
||||
},
|
||||
"the send() method": {
|
||||
topic: function (outbound, inbound) {
|
||||
inbound.on('data', this.callback.bind(null, null, outbound, inbound));
|
||||
outbound.send(['hello','world'], { some: "json", data: 123 });
|
||||
},
|
||||
"we should see it on the other end": function (_, outbound, wraped, data) {
|
||||
assert.isObject(data);
|
||||
arr = tcpOpt.decode(data.toString());
|
||||
assert.lengthOf(arr, 3);
|
||||
assert.equal(arr[0], 'hello');
|
||||
assert.equal(arr[1], 'world');
|
||||
assert.deepEqual(arr[2], { some: "json", data: 123 });
|
||||
},
|
||||
"the end() method": {
|
||||
topic: function (outbound, inbound) {
|
||||
outbound.on('close', this.callback.bind(null, null, outbound, inbound));
|
||||
inbound.end();
|
||||
},
|
||||
"should close without errors": function (_, _, _, err) {
|
||||
assert.isUndefined(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}).export(module);
|
||||
80
api.hyungi.net/node_modules/nssocket/test/tcp-reconnect-test.js
generated
vendored
Normal file
80
api.hyungi.net/node_modules/nssocket/test/tcp-reconnect-test.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* nssocket-test.js : namespace socket unit test for TCP
|
||||
*
|
||||
* (C) 2011, Charlie Robbins, Paolo Fragomeni, & the Contributors.
|
||||
*
|
||||
*/
|
||||
|
||||
var assert = require('assert'),
|
||||
fs = require('fs'),
|
||||
net = require('net'),
|
||||
path = require('path'),
|
||||
vows = require('vows'),
|
||||
NsSocket = require('../lib/nssocket').NsSocket;
|
||||
|
||||
var TCP_PORT = 30105;
|
||||
|
||||
var tcpServer = net.createServer(),
|
||||
tcpOpt;
|
||||
|
||||
tcpOpt = {
|
||||
type : 'tcp4',
|
||||
delimiter: '.}',
|
||||
reconnect: true,
|
||||
retryInterval: 1000
|
||||
};
|
||||
|
||||
tcpServer.listen(TCP_PORT);
|
||||
|
||||
vows.describe('nssocket/tcp/reconnect').addBatch({
|
||||
"When using NsSocket with TCP": {
|
||||
topic: new NsSocket(tcpOpt),
|
||||
"the connect() method": {
|
||||
topic: function (outbound) {
|
||||
var that = this;
|
||||
tcpServer.on('connection', this.callback.bind(null, null, outbound));
|
||||
outbound.connect(TCP_PORT);
|
||||
},
|
||||
"should actually connect": function (_, outbound, inbound) {
|
||||
assert.instanceOf(outbound, NsSocket);
|
||||
assert.instanceOf(inbound, net.Socket);
|
||||
},
|
||||
"when the server closes": {
|
||||
topic: function (outbound, inbound) {
|
||||
outbound.once('close', this.callback.bind(this, null, outbound));
|
||||
tcpServer.close();
|
||||
inbound.destroy();
|
||||
},
|
||||
"and then restarts": {
|
||||
topic: function (outbound) {
|
||||
tcpServer = net.createServer();
|
||||
tcpServer.listen(TCP_PORT);
|
||||
tcpServer.on('connection', this.callback.bind(null, null, outbound));
|
||||
},
|
||||
"the socket should reconnect correctly": function (_, outbound, inbound) {
|
||||
assert.instanceOf(outbound, NsSocket);
|
||||
assert.instanceOf(inbound, net.Socket);
|
||||
},
|
||||
"the on() method": {
|
||||
topic: function (outbound, inbound) {
|
||||
outbound.on('data.}here.}is', this.callback.bind(outbound, null));
|
||||
inbound.write(JSON.stringify(['here', 'is', 'something.']) + '\n');
|
||||
},
|
||||
"should handle namespaced events": function (_, data) {
|
||||
assert.isArray(this.event);
|
||||
assert.lengthOf(this.event, 3);
|
||||
assert.isString(this.event[0]);
|
||||
assert.isString(this.event[1]);
|
||||
assert.isString(this.event[2]);
|
||||
assert.isString(data);
|
||||
assert.equal(this.event[0], 'data');
|
||||
assert.equal(this.event[1], 'here');
|
||||
assert.equal(this.event[2], 'is');
|
||||
assert.equal(data, 'something.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}).export(module);
|
||||
99
api.hyungi.net/node_modules/nssocket/test/tcp-test.js
generated
vendored
Normal file
99
api.hyungi.net/node_modules/nssocket/test/tcp-test.js
generated
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* nssocket-test.js : namespace socket unit test for TCP
|
||||
*
|
||||
* (C) 2011, Charlie Robbins, Paolo Fragomeni, & the Contributors.
|
||||
*
|
||||
*/
|
||||
|
||||
var assert = require('assert'),
|
||||
fs = require('fs'),
|
||||
net = require('net'),
|
||||
path = require('path'),
|
||||
vows = require('vows'),
|
||||
NsSocket = require('../lib/nssocket').NsSocket;
|
||||
|
||||
var TCP_PORT = 30103;
|
||||
|
||||
var tcpServer = net.createServer(),
|
||||
tcpOpt;
|
||||
|
||||
tcpOpt = {
|
||||
type : 'tcp4',
|
||||
delimiter: '.}'
|
||||
};
|
||||
|
||||
tcpServer.listen(TCP_PORT);
|
||||
|
||||
vows.describe('nssocket/tcp').addBatch({
|
||||
"When using NsSocket with TCP": {
|
||||
topic: new NsSocket(tcpOpt),
|
||||
"should create a wrapped socket": function (outbound) {
|
||||
assert.instanceOf(outbound, NsSocket);
|
||||
},
|
||||
"should have the proper configuration settings": function (outbound) {
|
||||
assert.equal(outbound._type, tcpOpt.type);
|
||||
assert.equal(outbound._delimiter, tcpOpt.delimiter);
|
||||
},
|
||||
"the connect() method": {
|
||||
topic: function (outbound) {
|
||||
var that = this;
|
||||
tcpServer.on('connection', this.callback.bind(null, null, outbound));
|
||||
outbound.connect(TCP_PORT);
|
||||
},
|
||||
"should actually connect": function (_, outbound, inbound) {
|
||||
assert.instanceOf(outbound, NsSocket);
|
||||
assert.instanceOf(inbound, net.Socket);
|
||||
},
|
||||
"the on() method": {
|
||||
topic: function (outbound, inbound) {
|
||||
outbound.on('data.}here.}is', this.callback.bind(outbound, null));
|
||||
inbound.write(JSON.stringify(['here', 'is', 'something.']) + '\n');
|
||||
},
|
||||
"should handle namespaced events": function (_, data) {
|
||||
assert.isArray(this.event);
|
||||
assert.lengthOf(this.event, 3);
|
||||
assert.isString(this.event[0]);
|
||||
assert.isString(this.event[1]);
|
||||
assert.isString(this.event[2]);
|
||||
assert.isString(data);
|
||||
assert.equal(this.event[0], 'data');
|
||||
assert.equal(this.event[1], 'here');
|
||||
assert.equal(this.event[2], 'is');
|
||||
assert.equal(data, 'something.');
|
||||
},
|
||||
"once idle": {
|
||||
topic: function (_, outbound, inbound) {
|
||||
outbound.once('idle', this.callback.bind(null, null, outbound, inbound));
|
||||
outbound.setIdle(100);
|
||||
},
|
||||
"it should emit `idle`": function (_, outbound, inbound) {
|
||||
assert.isNull(_);
|
||||
},
|
||||
"the send() method": {
|
||||
topic: function (outbound, inbound) {
|
||||
inbound.on('data', this.callback.bind(null, null, outbound, inbound));
|
||||
outbound.send(['hello','world'], { some: "json", data: 123 });
|
||||
},
|
||||
"we should see it on the other end": function (_, outbound, wraped, data) {
|
||||
assert.isObject(data);
|
||||
arr = JSON.parse(data.toString());
|
||||
assert.lengthOf(arr, 3);
|
||||
assert.equal(arr[0], 'hello');
|
||||
assert.equal(arr[1], 'world');
|
||||
assert.deepEqual(arr[2], { some: "json", data: 123 });
|
||||
},
|
||||
"the end() method": {
|
||||
topic: function (outbound, inbound) {
|
||||
outbound.on('close', this.callback.bind(null, null, outbound, inbound));
|
||||
inbound.end();
|
||||
},
|
||||
"should close without errors": function (_, _, _, err) {
|
||||
assert.isUndefined(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}).export(module);
|
||||
106
api.hyungi.net/node_modules/nssocket/test/tls-test.js
generated
vendored
Normal file
106
api.hyungi.net/node_modules/nssocket/test/tls-test.js
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* nssocket-test.js : namespace socket unit test for TLS.
|
||||
*
|
||||
* (C) 2011, Charlie Robbins, Paolo Fragomeni, & the Contributors.
|
||||
*
|
||||
*/
|
||||
|
||||
var assert = require('assert'),
|
||||
fs = require('fs'),
|
||||
net = require('net'),
|
||||
path = require('path'),
|
||||
tls = require('tls'),
|
||||
vows = require('vows'),
|
||||
NsSocket = require('../lib/nssocket').NsSocket;
|
||||
|
||||
var TLS_PORT = 50305,
|
||||
fixturesDir = path.join(__dirname, 'fixtures');
|
||||
|
||||
var serverOpts = {
|
||||
key: fs.readFileSync(path.join(fixturesDir, 'ryans-key.pem')),
|
||||
cert: fs.readFileSync(path.join(fixturesDir, 'ryans-cert.pem')),
|
||||
ca: fs.readFileSync(path.join(fixturesDir, 'ryans-csr.pem'))
|
||||
};
|
||||
|
||||
var tlsServer = tls.createServer(serverOpts),
|
||||
tlsOpt;
|
||||
|
||||
tlsOpt = {
|
||||
type: 'tls',
|
||||
delimiter: '::'
|
||||
};
|
||||
|
||||
tlsServer.listen(TLS_PORT);
|
||||
|
||||
vows.describe('nssocket/tls').addBatch({
|
||||
"When using NsSocket with TLS": {
|
||||
topic: new NsSocket(tlsOpt),
|
||||
"should create a wrapped socket": function (outbound) {
|
||||
assert.instanceOf(outbound, NsSocket);
|
||||
},
|
||||
"should have the proper configuration settings": function (outbound) {
|
||||
assert.equal(outbound._type, tlsOpt.type);
|
||||
assert.equal(outbound._delimiter, tlsOpt.delimiter);
|
||||
},
|
||||
"the connect() method": {
|
||||
topic: function (outbound) {
|
||||
var that = this;
|
||||
tlsServer.on('secureConnection', this.callback.bind(null, null, outbound));
|
||||
outbound.connect(TLS_PORT);
|
||||
},
|
||||
"should actually connect": function (_, outbound, inbound) {
|
||||
assert.instanceOf(outbound, NsSocket);
|
||||
if (!inbound.authorized) {
|
||||
console.log('Certificate is not authorized: ' + inbound.authorizationError);
|
||||
}
|
||||
},
|
||||
"the on() method": {
|
||||
topic: function (outbound, inbound) {
|
||||
outbound.on(['data', 'here', 'is'], this.callback.bind(outbound, null));
|
||||
inbound.write(JSON.stringify(['here', 'is', 'something']) + '\n');
|
||||
},
|
||||
"should handle namespaced events": function (_, data) {
|
||||
assert.isString(data);
|
||||
assert.isArray(this.event);
|
||||
assert.lengthOf(this.event, 3);
|
||||
assert.equal(this.event[0], 'data');
|
||||
assert.equal(this.event[1], 'here');
|
||||
assert.equal(this.event[2], 'is');
|
||||
assert.equal(data, 'something');
|
||||
},
|
||||
"once idle": {
|
||||
topic: function (_, outbound, inbound) {
|
||||
outbound.once('idle', this.callback.bind(null, null, outbound, inbound));
|
||||
outbound.setIdle(100);
|
||||
},
|
||||
"it should emit `idle`": function (_, outbound, inbound) {
|
||||
assert.isNull(_);
|
||||
},
|
||||
"the send() method": {
|
||||
topic: function (outbound, inbound) {
|
||||
inbound.on('data', this.callback.bind(null, null, outbound, inbound));
|
||||
outbound.send(['hello','world'], { some: "json", data: 123 });
|
||||
},
|
||||
"we should see it on the other end": function (_, outbound, inbound, data) {
|
||||
assert.isObject(data);
|
||||
arr = JSON.parse(data.toString());
|
||||
assert.lengthOf(arr, 3);
|
||||
assert.equal(arr[0], 'hello');
|
||||
assert.equal(arr[1], 'world');
|
||||
assert.deepEqual(arr[2], { some: "json", data: 123 });
|
||||
},
|
||||
"the end() method": {
|
||||
topic: function (outbound, inbound) {
|
||||
outbound.on('close', this.callback.bind(null, null, outbound, inbound));
|
||||
inbound.end();
|
||||
},
|
||||
"should close without errors": function (_, _, _, err) {
|
||||
assert.isUndefined(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}).export(module);
|
||||
Reference in New Issue
Block a user