mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Add /settings/user end point
This commit is contained in:
@@ -24,7 +24,6 @@ var auth = require("../../../../red/api/auth");
|
||||
var nodes = require("../../../../red/api/admin/nodes");
|
||||
var flows = require("../../../../red/api/admin/flows");
|
||||
var flow = require("../../../../red/api/admin/flow");
|
||||
var info = require("../../../../red/api/admin/info");
|
||||
|
||||
/**
|
||||
* Ensure all API routes are correctly mounted, with the expected permissions checks
|
||||
@@ -33,7 +32,7 @@ describe("api/admin/index", function() {
|
||||
describe("Ensure all API routes are correctly mounted, with the expected permissions checks", function() {
|
||||
var app;
|
||||
var mockList = [
|
||||
flows,flow,info,nodes
|
||||
flows,flow,nodes
|
||||
]
|
||||
var permissionChecks = {};
|
||||
var lastRequest;
|
||||
@@ -68,8 +67,6 @@ describe("api/admin/index", function() {
|
||||
sinon.stub(nodes,"getSet",stubApp);
|
||||
sinon.stub(nodes,"putSet",stubApp);
|
||||
|
||||
sinon.stub(info,"settings",stubApp);
|
||||
|
||||
});
|
||||
after(function() {
|
||||
mockList.forEach(function(m) {
|
||||
@@ -91,7 +88,6 @@ describe("api/admin/index", function() {
|
||||
nodes.getSet.restore();
|
||||
nodes.putSet.restore();
|
||||
|
||||
info.settings.restore();
|
||||
});
|
||||
|
||||
before(function() {
|
||||
@@ -285,15 +281,5 @@ describe("api/admin/index", function() {
|
||||
done();
|
||||
})
|
||||
});
|
||||
|
||||
it('GET /settings', function(done) {
|
||||
request(app).get("/settings").expect(200).end(function(err,res) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
permissionChecks.should.have.property('settings.read',1);
|
||||
done();
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -20,6 +20,7 @@ var request = require("supertest");
|
||||
var express = require("express");
|
||||
var editorApi = require("../../../../red/api/editor");
|
||||
var comms = require("../../../../red/api/editor/comms");
|
||||
var info = require("../../../../red/api/editor/settings");
|
||||
|
||||
|
||||
describe("api/editor/index", function() {
|
||||
@@ -27,9 +28,11 @@ describe("api/editor/index", function() {
|
||||
describe("disabled the editor", function() {
|
||||
beforeEach(function() {
|
||||
sinon.stub(comms,'init', function(){});
|
||||
sinon.stub(info,'init', function(){});
|
||||
});
|
||||
afterEach(function() {
|
||||
comms.init.restore();
|
||||
info.init.restore();
|
||||
});
|
||||
it("disables the editor", function() {
|
||||
var editorApp = editorApi.init({},{
|
||||
@@ -37,6 +40,7 @@ describe("api/editor/index", function() {
|
||||
});
|
||||
should.not.exist(editorApp);
|
||||
comms.init.called.should.be.false();
|
||||
info.init.called.should.be.false();
|
||||
});
|
||||
});
|
||||
describe("enables the editor", function() {
|
||||
@@ -61,9 +65,10 @@ describe("api/editor/index", function() {
|
||||
before(function() {
|
||||
app = editorApi.init({},{
|
||||
log:{audit:function(){},error:function(msg){errors.push(msg)}},
|
||||
settings:{httpNodeRoot:true, httpAdminRoot: true,disableEditor:false},
|
||||
settings:{httpNodeRoot:true, httpAdminRoot: true,disableEditor:false,exportNodeSettings:function(){}},
|
||||
events:{on:function(){},removeListener:function(){}},
|
||||
isStarted: function() { return isStarted; }
|
||||
isStarted: function() { return isStarted; },
|
||||
nodes: {paletteEditorEnabled: function() { return false }}
|
||||
});
|
||||
});
|
||||
it('serves the editor', function(done) {
|
||||
@@ -105,5 +110,14 @@ describe("api/editor/index", function() {
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('GET /settings', function(done) {
|
||||
request(app).get("/settings").expect(200).end(function(err,res) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
// permissionChecks.should.have.property('settings.read',1);
|
||||
done();
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -21,15 +21,15 @@ var sinon = require('sinon');
|
||||
var when = require('when');
|
||||
|
||||
var app = express();
|
||||
var info = require("../../../../red/api/admin/info");
|
||||
var info = require("../../../../red/api/editor/settings");
|
||||
var theme = require("../../../../red/api/editor/theme");
|
||||
|
||||
describe("api/admin/info", function() {
|
||||
describe("api/editor/settings", function() {
|
||||
describe("settings handler", function() {
|
||||
before(function() {
|
||||
sinon.stub(theme,"settings",function() { return { test: 456 };});
|
||||
app = express();
|
||||
app.get("/settings",info.settings);
|
||||
app.get("/settings",info.runtimeSettings);
|
||||
});
|
||||
|
||||
after(function() {
|
||||
@@ -49,7 +49,8 @@ describe("api/admin/info", function() {
|
||||
},
|
||||
nodes: {
|
||||
paletteEditorEnabled: function() { return true; }
|
||||
}
|
||||
},
|
||||
log: { error: console.error }
|
||||
});
|
||||
request(app)
|
||||
.get("/settings")
|
||||
@@ -78,7 +79,8 @@ describe("api/admin/info", function() {
|
||||
},
|
||||
nodes: {
|
||||
paletteEditorEnabled: function() { return false; }
|
||||
}
|
||||
},
|
||||
log: { error: console.error }
|
||||
});
|
||||
request(app)
|
||||
.get("/settings")
|
Reference in New Issue
Block a user