mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add credentials support to node test helper.
This commit is contained in:
parent
a5265784e8
commit
059ec3b50c
@ -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();
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user