1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge pull request #419 from hindessm/add-credentials-to-test-helper

Add credentials support to node test helper.
This commit is contained in:
Nick O'Leary 2014-10-01 11:13:28 +01:00
commit 322a6ebed3

View File

@ -20,6 +20,7 @@ var request = require('supertest');
var RED = require("../../red/red.js");
var redNodes = require("../../red/nodes");
var flows = require("../../red/nodes/flows");
var credentials = require("../../red/nodes/credentials");
var comms = require("../../red/comms.js");
var http = require('http');
@ -38,7 +39,12 @@ function helperNode(n) {
}
module.exports = {
load: function(testNode, testFlows, cb) {
load: function(testNode, testFlows, testCredentials, cb) {
if (typeof testCredentials === 'function') {
cb = testCredentials;
testCredentials = {};
}
var storage = {
getFlows: function() {
var defer = when.defer();
@ -47,15 +53,19 @@ module.exports = {
},
getCredentials: function() {
var defer = when.defer();
defer.resolve({});
defer.resolve(testCredentials);
return defer.promise;
},
saveCredentials: function() {
// do nothing
},
};
var settings = {
available: function() { return false; }
}
redNodes.init(settings, storage);
credentials.init(storage);
RED.nodes.registerType("helper", helperNode);
testNode(RED);
flows.load().then(function() {
@ -73,6 +83,8 @@ module.exports = {
return flows.get(id);
},
credentials: credentials,
clearFlows: function() {
return flows.clear();
},