From b51b57b987deb9b1579469726a75cec521c23b75 Mon Sep 17 00:00:00 2001 From: Brandon Nozaki Miller Date: Mon, 4 Jan 2016 01:45:28 -0800 Subject: [PATCH] updated TLS socket examples --- .../world-server.js | 4 +- .../basic-more-secure/hello-client.js | 6 +- .../basic-more-secure/world-server.js | 8 +- .../basic-most-secure/hello-client.js | 6 +- .../basic-most-secure/world-server.js | 8 +- example/TLSSocket/basic/world-server.js | 4 +- example/TLSSocket/basicSync/world-server.js | 4 +- .../hello-client.js | 6 +- .../world.server.js | 8 +- testHarness/readme.md | 9 - testHarness/test.js | 170 ------------------ .../stopRetrieing-unix-socket-test/client.js | 32 ---- .../stopRetrieing-unix-socket-test/server.js | 48 ----- testHarness/tests/tcp-socket-test/client.js | 39 ---- testHarness/tests/tcp-socket-test/server.js | 92 ---------- .../test-harness-test/testHarnessClient.js | 42 ----- testHarness/tests/udp-socket-test/client.js | 36 ---- testHarness/tests/udp-socket-test/server.js | 101 ----------- testHarness/tests/unix-socket-test/client.js | 39 ---- testHarness/tests/unix-socket-test/server.js | 97 ---------- 20 files changed, 27 insertions(+), 732 deletions(-) delete mode 100644 testHarness/readme.md delete mode 100644 testHarness/test.js delete mode 100644 testHarness/tests/stopRetrieing-unix-socket-test/client.js delete mode 100644 testHarness/tests/stopRetrieing-unix-socket-test/server.js delete mode 100644 testHarness/tests/tcp-socket-test/client.js delete mode 100644 testHarness/tests/tcp-socket-test/server.js delete mode 100644 testHarness/tests/test-harness-test/testHarnessClient.js delete mode 100644 testHarness/tests/udp-socket-test/client.js delete mode 100644 testHarness/tests/udp-socket-test/server.js delete mode 100644 testHarness/tests/unix-socket-test/client.js delete mode 100644 testHarness/tests/unix-socket-test/server.js diff --git a/example/TLSSocket/Multi-Client-Broadcast-basic/world-server.js b/example/TLSSocket/Multi-Client-Broadcast-basic/world-server.js index 7442d85..6214040 100644 --- a/example/TLSSocket/Multi-Client-Broadcast-basic/world-server.js +++ b/example/TLSSocket/Multi-Client-Broadcast-basic/world-server.js @@ -10,8 +10,8 @@ var ipc=require('../../../node-ipc'); ipc.config.id = 'world'; ipc.config.retry= 1500; ipc.config.tls={ - public: '../../../local-node-ipc-certs/server.pub', - private: '../../../local-node-ipc-certs/private/server.key' + public: __dirname+'/../../../local-node-ipc-certs/server.pub', + private: __dirname+'/../../../local-node-ipc-certs/private/server.key' } var messages={ diff --git a/example/TLSSocket/basic-more-secure/hello-client.js b/example/TLSSocket/basic-more-secure/hello-client.js index 4104d26..5f40b04 100644 --- a/example/TLSSocket/basic-more-secure/hello-client.js +++ b/example/TLSSocket/basic-more-secure/hello-client.js @@ -10,11 +10,11 @@ var ipc=require('../../../node-ipc'); ipc.config.id = 'hello'; ipc.config.retry= 1500; ipc.config.tls={ - private: '../../../local-node-ipc-certs/private/client.key', - public: '../../../local-node-ipc-certs/client.pub', + private: __dirname+'/../../../local-node-ipc-certs/private/client.key', + public: __dirname+'/../../../local-node-ipc-certs/client.pub', rejectUnauthorized:false, trustedConnections: [ - '../../../local-node-ipc-certs/server.pub' + __dirname+'/../../../local-node-ipc-certs/server.pub' ] }; diff --git a/example/TLSSocket/basic-more-secure/world-server.js b/example/TLSSocket/basic-more-secure/world-server.js index a893487..f1762dc 100644 --- a/example/TLSSocket/basic-more-secure/world-server.js +++ b/example/TLSSocket/basic-more-secure/world-server.js @@ -10,13 +10,13 @@ var ipc=require('../../../node-ipc'); ipc.config.id = 'world'; ipc.config.retry= 1500; ipc.config.tls={ - public: '../../../local-node-ipc-certs/server.pub', - private: '../../../local-node-ipc-certs/private/server.key', - dhparam: '../../../local-node-ipc-certs/private/dhparam.pem', + public: __dirname+'/../../../local-node-ipc-certs/server.pub', + private: __dirname+'/../../../local-node-ipc-certs/private/server.key', + dhparam: __dirname+'/../../../local-node-ipc-certs/private/dhparam.pem', requestCert: true, rejectUnauthorized:false, trustedConnections: [ - '../../../local-node-ipc-certs/client.pub' + __dirname+'/../../../local-node-ipc-certs/client.pub' ] } diff --git a/example/TLSSocket/basic-most-secure/hello-client.js b/example/TLSSocket/basic-most-secure/hello-client.js index 2bfced2..1188cfb 100644 --- a/example/TLSSocket/basic-most-secure/hello-client.js +++ b/example/TLSSocket/basic-most-secure/hello-client.js @@ -11,11 +11,11 @@ ipc.config.id = 'hello'; ipc.config.retry= 1500; ipc.config.networkHost='localhost'; ipc.config.tls={ - private: '../../../local-node-ipc-certs/private/client.key', - public: '../../../local-node-ipc-certs/client.pub', + private: __dirname+'/../../../local-node-ipc-certs/private/client.key', + public: __dirname+'/../../../local-node-ipc-certs/client.pub', rejectUnauthorized:true, trustedConnections: [ - '../../../local-node-ipc-certs/server.pub' + __dirname+'/../../../local-node-ipc-certs/server.pub' ] }; diff --git a/example/TLSSocket/basic-most-secure/world-server.js b/example/TLSSocket/basic-most-secure/world-server.js index e44b4c9..4af0315 100644 --- a/example/TLSSocket/basic-most-secure/world-server.js +++ b/example/TLSSocket/basic-most-secure/world-server.js @@ -11,13 +11,13 @@ ipc.config.id = 'world'; ipc.config.retry= 1500; ipc.config.networkHost='localhost'; ipc.config.tls={ - public: '../../../local-node-ipc-certs/server.pub', - private: '../../../local-node-ipc-certs/private/server.key', - dhparam: '../../../local-node-ipc-certs/private/dhparam.pem', + public: __dirname+'/../../../local-node-ipc-certs/server.pub', + private: __dirname+'/../../../local-node-ipc-certs/private/server.key', + dhparam: __dirname+'/../../../local-node-ipc-certs/private/dhparam.pem', requestCert: true, rejectUnauthorized:true, trustedConnections: [ - '../../../local-node-ipc-certs/client.pub' + __dirname+'/../../../local-node-ipc-certs/client.pub' ] } diff --git a/example/TLSSocket/basic/world-server.js b/example/TLSSocket/basic/world-server.js index a78da8a..31d4798 100644 --- a/example/TLSSocket/basic/world-server.js +++ b/example/TLSSocket/basic/world-server.js @@ -10,8 +10,8 @@ var ipc=require('../../../node-ipc'); ipc.config.id = 'world'; ipc.config.retry= 1500; ipc.config.tls={ - public: '../../../local-node-ipc-certs/server.pub', - private: '../../../local-node-ipc-certs/private/server.key' + public: __dirname+'/../../../local-node-ipc-certs/server.pub', + private: __dirname+'/../../../local-node-ipc-certs/private/server.key' } ipc.serveNet( diff --git a/example/TLSSocket/basicSync/world-server.js b/example/TLSSocket/basicSync/world-server.js index 8ae2325..d6128b5 100644 --- a/example/TLSSocket/basicSync/world-server.js +++ b/example/TLSSocket/basicSync/world-server.js @@ -11,8 +11,8 @@ ipc.config.id = 'world'; ipc.config.retry= 1500; ipc.config.sync= true; ipc.config.tls={ - public: '../../../local-node-ipc-certs/server.pub', - private: '../../../local-node-ipc-certs/private/server.key' + public: __dirname+'/../../../local-node-ipc-certs/server.pub', + private: __dirname+'/../../../local-node-ipc-certs/private/server.key' } ipc.serveNet( diff --git a/example/TLSSocket/rawBuffer-only-works-with-most-secure/hello-client.js b/example/TLSSocket/rawBuffer-only-works-with-most-secure/hello-client.js index b893444..f4cac3e 100644 --- a/example/TLSSocket/rawBuffer-only-works-with-most-secure/hello-client.js +++ b/example/TLSSocket/rawBuffer-only-works-with-most-secure/hello-client.js @@ -14,11 +14,11 @@ ipc.config.encoding='ascii'; ipc.config.networkHost='localhost'; ipc.config.tls={ - private: '../../../local-node-ipc-certs/private/client.key', - public: '../../../local-node-ipc-certs/client.pub', + private: __dirname+'/../../../local-node-ipc-certs/private/client.key', + public: __dirname+'/../../../local-node-ipc-certs/client.pub', rejectUnauthorized:true, trustedConnections: [ - '../../../local-node-ipc-certs/server.pub' + __dirname+'/../../../local-node-ipc-certs/server.pub' ] }; diff --git a/example/TLSSocket/rawBuffer-only-works-with-most-secure/world.server.js b/example/TLSSocket/rawBuffer-only-works-with-most-secure/world.server.js index d4053ea..f8394be 100644 --- a/example/TLSSocket/rawBuffer-only-works-with-most-secure/world.server.js +++ b/example/TLSSocket/rawBuffer-only-works-with-most-secure/world.server.js @@ -14,13 +14,13 @@ ipc.config.encoding='ascii'; ipc.config.networkHost='localhost'; ipc.config.tls={ - public: '../../../local-node-ipc-certs/server.pub', - private: '../../../local-node-ipc-certs/private/server.key', - dhparam: '../../../local-node-ipc-certs/private/dhparam.pem', + public: __dirname+'/../../../local-node-ipc-certs/server.pub', + private: __dirname+'/../../../local-node-ipc-certs/private/server.key', + dhparam: __dirname+'/../../../local-node-ipc-certs/private/dhparam.pem', requestCert: true, rejectUnauthorized:true, trustedConnections: [ - '../../../local-node-ipc-certs/client.pub' + __dirname+'/../../../local-node-ipc-certs/client.pub' ] } diff --git a/testHarness/readme.md b/testHarness/readme.md deleted file mode 100644 index fe2c214..0000000 --- a/testHarness/readme.md +++ /dev/null @@ -1,9 +0,0 @@ -#node-ipc test harness -***TestHarness was intended to be run on linux.*** -*the test.js file is intended to start and run all of the files in the test folder* - -A full regression test should be done before each release to npm to insure that no expected or previously documented bugs pop up again. -This will also help to ensure that each new release does not create any additional bugs. However, it can never fully ensure no new bugs will be created. -Any bug that is reported and testable, which should be 99.9% of bugs, should have a test written and added to the test folder after fixing. - -> Written with [StackEdit](https://stackedit.io/). \ No newline at end of file diff --git a/testHarness/test.js b/testHarness/test.js deleted file mode 100644 index bca7e3c..0000000 --- a/testHarness/test.js +++ /dev/null @@ -1,170 +0,0 @@ -var ipc = require('../node-ipc'), - cmd = require('node-cmd'), - fs = require('fs'), - tests = {}, - testCount=0, - fails=[], - passes=[], - debug=true; - -ipc.config.id = 'testHarness'; - -ipc.serve( - function(){ - - } -); - -ipc.server.on( - 'pass', - function(test,socket){ - ipc.log(socket.id.good,'passed',test.data); - tests[socket.id].pass.push(test); - passes.push(test); - } -); - -ipc.server.on( - 'fail', - function(test,socket){ - ipc.log(socket.id.warn,'failed',test.data); - tests[socket.id].fail.push(test); - fails.push(test); - } -); - -ipc.server.on( - 'start.test', - function(data,socket){ - - socket.id=data.id; - - if(!data.id){ - ipc.log('start.test duration not passed for unknown test, so failing test'.error); - socket.destroy(); - return; - } - - if(!data.duration){ - ipc.log(data.id.notice, 'start.test duration not passed, so failing test'.error); - ipc.disconnect(data.id); - return; - } - - ipc.log(data.id.notice, 'started'.debug); - - tests[data.id].started=true; - clearTimeout( - tests[data.id].delay - ); - - tests[data.id].delay=setTimeout( - ( - function(test){ - return function(){ - ipc.log(test.warn," failed to complete ".error); - tests[test].fail.push('end.test'); - fails.push(test+' >> end.test'); - testCount--; - tests[socket.id].delay=null; - checkComplete(); - } - } - )(data.id), - data.duration - ) - } -); - -ipc.server.on( - 'end.test', - function(data,socket){ - ipc.log(socket.id.notice, 'completed'.debug); - clearTimeout( - tests[socket.id].delay - ); - - tests[socket.id].delay=null; - - testCount--; - checkComplete(); - } -); - -ipc.log('TestHarness started.'.debug, 'Loading Tests.'.notice); - -ipc.server.define.listen['start.test']='This event should be called when a test is starting. It accepts an object with test details including the test id and duration'; -ipc.server.define.listen['end.test']='This event should be called when a test is completed.'; -ipc.server.define.listen['pass']='This event should be called when a test has passed, it accepts the name of the test portion which passed'; -ipc.server.define.listen['fail']='This event should be called when a test has failed, it accepts the name of the test portion which failed'; - -ipc.server.start(); - -fs.readdir( - 'tests', - function(err,testFolders){ - if(err){ - ipc.log(err,'You must execute the testHarness from the testHarness directory'.error) - return; - } - testCount=testFolders.length; - - for(var i =0; i> start.test'); - testCount--; - checkComplete(); - } - } - )(testFolders[i]), - 1000 - ) - }; - - runTests(testFolders[i]) - } - } -); - -function runTests(dir){ - fs.readdir( - 'tests/'+dir, - function(err,testFiles){ - if(err){ - ipc.log(err,'You must execute the testHarness from the testHarness directory'.error) - return; - } - for(var i =0; i