mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Merge 0.18.5
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
|
||||
var should = require("should");
|
||||
var sentimentNode = require("../../../../nodes/core/analysis/72-sentiment.js");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
|
||||
describe('sentiment Node', function() {
|
||||
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
var should = require("should");
|
||||
var injectNode = require("../../../../nodes/core/core/20-inject.js");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
|
||||
describe('inject node', function() {
|
||||
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
var should = require("should");
|
||||
var catchNode = require("../../../../nodes/core/core/25-catch.js");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
|
||||
describe('catch Node', function() {
|
||||
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
var should = require("should");
|
||||
var catchNode = require("../../../../nodes/core/core/25-status.js");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
|
||||
describe('status Node', function() {
|
||||
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
var should = require("should");
|
||||
var debugNode = require("../../../../nodes/core/core/58-debug.js");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
var WebSocket = require('ws');
|
||||
|
||||
describe('debug node', function() {
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
var should = require("should");
|
||||
var linkNode = require("../../../../nodes/core/core/60-link.js");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
|
||||
describe('link Node', function() {
|
||||
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
var should = require("should");
|
||||
var sinon = require("sinon");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
var execNode = require("../../../../nodes/core/core/75-exec.js");
|
||||
var osType = require("os").type();
|
||||
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
var should = require("should");
|
||||
var functionNode = require("../../../../nodes/core/core/80-function.js");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
|
||||
describe('function node', function() {
|
||||
|
||||
@@ -242,7 +242,7 @@ describe('function node', function() {
|
||||
});
|
||||
|
||||
it('should handle and log script error', function(done) {
|
||||
var flow = [{id:"n1",type:"function",wires:[["n2"]],func:"retunr"}];
|
||||
var flow = [{id:"n1",type:"function",wires:[["n2"]],func:"var a = 1;\nretunr"}];
|
||||
helper.load(functionNode, flow, function() {
|
||||
var n1 = helper.getNode("n1");
|
||||
n1.receive({payload:"foo",topic: "bar"});
|
||||
@@ -256,7 +256,7 @@ describe('function node', function() {
|
||||
msg.should.have.property('level', helper.log().ERROR);
|
||||
msg.should.have.property('id', 'n1');
|
||||
msg.should.have.property('type', 'function');
|
||||
msg.should.have.property('msg', 'ReferenceError: retunr is not defined (line 1, col 1)');
|
||||
msg.should.have.property('msg', 'ReferenceError: retunr is not defined (line 2, col 1)');
|
||||
done();
|
||||
} catch(err) {
|
||||
done(err);
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
var should = require("should");
|
||||
var templateNode = require("../../../../nodes/core/core/80-template.js");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
|
||||
describe('template node', function() {
|
||||
|
||||
|
@@ -17,7 +17,7 @@
|
||||
var should = require("should");
|
||||
|
||||
var delayNode = require("../../../../nodes/core/core/89-delay.js");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
|
||||
var GRACE_PERCENTAGE=10;
|
||||
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
var should = require("should");
|
||||
var sinon = require("sinon");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
var triggerNode = require("../../../../nodes/core/core/89-trigger.js");
|
||||
var RED = require("../../../../red/red.js");
|
||||
|
||||
@@ -419,7 +419,7 @@ describe('trigger node', function() {
|
||||
});
|
||||
|
||||
it('should be able to extend the delay (but with no 2nd output)', function(done) {
|
||||
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", extend:"true", op1type:"pay", op2type:"nul", op1:"false", op2:"true", duration:"50", wires:[["n2"]] },
|
||||
var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", extend:"true", op1type:"pay", op2type:"nul", op1:"false", op2:"true", duration:"100", wires:[["n2"]] },
|
||||
{id:"n2", type:"helper"} ];
|
||||
helper.load(triggerNode, flow, function() {
|
||||
var n1 = helper.getNode("n1");
|
||||
@@ -434,7 +434,7 @@ describe('trigger node', function() {
|
||||
else {
|
||||
msg.should.have.a.property("payload", "World");
|
||||
//console.log(Date.now() - ss);
|
||||
(Date.now() - ss).should.be.greaterThan(70);
|
||||
(Date.now() - ss).should.be.greaterThan(140);
|
||||
done();
|
||||
}
|
||||
}
|
||||
@@ -447,7 +447,7 @@ describe('trigger node', function() {
|
||||
},20);
|
||||
setTimeout( function() {
|
||||
n1.emit("input", {payload:"World"});
|
||||
},80);
|
||||
},150);
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
var should = require("should");
|
||||
var commentNode = require("../../../../nodes/core/core/90-comment.js");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
|
||||
describe('comment Node', function() {
|
||||
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
var should = require("should");
|
||||
var unknown = require("../../../../nodes/core/core/98-unknown.js");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
|
||||
describe('unknown Node', function() {
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -17,7 +17,7 @@
|
||||
var ws = require("ws");
|
||||
var when = require("when");
|
||||
var should = require("should");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
var websocketNode = require("../../../../nodes/core/io/22-websocket.js");
|
||||
|
||||
var sockets = [];
|
||||
|
@@ -17,7 +17,7 @@
|
||||
var fs = require("fs-extra");
|
||||
var path = require("path");
|
||||
var should = require("should");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
var watchNode = require("../../../../nodes/core/io/23-watch.js");
|
||||
|
||||
|
||||
|
@@ -17,7 +17,8 @@
|
||||
var net = require("net");
|
||||
var should = require("should");
|
||||
var stoppable = require('stoppable');
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
|
||||
var tcpinNode = require("../../../../nodes/core/io/31-tcpin.js");
|
||||
|
||||
|
||||
@@ -46,7 +47,7 @@ describe('TCP in Node', function() {
|
||||
sock.end();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function startServer(done) {
|
||||
server_port += 1;
|
||||
server = stoppable(net.createServer(function(c) {
|
||||
@@ -59,7 +60,7 @@ describe('TCP in Node', function() {
|
||||
function stopServer(done) {
|
||||
server.stop(done);
|
||||
}
|
||||
|
||||
|
||||
function send(wdata) {
|
||||
var opt = {port:port, host:"localhost"};
|
||||
var client = net.createConnection(opt, function() {
|
||||
|
@@ -17,7 +17,7 @@
|
||||
var net = require("net");
|
||||
var should = require("should");
|
||||
var stoppable = require('stoppable');
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
var tcpinNode = require("../../../../nodes/core/io/31-tcpin.js");
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ describe('TCP Request Node', function() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
it('should send & recv data', function(done) {
|
||||
var flow = [{id:"n1", type:"tcp request", server:"localhost", port:port, out:"time", splitc: "0", wires:[["n2"]] },
|
||||
{id:"n2", type:"helper"}];
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
var dgram = require("dgram");
|
||||
var should = require("should");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
var udpNode = require("../../../../nodes/core/io/32-udp.js");
|
||||
|
||||
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
var dgram = require("dgram");
|
||||
var should = require("should");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
var udpNode = require("../../../../nodes/core/io/32-udp.js");
|
||||
|
||||
|
||||
|
@@ -17,7 +17,7 @@
|
||||
var should = require("should");
|
||||
|
||||
var switchNode = require("../../../../nodes/core/logic/10-switch.js");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
var RED = require("../../../../red/red.js");
|
||||
|
||||
describe('switch Node', function() {
|
||||
@@ -103,7 +103,7 @@ describe('switch Node', function() {
|
||||
helperNode1.on("input", function(msg) {
|
||||
try {
|
||||
if (shouldReceive === true) {
|
||||
msg.payload.should.equal(sendPayload);
|
||||
should.equal(msg.payload,sendPayload);
|
||||
done();
|
||||
} else {
|
||||
should.fail(null, null, "We should never get an input!");
|
||||
@@ -168,8 +168,6 @@ describe('switch Node', function() {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
it('should check if payload equals given value', function(done) {
|
||||
genericSwitchTest("eq", "Hello", true, true, "Hello", done);
|
||||
});
|
||||
@@ -258,6 +256,43 @@ describe('switch Node', function() {
|
||||
genericSwitchTest("regex", "[abc]+", true, true, "abbabac", done);
|
||||
});
|
||||
|
||||
it('should check if payload if of type string ', function(done) {
|
||||
genericSwitchTest("istype", "string", true, true, "Hello", done);
|
||||
});
|
||||
it('should check if payload if of type number ', function(done) {
|
||||
genericSwitchTest("istype", "number", true, true, 999, done);
|
||||
});
|
||||
it('should check if payload if of type number 0', function(done) {
|
||||
genericSwitchTest("istype", "number", true, true, 0, done);
|
||||
});
|
||||
it('should check if payload if of type boolean true', function(done) {
|
||||
genericSwitchTest("istype", "boolean", true, true, true, done);
|
||||
});
|
||||
it('should check if payload if of type boolean false', function(done) {
|
||||
genericSwitchTest("istype", "boolean", true, true, true, done);
|
||||
});
|
||||
it('should check if payload if of type array ', function(done) {
|
||||
genericSwitchTest("istype", "array", true, true, [1,2,3,"a","b"], done);
|
||||
});
|
||||
it('should check if payload if of type buffer ', function(done) {
|
||||
genericSwitchTest("istype", "buffer", true, true, Buffer.from("Hello"), done);
|
||||
});
|
||||
it('should check if payload if of type object ', function(done) {
|
||||
genericSwitchTest("istype", "object", true, true, {a:1,b:"b",c:true}, done);
|
||||
});
|
||||
it('should check if payload if of type JSON string ', function(done) {
|
||||
genericSwitchTest("istype", "json", true, true, JSON.stringify({a:1,b:"b",c:true}), done);
|
||||
});
|
||||
it('should check if payload if of type JSON string (and fail if not) ', function(done) {
|
||||
genericSwitchTest("istype", "json", true, false, "Hello", done);
|
||||
});
|
||||
it('should check if payload if of type null', function(done) {
|
||||
genericSwitchTest("istype", "null", true, true, null, done);
|
||||
});
|
||||
it('should check if payload if of type undefined', function(done) {
|
||||
genericSwitchTest("istype", "undefined", true, true, undefined, done);
|
||||
});
|
||||
|
||||
it('should match regex with ignore-case flag set true', function(done) {
|
||||
var flow = [{id:"switchNode1",type:"switch",name:"switchNode",property:"payload",rules:[{"t":"regex","v":"onetwothree","case":true}],checkall:true,outputs:1,wires:[["helperNode1"]]},
|
||||
{id:"helperNode1", type:"helper", wires:[]}];
|
||||
@@ -433,7 +468,6 @@ describe('switch Node', function() {
|
||||
var flow = [{id:"switchNode1",type:"switch",name:"switchNode",property:"payload",rules:[{"t":"nnull"}],checkall:false,outputs:1,wires:[["helperNode1"]]},
|
||||
{id:"helperNode1", type:"helper", wires:[]}];
|
||||
|
||||
|
||||
helper.load(switchNode, flow, function() {
|
||||
var switchNode1 = helper.getNode("switchNode1");
|
||||
var helperNode1 = helper.getNode("helperNode1");
|
||||
@@ -787,5 +821,4 @@ describe('switch Node', function() {
|
||||
n1.receive({payload:1, parts:{index:0, count:4, id:222}});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
@@ -17,7 +17,7 @@
|
||||
var should = require("should");
|
||||
|
||||
var changeNode = require("../../../../nodes/core/logic/15-change.js");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
|
||||
describe('change Node', function() {
|
||||
|
||||
|
@@ -17,7 +17,7 @@
|
||||
var should = require("should");
|
||||
|
||||
var rangeNode = require("../../../../nodes/core/logic/16-range.js");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
|
||||
describe('range Node', function() {
|
||||
|
||||
|
@@ -17,7 +17,7 @@
|
||||
var should = require("should");
|
||||
var splitNode = require("../../../../nodes/core/logic/17-split.js");
|
||||
var joinNode = require("../../../../nodes/core/logic/17-split.js");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
var RED = require("../../../../red/red.js");
|
||||
|
||||
describe('SPLIT node', function() {
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
var should = require("should");
|
||||
var sortNode = require("../../../../nodes/core/logic/18-sort.js");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
var RED = require("../../../../red/red.js");
|
||||
|
||||
describe('SORT node', function() {
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
var should = require("should");
|
||||
var batchNode = require("../../../../nodes/core/logic/19-batch.js");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
var RED = require("../../../../red/red.js");
|
||||
|
||||
describe('BATCH node', function() {
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
var should = require("should");
|
||||
var csvNode = require("../../../../nodes/core/parsers/70-CSV.js");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
|
||||
describe('CSV node', function() {
|
||||
|
||||
|
@@ -19,7 +19,7 @@ var path = require("path");
|
||||
var fs = require('fs-extra');
|
||||
|
||||
var htmlNode = require("../../../../nodes/core/parsers/70-HTML.js");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
|
||||
describe('html node', function() {
|
||||
|
||||
@@ -69,7 +69,7 @@ describe('html node', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should retrieve header contents if asked to by msg.select - alternative property', function(done) {
|
||||
it('should retrieve header contents if asked to by msg.select - alternative in property', function(done) {
|
||||
fs.readFile(file, 'utf8', function(err, data) {
|
||||
var flow = [{id:"n1",type:"html",property:"foo",wires:[["n2"]],func:"return msg;"},
|
||||
{id:"n2", type:"helper"}];
|
||||
@@ -79,7 +79,7 @@ describe('html node', function() {
|
||||
var n2 = helper.getNode("n2");
|
||||
n2.on("input", function(msg) {
|
||||
msg.should.have.property('topic', 'bar');
|
||||
should.equal(msg.foo, 'This is a test page for node 70-HTML');
|
||||
msg.foo[0].should.equal('This is a test page for node 70-HTML');
|
||||
done();
|
||||
});
|
||||
n1.receive({foo:data,topic:"bar",select:"h1"});
|
||||
@@ -87,6 +87,24 @@ describe('html node', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should retrieve header contents if asked to by msg.select - alternative in and out properties', function(done) {
|
||||
fs.readFile(file, 'utf8', function(err, data) {
|
||||
var flow = [{id:"n1",type:"html",property:"foo",outproperty:"bar",tag:"h1",wires:[["n2"]],func:"return msg;"},
|
||||
{id:"n2", type:"helper"}];
|
||||
|
||||
helper.load(htmlNode, flow, function() {
|
||||
var n1 = helper.getNode("n1");
|
||||
var n2 = helper.getNode("n2");
|
||||
n2.on("input", function(msg) {
|
||||
msg.should.have.property('topic', 'bar');
|
||||
msg.bar[0].should.equal('This is a test page for node 70-HTML');
|
||||
done();
|
||||
});
|
||||
n1.receive({foo:data,topic:"bar"});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should emit an empty array if no matching elements', function(done) {
|
||||
fs.readFile(file, 'utf8', function(err, data) {
|
||||
var flow = [{id:"n1",type:"html",wires:[["n2"]],func:"return msg;"},
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
var should = require("should");
|
||||
var jsonNode = require("../../../../nodes/core/parsers/70-JSON.js");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
|
||||
describe('JSON node', function() {
|
||||
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
var should = require("should");
|
||||
var xmlNode = require("../../../../nodes/core/parsers/70-XML.js");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
|
||||
describe('XML node', function() {
|
||||
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
var should = require("should");
|
||||
var yamlNode = require("../../../../nodes/core/parsers/70-YAML.js");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
|
||||
describe('YAML node', function() {
|
||||
|
||||
|
@@ -20,7 +20,7 @@ var os = require('os');
|
||||
var fs = require('fs-extra');
|
||||
var sinon = require('sinon');
|
||||
var tailNode = require("../../../../nodes/core/storage/28-tail.js");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
|
||||
describe('tail Node', function() {
|
||||
|
||||
|
@@ -20,7 +20,7 @@ var fs = require('fs-extra');
|
||||
var os = require('os');
|
||||
var sinon = require("sinon");
|
||||
var fileNode = require("../../../../nodes/core/storage/50-file.js");
|
||||
var helper = require("../../helper.js");
|
||||
var helper = require("node-red-node-test-helper");
|
||||
|
||||
describe('file Nodes', function() {
|
||||
|
||||
|
@@ -1,169 +0,0 @@
|
||||
/**
|
||||
* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
var should = require("should");
|
||||
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
|
||||
try {
|
||||
nock = require('nock');
|
||||
} catch (err) {
|
||||
// nevermind, will skip nock tests
|
||||
nock = null;
|
||||
}
|
||||
}
|
||||
var RED = require("../../red/red.js");
|
||||
var redNodes = require("../../red/runtime/nodes");
|
||||
var flows = require("../../red/runtime/nodes/flows");
|
||||
var credentials = require("../../red/runtime/nodes/credentials");
|
||||
var comms = require("../../red/api/editor/comms.js");
|
||||
var log = require("../../red/util/log.js");
|
||||
var context = require("../../red/runtime/nodes/context.js");
|
||||
var events = require("../../red/runtime/events.js");
|
||||
|
||||
var http = require('http');
|
||||
var express = require('express');
|
||||
var app = express();
|
||||
|
||||
var address = '127.0.0.1';
|
||||
var listenPort = 0; // use ephemeral port
|
||||
var port;
|
||||
var url;
|
||||
var logSpy;
|
||||
var server;
|
||||
|
||||
function helperNode(n) {
|
||||
RED.nodes.createNode(this, n);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
load: function(testNode, testFlows, testCredentials, cb) {
|
||||
var i;
|
||||
|
||||
logSpy = sinon.spy(log,"log");
|
||||
logSpy.FATAL = log.FATAL;
|
||||
logSpy.ERROR = log.ERROR;
|
||||
logSpy.WARN = log.WARN;
|
||||
logSpy.INFO = log.INFO;
|
||||
logSpy.DEBUG = log.DEBUG;
|
||||
logSpy.TRACE = log.TRACE;
|
||||
logSpy.METRIC = log.METRIC;
|
||||
|
||||
if (typeof testCredentials === 'function') {
|
||||
cb = testCredentials;
|
||||
testCredentials = {};
|
||||
}
|
||||
|
||||
var storage = {
|
||||
getFlows: function() {
|
||||
return when.resolve({flows:testFlows,credentials:testCredentials});
|
||||
}
|
||||
};
|
||||
|
||||
var settings = {
|
||||
available: function() { return false; }
|
||||
};
|
||||
|
||||
var red = {};
|
||||
for (i in RED) {
|
||||
if (RED.hasOwnProperty(i) && !/^(init|start|stop)$/.test(i)) {
|
||||
var propDescriptor = Object.getOwnPropertyDescriptor(RED,i);
|
||||
Object.defineProperty(red,i,propDescriptor);
|
||||
}
|
||||
}
|
||||
|
||||
red["_"] = function(messageId) {
|
||||
return messageId;
|
||||
};
|
||||
|
||||
redNodes.init({events:events,settings:settings, storage:storage,log:log,});
|
||||
RED.nodes.registerType("helper", helperNode);
|
||||
if (Array.isArray(testNode)) {
|
||||
for (i = 0; i < testNode.length; i++) {
|
||||
testNode[i](red);
|
||||
}
|
||||
} else {
|
||||
testNode(red);
|
||||
}
|
||||
flows.load().then(function() {
|
||||
flows.startFlows();
|
||||
should.deepEqual(testFlows, flows.getFlows().flows);
|
||||
cb();
|
||||
});
|
||||
},
|
||||
|
||||
unload: function() {
|
||||
// TODO: any other state to remove between tests?
|
||||
redNodes.clearRegistry();
|
||||
logSpy.restore();
|
||||
context.clean({allNodes:[]});
|
||||
return flows.stopFlows();
|
||||
},
|
||||
|
||||
getNode: function(id) {
|
||||
return flows.get(id);
|
||||
},
|
||||
|
||||
credentials: credentials,
|
||||
|
||||
clearFlows: function() {
|
||||
return flows.stopFlows();
|
||||
},
|
||||
|
||||
request: function() {
|
||||
return request(RED.httpAdmin);
|
||||
},
|
||||
|
||||
startServer: function(done) {
|
||||
server = stoppable(http.createServer(function(req,res) { app(req,res); }), 0);
|
||||
RED.init(server, {
|
||||
SKIP_BUILD_CHECK: true,
|
||||
logging:{console:{level:'off'}}
|
||||
});
|
||||
server.listen(listenPort, address);
|
||||
server.on('listening', function() {
|
||||
port = server.address().port;
|
||||
url = 'http://' + address + ':' + port;
|
||||
comms.start();
|
||||
done();
|
||||
});
|
||||
},
|
||||
|
||||
//TODO consider saving TCP handshake/server reinit on start/stop/start sequences
|
||||
stopServer: function(done) {
|
||||
if (server) {
|
||||
try {
|
||||
comms.stop();
|
||||
server.stop(done);
|
||||
} catch(e) {
|
||||
done();
|
||||
}
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
},
|
||||
|
||||
url: function() { return url; },
|
||||
|
||||
nock: nock,
|
||||
|
||||
log: function() { return logSpy;}
|
||||
};
|
@@ -45,6 +45,28 @@ describe("runtime-api/settings", function() {
|
||||
|
||||
|
||||
/*
|
||||
|
||||
before(function() {
|
||||
sinon.stub(theme,"settings",function() { return { test: 456 };});
|
||||
app = express();
|
||||
app.get("/settings",info.runtimeSettings);
|
||||
app.get("/settingsWithUser",function(req,res,next) {
|
||||
req.user = {
|
||||
username: "nick",
|
||||
permissions: "*",
|
||||
image: "http://example.com",
|
||||
anonymous: false,
|
||||
private: "secret"
|
||||
}
|
||||
next();
|
||||
},info.runtimeSettings);
|
||||
});
|
||||
after(function() {
|
||||
theme.settings.restore();
|
||||
});
|
||||
|
||||
|
||||
|
||||
it('returns the filtered settings', function(done) {
|
||||
info.init({
|
||||
settings: {
|
||||
@@ -77,6 +99,42 @@ describe("runtime-api/settings", function() {
|
||||
res.body.should.have.property("testNodeSetting","helloWorld");
|
||||
res.body.should.not.have.property("foo",123);
|
||||
res.body.should.have.property("flowEncryptionType","test-key-type");
|
||||
res.body.should.not.have.property("user");
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('returns the filtered user in settings', function(done) {
|
||||
info.init({
|
||||
settings: {
|
||||
foo: 123,
|
||||
httpNodeRoot: "testHttpNodeRoot",
|
||||
version: "testVersion",
|
||||
paletteCategories :["red","blue","green"],
|
||||
exportNodeSettings: function(obj) {
|
||||
obj.testNodeSetting = "helloWorld";
|
||||
}
|
||||
},
|
||||
nodes: {
|
||||
paletteEditorEnabled: function() { return true; },
|
||||
getCredentialKeyType: function() { return "test-key-type"}
|
||||
},
|
||||
log: { error: console.error },
|
||||
storage: {}
|
||||
});
|
||||
request(app)
|
||||
.get("/settingsWithUser")
|
||||
.expect(200)
|
||||
.end(function(err,res) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
res.body.should.have.property("user");
|
||||
res.body.user.should.have.property("username","nick");
|
||||
res.body.user.should.have.property("permissions","*");
|
||||
res.body.user.should.have.property("image","http://example.com");
|
||||
res.body.user.should.have.property("anonymous",false);
|
||||
res.body.user.should.not.have.property("private");
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
20
test/resources/ssl/server.crt
Normal file
20
test/resources/ssl/server.crt
Normal file
@@ -0,0 +1,20 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDMDCCAhgCCQDPGPyu5M6ZaDANBgkqhkiG9w0BAQsFADBZMQswCQYDVQQGEwJB
|
||||
VTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0
|
||||
cyBQdHkgTHRkMRIwEAYDVQQDDAlsb2NhbGhvc3QwIBcNMTgwMzE2MDY0ODU1WhgP
|
||||
MjExODAyMjAwNjQ4NTVaMFkxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0
|
||||
YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxEjAQBgNVBAMM
|
||||
CWxvY2FsaG9zdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMifGelM
|
||||
k/b3HeIj98y9P5jS+Qblqpq7+gsCaL+qglMFmG0QXe6Ordkrh3xeY0uTkaFatwLM
|
||||
WMzoX60nNdaVjC9U9RlQLK/3nncCveexxRUGtI8VpxN04ivBE/ULhtJeStQFrfyt
|
||||
LWr1WWf8o8P/EWzZnh0Y1oHc0XqhOPHu9Nfd9kn5nfHNd/xbY8KXa4DkVSJ1lLFK
|
||||
3t/nSWttchF8zKgNpoQznNGqUTjT28l0sS8fyH76DyRj3Ke6xdNxX2NRUU0PnGFI
|
||||
RMsBG4Qrzo5xY7lQP7uVVgZUlxryw+NuZuC1PBXaUKJOf6CGwrTq5WB9zF1iBZCs
|
||||
wD68NvtLd0kHEgECAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAfqNOg2v90r5x4lFo
|
||||
SYmPUoX24gdwHd/mfCzDJksB8n98X1eULYZqqRF2Q7LMkYu/twxfR3EKQX1HZxQY
|
||||
LpGUYX4ubJdVTy13opJs8B4NkhvRuOAP0+b7RVt4RfuxLX9tYOB98tEbf7Mj0ccq
|
||||
F4sHi+PMCh64K7rNWECHar0F51yNtNXcxJPMuHZVmj0/U7h6ZxNf+GzdTi8YKmVy
|
||||
5OHI7xol/II/v3QOi1L+BaEIUkqYODKuQouJVIzu4zX6JRfAaxwjJmliYoJm7OEY
|
||||
dFMEQUw1Ggsos+KbkGi9mCDbveYpWcZTR8nfPwmx+oJtt47DTHUC3KSdRxgtfjGs
|
||||
otmVSw==
|
||||
-----END CERTIFICATE-----
|
27
test/resources/ssl/server.key
Normal file
27
test/resources/ssl/server.key
Normal file
@@ -0,0 +1,27 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEowIBAAKCAQEAyJ8Z6UyT9vcd4iP3zL0/mNL5BuWqmrv6CwJov6qCUwWYbRBd
|
||||
7o6t2SuHfF5jS5ORoVq3AsxYzOhfrSc11pWML1T1GVAsr/eedwK957HFFQa0jxWn
|
||||
E3TiK8ET9QuG0l5K1AWt/K0tavVZZ/yjw/8RbNmeHRjWgdzReqE48e701932Sfmd
|
||||
8c13/FtjwpdrgORVInWUsUre3+dJa21yEXzMqA2mhDOc0apRONPbyXSxLx/IfvoP
|
||||
JGPcp7rF03FfY1FRTQ+cYUhEywEbhCvOjnFjuVA/u5VWBlSXGvLD425m4LU8FdpQ
|
||||
ok5/oIbCtOrlYH3MXWIFkKzAPrw2+0t3SQcSAQIDAQABAoIBAGmbryUrpZxU24tG
|
||||
idRiLw9Ax8yEq7lGiMqw2vlCRdZ0VJfdDMVeoE945ZpniXeoV/oLadl0Pq6nCG56
|
||||
/JFYKfJkk51eoheDjwxxCgzkfK2j2PqVWF0ao1CLE/ljtvYYouVXlA42D3mFbCoc
|
||||
SQ0MwVx+dgg1If48gp0+L17T/ll/VOOQumts5UzoKC8YABLL00g5ZL9/jZlVipgl
|
||||
HfENMPWOfy3q5kSgQqvTWTMdSE6644ryV890mrwcC/RzqQBSNgRh1Lqx3jcXQSdN
|
||||
x5C19gEK60hZqcvzBkKYudMHUC6I0lcuao1xwBnHUQIVKmLFPZBUIQq3tVar/YUc
|
||||
d65cJpECgYEA5D9QilQpHxv875wBvBOEbyt9TqDBBN/5JpGQ9sBKpA0eNp3UzrOr
|
||||
+n0TlyoDZYjkxgNJScS4TpeKde1Hk5j2kkMngjS69dn4G6wmOI79gAOGrCiJd1/I
|
||||
AWb09KxUKlWBbfKuLHdl1wSMCYQornDdXxYCxhv9sMZKbEJ//tsI420CgYEA4QPf
|
||||
n/dRAm+6zwNQTWOYWlj5jsG1TilBBCtoRqUqVlrAgR6rS1lgOleHkVrWH0g0Lkmh
|
||||
9DxWiWuNNXxdU/5zx9AQn/JuHuL8EjDLN5r7idcg2LtEElCkr12y0I9nzS2OOZnj
|
||||
MTioIh+hghzNuk09NlVJrHi48bJUVL/6Ws7ruGUCgYBT9UJAD+MscVQiI2Wz9A30
|
||||
ArBOOu2lSGnSmRsU2PjbzYN+naIJAqhRNK7/HNIxCCD3AYB05SrSpgWliUmZ7ltM
|
||||
w+0FhTX8d1g/fZx1k4uGCkYAj8y5H39nnKKgWb9/7wH0Gp+c9bJ9XEvSuE1qlVOo
|
||||
xWTx0JwJ6Xa4yeFhMtrbJQKBgF/FfErjwvEciRBPQsCNoWzi7eUbAYYw/OE/cHSR
|
||||
HAIBQmoymYnKkrCCTMtLNFPAMaV55ZrEi7iVtFaNhlOXu8PSBSFu1/wBdHRxnC0g
|
||||
o+s5S1uz6Pc6p72UTeWDBBVKTHyryQ1MJhPQDrgIdm/TLDiR+HeWMnF9C3O++lno
|
||||
NGAZAoGBAKhsmatxVD9B3jvUDd/CWhXVDSZQECrfJ+Uy1q6b5NO5yMibpIZv14Nj
|
||||
VT+b2qXoO1wL6htTRJXXNPmrB/JtrLiLg/vxVuA7CPSgot8SDA+/lbRhf1n/SKnD
|
||||
ECXrEUmq28SgBItbY4vcy5PVEHRvlzqO/LpD6Y7iGNpR7zw9Yk3b
|
||||
-----END RSA PRIVATE KEY-----
|
Reference in New Issue
Block a user