mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Add envVarExcludes setting to block named env vars
This commit is contained in:
@@ -50,7 +50,7 @@ describe('flows/util', function() {
|
||||
var foo = {a:"$(foo1)",b:"$(foo2)",c:{d:"$(foo3)"}};
|
||||
for (var p in foo) {
|
||||
if (foo.hasOwnProperty(p)) {
|
||||
flowUtil.mapEnvVarProperties(foo,p);
|
||||
flowUtil.mapEnvVarProperties(foo,p,{getSetting: p => process.env[p]});
|
||||
}
|
||||
}
|
||||
foo.should.eql({ a: 'bar1', b: 'bar2', c: { d: 'bar3' } } );
|
||||
@@ -59,7 +59,7 @@ describe('flows/util', function() {
|
||||
var foo = {a:"${foo1}",b:"${foo2}",c:{d:"${foo3}"}};
|
||||
for (var p in foo) {
|
||||
if (foo.hasOwnProperty(p)) {
|
||||
flowUtil.mapEnvVarProperties(foo,p);
|
||||
flowUtil.mapEnvVarProperties(foo,p,{getSetting: p => process.env[p]});
|
||||
}
|
||||
}
|
||||
foo.should.eql({ a: 'bar1', b: 'bar2', c: { d: 'bar3' } } );
|
||||
@@ -77,6 +77,27 @@ describe('flows/util', function() {
|
||||
foo.should.eql({ a: '$(unknown)', b: 'FOO2', c: { d: 'FOO3' } } );
|
||||
});
|
||||
});
|
||||
describe('#getEnvVar',function() {
|
||||
before(function() {
|
||||
process.env.foo1 = "bar1";
|
||||
})
|
||||
after(function() {
|
||||
delete process.env.foo1;
|
||||
})
|
||||
it('returns a known env var', function() {
|
||||
flowUtil.init({settings:{}});
|
||||
flowUtil.getEnvVar("foo1").should.equal("bar1")
|
||||
})
|
||||
it('returns undefined for an unknown env var', function() {
|
||||
flowUtil.init({settings:{}});
|
||||
(flowUtil.getEnvVar("foo2") === undefined).should.be.true()
|
||||
})
|
||||
it('returns undefined for an excluded env var', function() {
|
||||
flowUtil.init({settings:{envVarExcludes:['foo1']}});
|
||||
(flowUtil.getEnvVar("foo1") === undefined).should.be.true()
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
describe('#diffNodes',function() {
|
||||
it('handles a null old node', function() {
|
||||
|
@@ -31,17 +31,18 @@ describe("red/nodes/index", function() {
|
||||
before(function() {
|
||||
sinon.stub(index,"startFlows");
|
||||
process.env.NODE_RED_HOME = NR_TEST_UTILS.resolve("node-red");
|
||||
process.env.foo="bar";
|
||||
});
|
||||
after(function() {
|
||||
index.startFlows.restore();
|
||||
delete process.env.NODE_RED_HOME;
|
||||
delete process.env.foo;
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
index.clearRegistry();
|
||||
});
|
||||
|
||||
process.env.foo="bar";
|
||||
var testFlows = [{"type":"test","id":"tab1","label":"Sheet 1"}];
|
||||
var testCredentials = {"tab1":{"b":1, "c":"2", "d":"$(foo)"}};
|
||||
var storage = {
|
||||
@@ -68,8 +69,8 @@ describe("red/nodes/index", function() {
|
||||
};
|
||||
|
||||
function TestNode(n) {
|
||||
this._flow = {getSetting: p => process.env[p]};
|
||||
index.createNode(this, n);
|
||||
var node = this;
|
||||
this.on("log", function() {
|
||||
// do nothing
|
||||
});
|
||||
|
Reference in New Issue
Block a user