mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	fix many test problems (#1677)
* fix many test problems - adds [stoppable](https://npm.im/stoppable) to force-stop net & http servers - upgrades to latest mocha - much cleanup of servers - some removal of useless code Signed-off-by: Christopher Hiller <boneskull@boneskull.com> * increase wait time to hack at race condition * PoC with fork of stoppable Signed-off-by: Christopher Hiller <boneskull@boneskull.com> * fix custom stoppable url for newer npm * make travis go faster; attempt to avoid npm troubles * fix coveralls executable path * add extra time for flake to trigger spec Signed-off-by: Christopher Hiller <boneskull@boneskull.com>
This commit is contained in:
		
				
					committed by
					
						 Nick O'Leary
						Nick O'Leary
					
				
			
			
				
	
			
			
			
						parent
						
							25345302e8
						
					
				
				
					commit
					e1195ac00a
				
			
							
								
								
									
										14
									
								
								.travis.yml
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								.travis.yml
									
									
									
									
									
								
							| @@ -1,20 +1,10 @@ | ||||
| sudo: false | ||||
| language: node_js | ||||
| env: | ||||
|   - CXX="g++-4.8" | ||||
| addons: | ||||
|   apt: | ||||
|     sources: | ||||
|     - ubuntu-toolchain-r-test | ||||
|     packages: | ||||
|     - g++-4.8 | ||||
|     - gcc-4.8 | ||||
| node_js: | ||||
|   - "8" | ||||
|   - "6" | ||||
|   - "4" | ||||
| script: | ||||
|   - istanbul cover ./node_modules/.bin/grunt --report lcovonly && istanbul report text && ( cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js || true ) && rm -rf coverage | ||||
|   - istanbul cover ./node_modules/.bin/grunt --report lcovonly && istanbul report text && ( cat coverage/lcov.info | $(npm get prefix)/bin/coveralls || true ) && rm -rf coverage | ||||
| before_script: | ||||
|   - npm install -g istanbul | ||||
|   - npm install coveralls | ||||
|   - npm install -g istanbul coveralls | ||||
|   | ||||
							
								
								
									
										221
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										221
									
								
								package.json
									
									
									
									
									
								
							| @@ -1,114 +1,115 @@ | ||||
| { | ||||
|     "name": "node-red", | ||||
|     "version": "0.18.4", | ||||
|     "description": "A visual tool for wiring the Internet of Things", | ||||
|     "homepage": "http://nodered.org", | ||||
|     "license": "Apache-2.0", | ||||
|     "repository": { | ||||
|         "type": "git", | ||||
|         "url": "https://github.com/node-red/node-red.git" | ||||
|   "name": "node-red", | ||||
|   "version": "0.18.4", | ||||
|   "description": "A visual tool for wiring the Internet of Things", | ||||
|   "homepage": "http://nodered.org", | ||||
|   "license": "Apache-2.0", | ||||
|   "repository": { | ||||
|     "type": "git", | ||||
|     "url": "https://github.com/node-red/node-red.git" | ||||
|   }, | ||||
|   "main": "red/red.js", | ||||
|   "scripts": { | ||||
|     "start": "node red.js", | ||||
|     "test": "grunt", | ||||
|     "build": "grunt build" | ||||
|   }, | ||||
|   "bin": { | ||||
|     "node-red": "./red.js", | ||||
|     "node-red-pi": "bin/node-red-pi" | ||||
|   }, | ||||
|   "contributors": [ | ||||
|     { | ||||
|       "name": "Nick O'Leary" | ||||
|     }, | ||||
|     "main": "red/red.js", | ||||
|     "scripts": { | ||||
|         "start": "node red.js", | ||||
|         "test": "grunt", | ||||
|         "build": "grunt build" | ||||
|     }, | ||||
|     "bin": { | ||||
|         "node-red": "./red.js", | ||||
|         "node-red-pi": "bin/node-red-pi" | ||||
|     }, | ||||
|     "contributors": [ | ||||
|         { | ||||
|             "name": "Nick O'Leary" | ||||
|         }, | ||||
|         { | ||||
|             "name": "Dave Conway-Jones" | ||||
|         } | ||||
|     ], | ||||
|     "keywords": [ | ||||
|         "editor", | ||||
|         "messaging", | ||||
|         "iot", | ||||
|         "flow" | ||||
|     ], | ||||
|     "dependencies": { | ||||
|         "basic-auth": "2.0.0", | ||||
|         "bcryptjs": "2.4.3", | ||||
|         "body-parser": "1.18.2", | ||||
|         "cheerio": "0.22.0", | ||||
|         "clone": "2.1.1", | ||||
|         "cookie": "0.3.1", | ||||
|         "cookie-parser": "1.4.3", | ||||
|         "cors": "2.8.4", | ||||
|         "cron": "1.3.0", | ||||
|         "express": "4.16.2", | ||||
|         "express-session": "1.15.6", | ||||
|         "follow-redirects": "1.3.0", | ||||
|         "fs-extra": "5.0.0", | ||||
|         "fs.notify": "0.0.4", | ||||
|         "hash-sum": "1.0.2", | ||||
|         "i18next": "1.10.6", | ||||
|         "is-utf8": "0.2.1", | ||||
|         "js-yaml": "3.10.0", | ||||
|         "json-stringify-safe": "5.0.1", | ||||
|         "jsonata": "1.5.0", | ||||
|         "media-typer": "0.3.0", | ||||
|         "memorystore": "1.6.0", | ||||
|         "mqtt": "2.15.1", | ||||
|         "multer": "1.3.0", | ||||
|         "mustache": "2.3.0", | ||||
|         "node-red-node-email": "0.1.*", | ||||
|         "node-red-node-feedparser": "0.1.*", | ||||
|         "node-red-node-rbe": "0.2.*", | ||||
|         "node-red-node-twitter": "0.1.*", | ||||
|         "nopt": "4.0.1", | ||||
|         "oauth2orize": "1.11.0", | ||||
|         "on-headers": "1.0.1", | ||||
|         "passport": "0.4.0", | ||||
|         "passport-http-bearer": "1.0.1", | ||||
|         "passport-oauth2-client-password": "0.1.2", | ||||
|         "raw-body": "2.3.2", | ||||
|         "semver": "5.4.1", | ||||
|         "sentiment": "2.1.0", | ||||
|         "uglify-js": "3.3.6", | ||||
|         "when": "3.7.8", | ||||
|         "ws": "1.1.5", | ||||
|         "xml2js": "0.4.19" | ||||
|     }, | ||||
|     "optionalDependencies": { | ||||
|         "bcrypt": "~1.0.3" | ||||
|     }, | ||||
|     "devDependencies": { | ||||
|         "chromedriver": "^2.33.2", | ||||
|         "grunt": "~1.0.1", | ||||
|         "grunt-chmod": "~1.1.1", | ||||
|         "grunt-cli": "~1.2.0", | ||||
|         "grunt-concurrent": "~2.3.1", | ||||
|         "grunt-contrib-clean": "~1.1.0", | ||||
|         "grunt-contrib-compress": "~1.4.0", | ||||
|         "grunt-contrib-concat": "~1.0.1", | ||||
|         "grunt-contrib-copy": "~1.0.0", | ||||
|         "grunt-contrib-jshint": "~1.1.0", | ||||
|         "grunt-contrib-uglify": "~3.3.0", | ||||
|         "grunt-contrib-watch": "~1.0.0", | ||||
|         "grunt-jsonlint": "~1.1.0", | ||||
|         "grunt-mocha-istanbul": "5.0.2", | ||||
|         "grunt-nodemon": "~0.4.2", | ||||
|         "grunt-sass": "~2.0.0", | ||||
|         "grunt-simple-mocha": "~0.4.1", | ||||
|         "grunt-webdriver": "^2.0.3", | ||||
|         "istanbul": "0.4.5", | ||||
|         "mocha": "~3.4.2", | ||||
|         "should": "^8.4.0", | ||||
|         "sinon": "1.17.7", | ||||
|         "supertest": "3.0.0", | ||||
|         "wdio-chromedriver-service": "^0.1.1", | ||||
|         "wdio-mocha-framework": "^0.5.11", | ||||
|         "wdio-spec-reporter": "^0.1.3", | ||||
|         "webdriverio": "^4.9.11" | ||||
|     }, | ||||
|     "engines": { | ||||
|         "node": ">=4" | ||||
|     { | ||||
|       "name": "Dave Conway-Jones" | ||||
|     } | ||||
|   ], | ||||
|   "keywords": [ | ||||
|     "editor", | ||||
|     "messaging", | ||||
|     "iot", | ||||
|     "flow" | ||||
|   ], | ||||
|   "dependencies": { | ||||
|     "basic-auth": "2.0.0", | ||||
|     "bcryptjs": "2.4.3", | ||||
|     "body-parser": "1.18.2", | ||||
|     "cheerio": "0.22.0", | ||||
|     "clone": "2.1.1", | ||||
|     "cookie": "0.3.1", | ||||
|     "cookie-parser": "1.4.3", | ||||
|     "cors": "2.8.4", | ||||
|     "cron": "1.3.0", | ||||
|     "express": "4.16.2", | ||||
|     "express-session": "1.15.6", | ||||
|     "follow-redirects": "1.3.0", | ||||
|     "fs-extra": "5.0.0", | ||||
|     "fs.notify": "0.0.4", | ||||
|     "hash-sum": "1.0.2", | ||||
|     "i18next": "1.10.6", | ||||
|     "is-utf8": "0.2.1", | ||||
|     "js-yaml": "3.10.0", | ||||
|     "json-stringify-safe": "5.0.1", | ||||
|     "jsonata": "1.5.0", | ||||
|     "media-typer": "0.3.0", | ||||
|     "memorystore": "1.6.0", | ||||
|     "mqtt": "2.15.1", | ||||
|     "multer": "1.3.0", | ||||
|     "mustache": "2.3.0", | ||||
|     "node-red-node-email": "0.1.*", | ||||
|     "node-red-node-feedparser": "0.1.*", | ||||
|     "node-red-node-rbe": "0.2.*", | ||||
|     "node-red-node-twitter": "0.1.*", | ||||
|     "nopt": "4.0.1", | ||||
|     "oauth2orize": "1.11.0", | ||||
|     "on-headers": "1.0.1", | ||||
|     "passport": "0.4.0", | ||||
|     "passport-http-bearer": "1.0.1", | ||||
|     "passport-oauth2-client-password": "0.1.2", | ||||
|     "raw-body": "2.3.2", | ||||
|     "semver": "5.4.1", | ||||
|     "sentiment": "2.1.0", | ||||
|     "uglify-js": "3.3.6", | ||||
|     "when": "3.7.8", | ||||
|     "ws": "1.1.5", | ||||
|     "xml2js": "0.4.19" | ||||
|   }, | ||||
|   "optionalDependencies": { | ||||
|     "bcrypt": "~1.0.3" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "chromedriver": "^2.33.2", | ||||
|     "grunt": "~1.0.1", | ||||
|     "grunt-chmod": "~1.1.1", | ||||
|     "grunt-cli": "~1.2.0", | ||||
|     "grunt-concurrent": "~2.3.1", | ||||
|     "grunt-contrib-clean": "~1.1.0", | ||||
|     "grunt-contrib-compress": "~1.4.0", | ||||
|     "grunt-contrib-concat": "~1.0.1", | ||||
|     "grunt-contrib-copy": "~1.0.0", | ||||
|     "grunt-contrib-jshint": "~1.1.0", | ||||
|     "grunt-contrib-uglify": "~3.3.0", | ||||
|     "grunt-contrib-watch": "~1.0.0", | ||||
|     "grunt-jsonlint": "~1.1.0", | ||||
|     "grunt-mocha-istanbul": "5.0.2", | ||||
|     "grunt-nodemon": "~0.4.2", | ||||
|     "grunt-sass": "~2.0.0", | ||||
|     "grunt-simple-mocha": "~0.4.1", | ||||
|     "grunt-webdriver": "^2.0.3", | ||||
|     "istanbul": "0.4.5", | ||||
|     "mocha": "^5.1.1", | ||||
|     "should": "^8.4.0", | ||||
|     "sinon": "1.17.7", | ||||
|     "stoppable": "^1.0.6", | ||||
|     "supertest": "3.0.0", | ||||
|     "wdio-chromedriver-service": "^0.1.1", | ||||
|     "wdio-mocha-framework": "^0.5.11", | ||||
|     "wdio-spec-reporter": "^0.1.3", | ||||
|     "webdriverio": "^4.9.11" | ||||
|   }, | ||||
|   "engines": { | ||||
|     "node": ">=4" | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -24,6 +24,10 @@ describe('sentiment Node', function() { | ||||
|         helper.startServer(done); | ||||
|     }); | ||||
|  | ||||
|     after(function(done) { | ||||
|         helper.stopServer(done); | ||||
|     }); | ||||
|  | ||||
|     afterEach(function() { | ||||
|         helper.unload(); | ||||
|     }); | ||||
|   | ||||
| @@ -24,6 +24,10 @@ describe('inject node', function() { | ||||
|         helper.startServer(done); | ||||
|     }); | ||||
|  | ||||
|     after(function(done) { | ||||
|         helper.stopServer(done); | ||||
|     }); | ||||
|  | ||||
|     afterEach(function() { | ||||
|         helper.unload(); | ||||
|     }); | ||||
|   | ||||
| @@ -25,6 +25,10 @@ describe('debug node', function() { | ||||
|         helper.startServer(done); | ||||
|     }); | ||||
|  | ||||
|     after(function(done) { | ||||
|         helper.stopServer(done); | ||||
|     }); | ||||
|  | ||||
|     beforeEach(function (done) { | ||||
|         setTimeout(function() { | ||||
|             done(); | ||||
|   | ||||
| @@ -24,6 +24,10 @@ describe('link Node', function() { | ||||
|         helper.startServer(done); | ||||
|     }); | ||||
|  | ||||
|     after(function(done) { | ||||
|         helper.stopServer(done); | ||||
|     }); | ||||
|  | ||||
|     afterEach(function() { | ||||
|         helper.unload(); | ||||
|     }); | ||||
|   | ||||
| @@ -24,6 +24,10 @@ describe('function node', function() { | ||||
|         helper.startServer(done); | ||||
|     }); | ||||
|  | ||||
|     after(function(done) { | ||||
|         helper.stopServer(done); | ||||
|     }); | ||||
|  | ||||
|     afterEach(function() { | ||||
|         helper.unload(); | ||||
|     }); | ||||
|   | ||||
| @@ -24,6 +24,10 @@ describe('template node', function() { | ||||
|         helper.startServer(done); | ||||
|     }); | ||||
|  | ||||
|     after(function(done) { | ||||
|         helper.stopServer(done); | ||||
|     }); | ||||
|  | ||||
|     afterEach(function() { | ||||
|         helper.unload(); | ||||
|     }); | ||||
|   | ||||
| @@ -304,11 +304,11 @@ describe('trigger node', function() { | ||||
|                     } | ||||
|                     else { | ||||
|                         msg.should.have.a.property("payload", "bar"); | ||||
|                         spy.restore(); | ||||
|                         RED.util.evaluateNodeProperty.restore(); | ||||
|                         done(); | ||||
|                     } | ||||
|                 } | ||||
|                 catch(err) { spy.restore(); done(err); } | ||||
|                 catch(err) { RED.util.evaluateNodeProperty.restore(); done(err); } | ||||
|             }); | ||||
|             n1.emit("input", {payload:null}); | ||||
|         }); | ||||
| @@ -384,6 +384,7 @@ describe('trigger node', function() { | ||||
|     }); | ||||
|  | ||||
|     it('should be able to extend the delay', function(done) { | ||||
|         this.timeout(5000); // add extra time for flake | ||||
|         var spy = sinon.stub(RED.util, 'evaluateNodeProperty', | ||||
|             function(arg1, arg2, arg3, arg4) { return arg1; } | ||||
|         ); | ||||
|   | ||||
| @@ -19,6 +19,7 @@ var http = require("http"); | ||||
| var should = require("should"); | ||||
| var express = require("express"); | ||||
| var bodyParser = require('body-parser'); | ||||
| var stoppable = require('stoppable'); | ||||
| var helper = require("../../helper.js"); | ||||
| var httpRequestNode = require("../../../../nodes/core/io/21-httprequest.js"); | ||||
| var hashSum = require("hash-sum"); | ||||
| @@ -30,13 +31,10 @@ describe('HTTP Request Node', function() { | ||||
|  | ||||
|     function startServer(done) { | ||||
|         testPort += 1; | ||||
|         testServer = http.createServer(testApp); | ||||
|         testServer.on('error', function(err) { | ||||
|             startServer(done); | ||||
|         }); | ||||
|         testServer = stoppable(http.createServer(testApp)); | ||||
|         testServer.listen(testPort,function(err) { | ||||
|             done(); | ||||
|         }) | ||||
|             done(err); | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     function getTestURL(url) { | ||||
| @@ -57,13 +55,18 @@ describe('HTTP Request Node', function() { | ||||
|             } | ||||
|             res.json(result); | ||||
|         }); | ||||
|         startServer(function() { | ||||
|         startServer(function(err) { | ||||
|             if (err) { | ||||
|                 done(err); | ||||
|             } | ||||
|             helper.startServer(done); | ||||
|         }); | ||||
|     }); | ||||
|  | ||||
|     after(function() { | ||||
|         testServer.close(); | ||||
|     after(function(done) { | ||||
|         testServer.stop(() => { | ||||
|             helper.stopServer(done); | ||||
|         }); | ||||
|     }); | ||||
|     afterEach(function() { | ||||
|         helper.unload(); | ||||
|   | ||||
| @@ -61,6 +61,10 @@ describe('websocket Node', function() { | ||||
|         helper.startServer(done); | ||||
|     }); | ||||
|  | ||||
|     after(function(done) { | ||||
|         helper.stopServer(done); | ||||
|     }); | ||||
|  | ||||
|     afterEach(function() { | ||||
|         closeAll(); | ||||
|         helper.unload(); | ||||
|   | ||||
| @@ -16,6 +16,7 @@ | ||||
|  | ||||
| var net = require("net"); | ||||
| var should = require("should"); | ||||
| var stoppable = require('stoppable'); | ||||
| var helper = require("../../helper.js"); | ||||
| var tcpinNode = require("../../../../nodes/core/io/31-tcpin.js"); | ||||
|  | ||||
| @@ -26,20 +27,13 @@ describe('TCP in Node', function() { | ||||
|     var server_port = 9300; | ||||
|     var reply_data = undefined; | ||||
|  | ||||
|     before(function(done) { | ||||
|         done(); | ||||
|     }); | ||||
|  | ||||
|     after(function() { | ||||
|     }); | ||||
|  | ||||
|     beforeEach(function(done) { | ||||
|         startServer(done); | ||||
|     }); | ||||
|  | ||||
|     afterEach(function() { | ||||
|         stopServer(); | ||||
|     afterEach(function(done) { | ||||
|         helper.unload(); | ||||
|         stopServer(done); | ||||
|     }); | ||||
|  | ||||
|     function sendArray(sock, array) { | ||||
| @@ -55,15 +49,15 @@ describe('TCP in Node', function() { | ||||
|      | ||||
|     function startServer(done) { | ||||
|         server_port += 1; | ||||
|         server = net.createServer(function(c) { | ||||
|         server = stoppable(net.createServer(function(c) { | ||||
|             sendArray(c, reply_data); | ||||
|         }).listen(server_port, "localhost", function(err) { | ||||
|         })).listen(server_port, "localhost", function(err) { | ||||
|             done(err); | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     function stopServer() { | ||||
|         server.close(); | ||||
|     function stopServer(done) { | ||||
|         server.stop(done); | ||||
|     } | ||||
|      | ||||
|     function send(wdata) { | ||||
|   | ||||
| @@ -16,6 +16,7 @@ | ||||
|  | ||||
| var net = require("net"); | ||||
| var should = require("should"); | ||||
| var stoppable = require('stoppable'); | ||||
| var helper = require("../../helper.js"); | ||||
| var tcpinNode = require("../../../../nodes/core/io/31-tcpin.js"); | ||||
|  | ||||
| @@ -26,7 +27,7 @@ describe('TCP Request Node', function() { | ||||
|  | ||||
|     function startServer(done) { | ||||
|         port += 1; | ||||
|         server = net.createServer(function(c) { | ||||
|         server = stoppable(net.createServer(function(c) { | ||||
| 	    c.on('data', function(data) { | ||||
| 		var rdata = "ACK:"+data.toString(); | ||||
| 		c.write(rdata); | ||||
| @@ -34,7 +35,7 @@ describe('TCP Request Node', function() { | ||||
|             c.on('error', function(err) { | ||||
| 		startServer(done); | ||||
|             }); | ||||
|         }).listen(port, "127.0.0.1", function(err) { | ||||
|         })).listen(port, "127.0.0.1", function(err) { | ||||
|             done(); | ||||
|         }); | ||||
|     } | ||||
| @@ -43,8 +44,8 @@ describe('TCP Request Node', function() { | ||||
|         startServer(done); | ||||
|     }); | ||||
|  | ||||
|     after(function() { | ||||
|         server.close(); | ||||
|     after(function(done) { | ||||
|         server.stop(done); | ||||
|     }); | ||||
|  | ||||
|     afterEach(function() { | ||||
|   | ||||
| @@ -27,7 +27,8 @@ describe('UDP in Node', function() { | ||||
|         helper.startServer(done); | ||||
|     }); | ||||
|  | ||||
|     after(function() { | ||||
|     after(function(done) { | ||||
|         helper.stopServer(done); | ||||
|     }); | ||||
|  | ||||
|     afterEach(function() { | ||||
|   | ||||
| @@ -27,7 +27,8 @@ describe('UDP out Node', function() { | ||||
|         helper.startServer(done); | ||||
|     }); | ||||
|  | ||||
|     after(function() { | ||||
|     after(function(done) { | ||||
|         helper.stopServer(done); | ||||
|     }); | ||||
|  | ||||
|     afterEach(function() { | ||||
| @@ -38,7 +39,7 @@ describe('UDP out Node', function() { | ||||
|         var sock = dgram.createSocket('udp4'); | ||||
|         sock.on('message', function(msg, rinfo) { | ||||
|             msg.should.deepEqual(data); | ||||
|             done(); | ||||
|             sock.close(done); | ||||
|         }); | ||||
|         sock.bind(port, '127.0.0.1'); | ||||
|         port++; | ||||
|   | ||||
| @@ -28,8 +28,8 @@ describe('switch Node', function() { | ||||
|  | ||||
|     afterEach(function(done) { | ||||
|         helper.unload(); | ||||
|         helper.stopServer(done); | ||||
|         RED.settings.nodeMessageBufferMaxLength = 0; | ||||
|         helper.stopServer(done); | ||||
|     }); | ||||
|  | ||||
|     it('should be loaded with some defaults', function(done) { | ||||
|   | ||||
| @@ -578,7 +578,6 @@ describe('change Node', function() { | ||||
|         }); | ||||
|  | ||||
|         it('reports invalid regex', function(done) { | ||||
|             var sinon = require('sinon'); | ||||
|             var flow = [{"id":"changeNode1","type":"change","action":"change","property":"payload","from":"\\+**+","to":"NUMBER","reg":true,"name":"changeNode","wires":[["helperNode1"]]}, | ||||
|                         {id:"helperNode1", type:"helper", wires:[]}]; | ||||
|             helper.load(changeNode, flow, function() { | ||||
|   | ||||
| @@ -135,11 +135,13 @@ describe('range Node', function() { | ||||
|             var sinon = require('sinon'); | ||||
|             sinon.stub(rangeNode1, 'log', function(log) { | ||||
|                 if (log.indexOf("notnumber") > -1) { | ||||
|                     rangeNode1.log.restore(); | ||||
|                     done(); | ||||
|                 } else { | ||||
|                     try { | ||||
|                         should.fail(null, null, "Non-number inputs should be reported!"); | ||||
|                     } catch (err) { | ||||
|                         rangeNode1.log.restore(); | ||||
|                         done(err); | ||||
|                     } | ||||
|                 } | ||||
|   | ||||
| @@ -26,6 +26,10 @@ describe('SPLIT node', function() { | ||||
|         helper.startServer(done); | ||||
|     }); | ||||
|  | ||||
|     after(function(done) { | ||||
|         helper.stopServer(done); | ||||
|     }); | ||||
|  | ||||
|     afterEach(function() { | ||||
|         helper.unload(); | ||||
|     }); | ||||
| @@ -268,6 +272,10 @@ describe('JOIN node', function() { | ||||
|         helper.startServer(done); | ||||
|     }); | ||||
|  | ||||
|     after(function(done) { | ||||
|         helper.stopServer(done); | ||||
|     }); | ||||
|  | ||||
|     afterEach(function() { | ||||
|         helper.unload(); | ||||
|         RED.settings.nodeMessageBufferMaxLength = 0; | ||||
|   | ||||
| @@ -25,6 +25,10 @@ describe('SORT node', function() { | ||||
|         helper.startServer(done); | ||||
|     }); | ||||
|  | ||||
|     after(function(done) { | ||||
|         helper.stopServer(done); | ||||
|     }); | ||||
|  | ||||
|     afterEach(function() { | ||||
|         helper.unload(); | ||||
|         RED.settings.nodeMessageBufferMaxLength = 0; | ||||
|   | ||||
| @@ -26,6 +26,10 @@ describe('BATCH node', function() { | ||||
|         helper.startServer(done); | ||||
|     }); | ||||
|  | ||||
|     after(function(done) { | ||||
|         helper.stopServer(done); | ||||
|     }); | ||||
|  | ||||
|     afterEach(function() { | ||||
|         helper.unload(); | ||||
|         RED.settings.nodeMessageBufferMaxLength = 0; | ||||
|   | ||||
| @@ -24,6 +24,10 @@ describe('CSV node', function() { | ||||
|         helper.startServer(done); | ||||
|     }); | ||||
|  | ||||
|     after(function(done) { | ||||
|         helper.stopServer(done); | ||||
|     }); | ||||
|  | ||||
|     afterEach(function() { | ||||
|         helper.unload(); | ||||
|     }); | ||||
|   | ||||
| @@ -15,7 +15,6 @@ | ||||
|  **/ | ||||
|  | ||||
| var should = require("should"); | ||||
| var sinon = require("sinon"); | ||||
| var path = require("path"); | ||||
| var fs = require('fs-extra'); | ||||
|  | ||||
| @@ -31,6 +30,10 @@ describe('html node', function() { | ||||
|         helper.startServer(done); | ||||
|     }); | ||||
|  | ||||
|     after(function(done) { | ||||
|         helper.stopServer(done); | ||||
|     }); | ||||
|  | ||||
|     beforeEach(function() { | ||||
|         fs.existsSync(file).should.be.true(); | ||||
|     }); | ||||
|   | ||||
| @@ -24,6 +24,10 @@ describe('JSON node', function() { | ||||
|         helper.startServer(done); | ||||
|     }); | ||||
|  | ||||
|     after(function(done) { | ||||
|         helper.stopServer(done); | ||||
|     }); | ||||
|  | ||||
|     afterEach(function() { | ||||
|         helper.unload(); | ||||
|     }); | ||||
|   | ||||
| @@ -24,6 +24,10 @@ describe('XML node', function() { | ||||
|         helper.startServer(done); | ||||
|     }); | ||||
|  | ||||
|     after(function(done) { | ||||
|         helper.stopServer(done); | ||||
|     }); | ||||
|  | ||||
|     afterEach(function() { | ||||
|         helper.unload(); | ||||
|     }); | ||||
|   | ||||
| @@ -24,6 +24,10 @@ describe('YAML node', function() { | ||||
|         helper.startServer(done); | ||||
|     }); | ||||
|  | ||||
|     after(function(done) { | ||||
|         helper.stopServer(done); | ||||
|     }); | ||||
|  | ||||
|     afterEach(function() { | ||||
|         helper.unload(); | ||||
|     }); | ||||
|   | ||||
| @@ -130,15 +130,20 @@ describe('tail Node', function() { | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     it('should throw an error if run on Windows', function(done) { | ||||
|     it('should throw an error if run on Windows', function() { | ||||
|         // Stub os platform so we can make it look like windows | ||||
|         var os = require('os'); | ||||
|         var spy = sinon.stub(os, 'platform', function(arg) { return("windows"); }); | ||||
|  | ||||
|         /*jshint immed: false */ | ||||
|         (function() { tailNode("1234"); }).should.throw(); | ||||
|         os.platform.restore(); | ||||
|         done(); | ||||
|         try { | ||||
|             (function() { tailNode("1234"); }).should.throw(); | ||||
|         } catch (err) { | ||||
|             throw err; | ||||
|         } | ||||
|         finally { | ||||
|             os.platform.restore(); | ||||
|         } | ||||
|     }); | ||||
|  | ||||
|     /* | ||||
|   | ||||
| @@ -28,7 +28,7 @@ describe('file Nodes', function() { | ||||
|  | ||||
|         var resourcesDir = path.join(__dirname,"..","..","..","resources"); | ||||
|         var fileToTest = path.join(resourcesDir,"50-file-test-file.txt"); | ||||
|         var wait = 150; | ||||
|         var wait = 250; | ||||
|  | ||||
|         beforeEach(function(done) { | ||||
|             //fs.writeFileSync(fileToTest, "File message line 1\File message line 2\n"); | ||||
|   | ||||
| @@ -19,6 +19,7 @@ var sinon = require("sinon"); | ||||
| var when = require("when"); | ||||
| var request = require('supertest'); | ||||
| var express = require("express"); | ||||
| var stoppable = require('stoppable'); | ||||
| var nock; | ||||
| if (!process.version.match(/^v0\.[0-9]\./)) { | ||||
|     // only set nock for node >= 0.10 | ||||
| @@ -132,7 +133,7 @@ module.exports = { | ||||
|     }, | ||||
|  | ||||
|     startServer: function(done) { | ||||
|         server = http.createServer(function(req,res) { app(req,res); }); | ||||
|         server = stoppable(http.createServer(function(req,res) { app(req,res); }), 0); | ||||
|         RED.init(server, { | ||||
|             SKIP_BUILD_CHECK: true, | ||||
|             logging:{console:{level:'off'}} | ||||
| @@ -150,13 +151,13 @@ module.exports = { | ||||
|     stopServer: function(done) { | ||||
|         if (server) { | ||||
|             try { | ||||
|                 server.on('close', function() { | ||||
|                     comms.stop(); | ||||
|                 }); | ||||
|                 server.close(done); | ||||
|                 comms.stop(); | ||||
|                 server.stop(done); | ||||
|             } catch(e) { | ||||
|                 done(); | ||||
|             } | ||||
|         } else { | ||||
|             done(); | ||||
|         } | ||||
|     }, | ||||
|  | ||||
|   | ||||
| @@ -813,7 +813,6 @@ describe("api/admin/nodes", function() { | ||||
|  | ||||
|     describe('get icons', function() { | ||||
|         it('returns icon list', function(done) { | ||||
|             debugger; | ||||
|             initNodes({ | ||||
|                 nodes:{ | ||||
|                     getNodeIcons: function() { | ||||
|   | ||||
| @@ -16,6 +16,7 @@ | ||||
|  | ||||
| var should = require("should"); | ||||
| var sinon = require("sinon"); | ||||
| const stoppable = require('stoppable'); | ||||
|  | ||||
| var when = require("when"); | ||||
| var http = require('http'); | ||||
| @@ -30,13 +31,8 @@ var Tokens = require("../../../../red/api/auth/tokens"); | ||||
| var address = '127.0.0.1'; | ||||
| var listenPort = 0; // use ephemeral port | ||||
|  | ||||
| describe("api/editor/comms", function() { | ||||
|  | ||||
|     beforeEach(function (done) { | ||||
|         setTimeout(function() { | ||||
|             done(); | ||||
|         }, 55); | ||||
|     }); | ||||
| describe("api/editor/comms", function() { | ||||
|  | ||||
|     describe("with default keepalive", function() { | ||||
|         var server; | ||||
| @@ -44,7 +40,7 @@ describe("api/editor/comms", function() { | ||||
|         var port; | ||||
|         before(function(done) { | ||||
|             sinon.stub(Users,"default",function() { return when.resolve(null);}); | ||||
|             server = http.createServer(function(req,res){app(req,res)}); | ||||
|             server = stoppable(http.createServer(function(req,res){app(req,res)})); | ||||
|             comms.init(server, { | ||||
|                 settings:{}, | ||||
|                 log:{warn:function(){},_:function(){},trace:function(){},audit:function(){}}, | ||||
| @@ -59,9 +55,10 @@ describe("api/editor/comms", function() { | ||||
|             }); | ||||
|         }); | ||||
|  | ||||
|         after(function() { | ||||
|         after(function(done) { | ||||
|             Users.default.restore(); | ||||
|             comms.stop(); | ||||
|             server.stop(done); | ||||
|         }); | ||||
|  | ||||
|         it('accepts connection', function(done) { | ||||
| @@ -150,7 +147,7 @@ describe("api/editor/comms", function() { | ||||
|             }); | ||||
|         }); | ||||
|  | ||||
|         it.skip('listens for node/status events'); | ||||
|         it('listens for node/status events'); | ||||
|     }); | ||||
|     describe("disabled editor", function() { | ||||
|         var server; | ||||
| @@ -158,7 +155,7 @@ describe("api/editor/comms", function() { | ||||
|         var port; | ||||
|         before(function(done) { | ||||
|             sinon.stub(Users,"default",function() { return when.resolve(null);}); | ||||
|             server = http.createServer(function(req,res){app(req,res)}); | ||||
|             server = stoppable(http.createServer(function(req,res){app(req,res)})); | ||||
|             comms.init(server, { | ||||
|                 settings:{disableEditor:true}, | ||||
|                 log:{warn:function(){},_:function(){},trace:function(){},audit:function(){}}, | ||||
| @@ -173,9 +170,10 @@ describe("api/editor/comms", function() { | ||||
|             }); | ||||
|         }); | ||||
|  | ||||
|         after(function() { | ||||
|         after(function(done) { | ||||
|             Users.default.restore(); | ||||
|             comms.stop(); | ||||
|             server.stop(done); | ||||
|         }); | ||||
|  | ||||
|         it('rejects websocket connections',function(done) { | ||||
| @@ -197,7 +195,7 @@ describe("api/editor/comms", function() { | ||||
|         var port; | ||||
|         before(function(done) { | ||||
|             sinon.stub(Users,"default",function() { return when.resolve(null);}); | ||||
|             server = http.createServer(function(req,res){app(req,res)}); | ||||
|             server = stoppable(http.createServer(function(req,res){app(req,res)})); | ||||
|             comms.init(server, { | ||||
|                 settings:{httpAdminRoot:"/adminPath"}, | ||||
|                 log:{warn:function(){},_:function(){},trace:function(){},audit:function(){}}, | ||||
| @@ -212,9 +210,10 @@ describe("api/editor/comms", function() { | ||||
|             }); | ||||
|         }); | ||||
|  | ||||
|         after(function() { | ||||
|         after(function(done) { | ||||
|             Users.default.restore(); | ||||
|             comms.stop(); | ||||
|             server.stop(done); | ||||
|         }); | ||||
|  | ||||
|         it('accepts connections',function(done) { | ||||
| @@ -236,7 +235,7 @@ describe("api/editor/comms", function() { | ||||
|         var port; | ||||
|         before(function(done) { | ||||
|             sinon.stub(Users,"default",function() { return when.resolve(null);}); | ||||
|             server = http.createServer(function(req,res){app(req,res)}); | ||||
|             server = stoppable(http.createServer(function(req,res){app(req,res)})); | ||||
|             comms.init(server,{ | ||||
|                 settings:{httpAdminRoot:"/adminPath"}, | ||||
|                 log:{warn:function(){},_:function(){},trace:function(){},audit:function(){}}, | ||||
| @@ -251,9 +250,10 @@ describe("api/editor/comms", function() { | ||||
|             }); | ||||
|         }); | ||||
|  | ||||
|         after(function() { | ||||
|         after(function(done) { | ||||
|             Users.default.restore(); | ||||
|             comms.stop(); | ||||
|             server.stop(done); | ||||
|         }); | ||||
|  | ||||
|         it('accepts connections',function(done) { | ||||
| @@ -275,7 +275,7 @@ describe("api/editor/comms", function() { | ||||
|         var port; | ||||
|         before(function(done) { | ||||
|             sinon.stub(Users,"default",function() { return when.resolve(null);}); | ||||
|             server = http.createServer(function(req,res){app(req,res)}); | ||||
|             server = stoppable(http.createServer(function(req,res){app(req,res)})); | ||||
|             comms.init(server, { | ||||
|                 settings:{httpAdminRoot:"adminPath"}, | ||||
|                 log:{warn:function(){},_:function(){},trace:function(){},audit:function(){}}, | ||||
| @@ -290,9 +290,10 @@ describe("api/editor/comms", function() { | ||||
|             }); | ||||
|         }); | ||||
|  | ||||
|         after(function() { | ||||
|         after(function(done) { | ||||
|             Users.default.restore(); | ||||
|             comms.stop(); | ||||
|             server.stop(done); | ||||
|         }); | ||||
|  | ||||
|         it('accepts connections',function(done) { | ||||
| @@ -314,7 +315,7 @@ describe("api/editor/comms", function() { | ||||
|         var port; | ||||
|         before(function(done) { | ||||
|             sinon.stub(Users,"default",function() { return when.resolve(null);}); | ||||
|             server = http.createServer(function(req,res){app(req,res)}); | ||||
|             server = stoppable(http.createServer(function(req,res){app(req,res)})); | ||||
|             comms.init(server, { | ||||
|                 settings:{webSocketKeepAliveTime: 100}, | ||||
|                 log:{warn:function(){},_:function(){},trace:function(){},audit:function(){}}, | ||||
| @@ -328,9 +329,10 @@ describe("api/editor/comms", function() { | ||||
|                 done(); | ||||
|             }); | ||||
|         }); | ||||
|         after(function() { | ||||
|         after(function(done) { | ||||
|             Users.default.restore(); | ||||
|             comms.stop(); | ||||
|             server.stop(done); | ||||
|         }); | ||||
|         it('are sent', function(done) { | ||||
|             var ws = new WebSocket(url); | ||||
| @@ -400,7 +402,7 @@ describe("api/editor/comms", function() { | ||||
|             }); | ||||
|  | ||||
|  | ||||
|             server = http.createServer(function(req,res){app(req,res)}); | ||||
|             server = stoppable(http.createServer(function(req,res){app(req,res)})); | ||||
|             comms.init(server,{ | ||||
|                 settings:{adminAuth:{}}, | ||||
|                 log:{warn:function(){},_:function(){},trace:function(){},audit:function(){}}, | ||||
| @@ -414,11 +416,12 @@ describe("api/editor/comms", function() { | ||||
|                 done(); | ||||
|             }); | ||||
|         }); | ||||
|         after(function() { | ||||
|         after(function(done) { | ||||
|             getDefaultUser.restore(); | ||||
|             getUser.restore(); | ||||
|             getToken.restore(); | ||||
|             comms.stop(); | ||||
|             server.stop(done); | ||||
|         }); | ||||
|  | ||||
|         it('prevents connections that do not authenticate',function(done) { | ||||
| @@ -490,7 +493,7 @@ describe("api/editor/comms", function() { | ||||
|         var getDefaultUser; | ||||
|         before(function(done) { | ||||
|             getDefaultUser = sinon.stub(Users,"default",function() { return when.resolve({permissions:"read"});}); | ||||
|             server = http.createServer(function(req,res){app(req,res)}); | ||||
|             server = stoppable(http.createServer(function(req,res){app(req,res)})); | ||||
|             comms.init(server, { | ||||
|                 settings:{adminAuth:{}}, | ||||
|                 log:{warn:function(){},_:function(){},trace:function(){},audit:function(){}}, | ||||
| @@ -504,9 +507,10 @@ describe("api/editor/comms", function() { | ||||
|                 done(); | ||||
|             }); | ||||
|         }); | ||||
|         after(function() { | ||||
|         after(function(done) { | ||||
|             getDefaultUser.restore(); | ||||
|             comms.stop(); | ||||
|             server.stop(done); | ||||
|         }); | ||||
|  | ||||
|         it('allows anonymous connections that do not authenticate',function(done) { | ||||
|   | ||||
| @@ -52,9 +52,9 @@ describe("api/editor/sshkeys", function() { | ||||
|                     session_data = _session; | ||||
|                     return when.resolve(); | ||||
|                 } | ||||
|             }, | ||||
|             log:{audit:function(){},error:function(msg){errors.push(msg)}} | ||||
|             } | ||||
|         }, | ||||
|         log:{audit:function(){},error:function(msg){errors.push(msg)},trace:function(){}}, | ||||
|         storage: { | ||||
|             projects: { | ||||
|                 ssh: { | ||||
|   | ||||
| @@ -49,7 +49,11 @@ describe("localfilesystem/projects/git/authServer", function() { | ||||
|                 return sendPrompt(rs.path,"Password"); | ||||
|             }).then(function(response) { | ||||
|                 response.should.eql("TEST_PASS"); | ||||
|             }).then(done).catch(function(err) { | ||||
|             }).then(() => { | ||||
|                 rs.close(); | ||||
|                 done(); | ||||
|             }).catch(function(err) { | ||||
|                 rs.close(); | ||||
|                 done(err); | ||||
|             }) | ||||
|  | ||||
| @@ -64,7 +68,11 @@ describe("localfilesystem/projects/git/authServer", function() { | ||||
|                 return sendPrompt(rs.path,"Enter"); | ||||
|             }).then(function(response) { | ||||
|                 response.should.eql("TEST_PASSPHRASE"); | ||||
|             }).then(done).catch(function(err) { | ||||
|             }).then(() => { | ||||
|                 rs.close(); | ||||
|                 done(); | ||||
|             }).catch(function(err) { | ||||
|                 rs.close(); | ||||
|                 done(err); | ||||
|             }) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user