mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Initial projects implementation
This commit is contained in:
@@ -23,7 +23,7 @@ var when = require('when');
|
||||
|
||||
var flow = require("../../../../red/api/admin/flow");
|
||||
|
||||
describe("flow api", function() {
|
||||
describe("api/admin/flow", function() {
|
||||
|
||||
var app;
|
||||
|
||||
|
@@ -23,7 +23,7 @@ var when = require('when');
|
||||
|
||||
var flows = require("../../../../red/api/admin/flows");
|
||||
|
||||
describe("flows api", function() {
|
||||
describe("api/admin/flows", function() {
|
||||
|
||||
var app;
|
||||
|
||||
|
@@ -24,7 +24,7 @@ var app = express();
|
||||
var info = require("../../../../red/api/admin/info");
|
||||
var theme = require("../../../../red/api/editor/theme");
|
||||
|
||||
describe("info api", function() {
|
||||
describe("api/admin/info", function() {
|
||||
describe("settings handler", function() {
|
||||
before(function() {
|
||||
sinon.stub(theme,"settings",function() { return { test: 456 };});
|
||||
|
@@ -24,7 +24,7 @@ var when = require('when');
|
||||
var nodes = require("../../../../red/api/admin/nodes");
|
||||
var apiUtil = require("../../../../red/api/util");
|
||||
|
||||
describe("nodes api", function() {
|
||||
describe("api/admin/nodes", function() {
|
||||
|
||||
var app;
|
||||
function initNodes(runtime) {
|
||||
|
@@ -17,7 +17,7 @@
|
||||
var should = require("should");
|
||||
var Clients = require("../../../../red/api/auth/clients");
|
||||
|
||||
describe("Clients", function() {
|
||||
describe("api/auth/clients", function() {
|
||||
it('finds the known editor client',function(done) {
|
||||
Clients.get("node-red-editor").then(function(client) {
|
||||
client.should.have.property("id","node-red-editor");
|
||||
@@ -41,7 +41,6 @@ describe("Clients", function() {
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
@@ -24,7 +24,7 @@ var auth = require("../../../../red/api/auth");
|
||||
var Users = require("../../../../red/api/auth/users");
|
||||
var Tokens = require("../../../../red/api/auth/tokens");
|
||||
|
||||
describe("api auth middleware",function() {
|
||||
describe("api/auth/index",function() {
|
||||
|
||||
|
||||
|
||||
|
@@ -17,7 +17,7 @@
|
||||
var should = require("should");
|
||||
var permissions = require("../../../../red/api/auth/permissions");
|
||||
|
||||
describe("Auth permissions", function() {
|
||||
describe("api/auth/permissions", function() {
|
||||
describe("hasPermission", function() {
|
||||
it('a user with no permissions',function() {
|
||||
permissions.hasPermission([],"*").should.be.false();
|
||||
|
@@ -23,7 +23,7 @@ var Users = require("../../../../red/api/auth/users");
|
||||
var Tokens = require("../../../../red/api/auth/tokens");
|
||||
var Clients = require("../../../../red/api/auth/clients");
|
||||
|
||||
describe("Auth strategies", function() {
|
||||
describe("api/auth/strategies", function() {
|
||||
before(function() {
|
||||
strategies.init({log:{audit:function(){}}})
|
||||
});
|
||||
|
@@ -21,7 +21,7 @@ var sinon = require("sinon");
|
||||
var Tokens = require("../../../../red/api/auth/tokens");
|
||||
|
||||
|
||||
describe("Tokens", function() {
|
||||
describe("api/auth/tokens", function() {
|
||||
describe("#init",function() {
|
||||
it('loads sessions', function(done) {
|
||||
Tokens.init({}).then(done);
|
||||
|
@@ -20,7 +20,7 @@ var sinon = require('sinon');
|
||||
|
||||
var Users = require("../../../../red/api/auth/users");
|
||||
|
||||
describe("Users", function() {
|
||||
describe("api/auth/users", function() {
|
||||
describe('Initalised with a credentials object, no anon',function() {
|
||||
before(function() {
|
||||
Users.init({
|
||||
|
19
test/red/api/editor/projects/index_spec.js
Normal file
19
test/red/api/editor/projects/index_spec.js
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
|
||||
describe("api/editor/projects", function() {
|
||||
it.skip("NEEDS TESTS WRITING",function() {});
|
||||
});
|
@@ -424,8 +424,11 @@ describe('red/runtime/nodes/credentials', function() {
|
||||
var cryptedFlows = {"$":"5b89d8209b5158a3c313675561b1a5b5phN1gDBe81Zv98KqS/hVDmc9EKvaKqRIvcyXYvBlFNzzzJtvN7qfw06i"};
|
||||
credentials.init(runtime);
|
||||
credentials.load(cryptedFlows).then(function() {
|
||||
credentials.dirty().should.be.true();
|
||||
should.not.exist(credentials.get("node"));
|
||||
// credentials.dirty().should.be.true();
|
||||
// should.not.exist(credentials.get("node"));
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
err.should.have.property('code','credentials_load_failed');
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -437,8 +440,11 @@ describe('red/runtime/nodes/credentials', function() {
|
||||
var cryptedFlows = {"$":"5b89d8209b5158a3c313675561b1a5b5phN1gDBe81Zv98KqS/hVDmc9EKvaKqRIvcyXYvBlFNzzzJtvN7qfw06i"};
|
||||
credentials.init(runtime);
|
||||
credentials.load(cryptedFlows).then(function() {
|
||||
credentials.dirty().should.be.true();
|
||||
should.not.exist(credentials.get("node"));
|
||||
// credentials.dirty().should.be.true();
|
||||
// should.not.exist(credentials.get("node"));
|
||||
done();
|
||||
}).otherwise(function(err) {
|
||||
err.should.have.property('code','credentials_load_failed');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@@ -21,6 +21,12 @@ var path = require('path');
|
||||
var localfilesystem = require("../../../../../red/runtime/storage/localfilesystem");
|
||||
|
||||
describe('storage/localfilesystem', function() {
|
||||
var mockRuntime = {
|
||||
log:{
|
||||
_:function() { return "placeholder message"},
|
||||
info: function() { }
|
||||
}
|
||||
};
|
||||
var userDir = path.join(__dirname,".testUserHome");
|
||||
var testFlow = [{"type":"tab","id":"d8be2a6d.2741d8","label":"Sheet 1"}];
|
||||
beforeEach(function(done) {
|
||||
@@ -33,7 +39,7 @@ describe('storage/localfilesystem', function() {
|
||||
});
|
||||
|
||||
it('should initialise the user directory',function(done) {
|
||||
localfilesystem.init({userDir:userDir}).then(function() {
|
||||
localfilesystem.init({userDir:userDir}, mockRuntime).then(function() {
|
||||
fs.existsSync(path.join(userDir,"lib")).should.be.true();
|
||||
fs.existsSync(path.join(userDir,"lib",'flows')).should.be.true();
|
||||
done();
|
||||
@@ -49,7 +55,7 @@ describe('storage/localfilesystem', function() {
|
||||
fs.mkdirSync(process.env.NODE_RED_HOME);
|
||||
fs.writeFileSync(path.join(process.env.NODE_RED_HOME,".config.json"),"{}","utf8");
|
||||
var settings = {};
|
||||
localfilesystem.init(settings).then(function() {
|
||||
localfilesystem.init(settings, mockRuntime).then(function() {
|
||||
try {
|
||||
fs.existsSync(path.join(process.env.NODE_RED_HOME,"lib")).should.be.true();
|
||||
fs.existsSync(path.join(process.env.NODE_RED_HOME,"lib",'flows')).should.be.true();
|
||||
@@ -74,7 +80,7 @@ describe('storage/localfilesystem', function() {
|
||||
fs.mkdirSync(path.join(process.env.HOMEPATH,".node-red"));
|
||||
fs.writeFileSync(path.join(process.env.HOMEPATH,".node-red",".config.json"),"{}","utf8");
|
||||
var settings = {};
|
||||
localfilesystem.init(settings).then(function() {
|
||||
localfilesystem.init(settings, mockRuntime).then(function() {
|
||||
try {
|
||||
fs.existsSync(path.join(process.env.HOMEPATH,".node-red","lib")).should.be.true();
|
||||
fs.existsSync(path.join(process.env.HOMEPATH,".node-red","lib",'flows')).should.be.true();
|
||||
@@ -101,7 +107,7 @@ describe('storage/localfilesystem', function() {
|
||||
|
||||
fs.mkdirSync(process.env.HOME);
|
||||
var settings = {};
|
||||
localfilesystem.init(settings).then(function() {
|
||||
localfilesystem.init(settings, mockRuntime).then(function() {
|
||||
try {
|
||||
fs.existsSync(path.join(process.env.HOME,".node-red","lib")).should.be.true();
|
||||
fs.existsSync(path.join(process.env.HOME,".node-red","lib",'flows')).should.be.true();
|
||||
@@ -131,7 +137,7 @@ describe('storage/localfilesystem', function() {
|
||||
|
||||
fs.mkdirSync(process.env.USERPROFILE);
|
||||
var settings = {};
|
||||
localfilesystem.init(settings).then(function() {
|
||||
localfilesystem.init(settings, mockRuntime).then(function() {
|
||||
try {
|
||||
fs.existsSync(path.join(process.env.USERPROFILE,".node-red","lib")).should.be.true();
|
||||
fs.existsSync(path.join(process.env.USERPROFILE,".node-red","lib",'flows')).should.be.true();
|
||||
@@ -151,7 +157,7 @@ describe('storage/localfilesystem', function() {
|
||||
});
|
||||
|
||||
it('should handle missing flow file',function(done) {
|
||||
localfilesystem.init({userDir:userDir}).then(function() {
|
||||
localfilesystem.init({userDir:userDir}, mockRuntime).then(function() {
|
||||
var flowFile = 'flows_'+require('os').hostname()+'.json';
|
||||
var flowFilePath = path.join(userDir,flowFile);
|
||||
fs.existsSync(flowFilePath).should.be.false();
|
||||
@@ -167,7 +173,7 @@ describe('storage/localfilesystem', function() {
|
||||
});
|
||||
|
||||
it('should handle empty flow file, no backup',function(done) {
|
||||
localfilesystem.init({userDir:userDir}).then(function() {
|
||||
localfilesystem.init({userDir:userDir}, mockRuntime).then(function() {
|
||||
var flowFile = 'flows_'+require('os').hostname()+'.json';
|
||||
var flowFilePath = path.join(userDir,flowFile);
|
||||
var flowFileBackupPath = path.join(userDir,"."+flowFile+".backup");
|
||||
@@ -185,7 +191,7 @@ describe('storage/localfilesystem', function() {
|
||||
});
|
||||
|
||||
it('should handle empty flow file, restores backup',function(done) {
|
||||
localfilesystem.init({userDir:userDir}).then(function() {
|
||||
localfilesystem.init({userDir:userDir}, mockRuntime).then(function() {
|
||||
var flowFile = 'flows_'+require('os').hostname()+'.json';
|
||||
var flowFilePath = path.join(userDir,flowFile);
|
||||
var flowFileBackupPath = path.join(userDir,"."+flowFile+".backup");
|
||||
@@ -208,7 +214,7 @@ describe('storage/localfilesystem', function() {
|
||||
});
|
||||
|
||||
it('should save flows to the default file',function(done) {
|
||||
localfilesystem.init({userDir:userDir}).then(function() {
|
||||
localfilesystem.init({userDir:userDir}, mockRuntime).then(function() {
|
||||
var flowFile = 'flows_'+require('os').hostname()+'.json';
|
||||
var flowFilePath = path.join(userDir,flowFile);
|
||||
var flowFileBackupPath = path.join(userDir,"."+flowFile+".backup");
|
||||
@@ -237,7 +243,7 @@ describe('storage/localfilesystem', function() {
|
||||
var flowFile = 'test.json';
|
||||
var flowFilePath = path.join(userDir,flowFile);
|
||||
|
||||
localfilesystem.init({userDir:userDir, flowFile:flowFilePath}).then(function() {
|
||||
localfilesystem.init({userDir:userDir, flowFile:flowFilePath}, mockRuntime).then(function() {
|
||||
fs.existsSync(defaultFlowFilePath).should.be.false();
|
||||
fs.existsSync(flowFilePath).should.be.false();
|
||||
|
||||
@@ -261,7 +267,7 @@ describe('storage/localfilesystem', function() {
|
||||
it('should format the flows file when flowFilePretty specified',function(done) {
|
||||
var flowFile = 'test.json';
|
||||
var flowFilePath = path.join(userDir,flowFile);
|
||||
localfilesystem.init({userDir:userDir, flowFile:flowFilePath,flowFilePretty:true}).then(function() {
|
||||
localfilesystem.init({userDir:userDir, flowFile:flowFilePath,flowFilePretty:true}, mockRuntime).then(function() {
|
||||
localfilesystem.saveFlows(testFlow).then(function() {
|
||||
var content = fs.readFileSync(flowFilePath,"utf8");
|
||||
content.split("\n").length.should.be.above(1);
|
||||
@@ -286,7 +292,7 @@ describe('storage/localfilesystem', function() {
|
||||
var flowFilePath = path.join(userDir,flowFile);
|
||||
var flowFileBackupPath = path.join(userDir,"."+flowFile+".backup");
|
||||
|
||||
localfilesystem.init({userDir:userDir, flowFile:flowFilePath}).then(function() {
|
||||
localfilesystem.init({userDir:userDir, flowFile:flowFilePath}, mockRuntime).then(function() {
|
||||
fs.existsSync(defaultFlowFilePath).should.be.false();
|
||||
fs.existsSync(flowFilePath).should.be.false();
|
||||
fs.existsSync(flowFileBackupPath).should.be.false();
|
||||
@@ -326,7 +332,7 @@ describe('storage/localfilesystem', function() {
|
||||
var flowFile = 'test.json';
|
||||
var flowFilePath = path.join(userDir,flowFile);
|
||||
var credFile = path.join(userDir,"test_cred.json");
|
||||
localfilesystem.init({userDir:userDir, flowFile:flowFilePath}).then(function() {
|
||||
localfilesystem.init({userDir:userDir, flowFile:flowFilePath}, mockRuntime).then(function() {
|
||||
fs.existsSync(credFile).should.be.false();
|
||||
|
||||
localfilesystem.getCredentials().then(function(creds) {
|
||||
@@ -345,7 +351,7 @@ describe('storage/localfilesystem', function() {
|
||||
var flowFilePath = path.join(userDir,flowFile);
|
||||
var credFile = path.join(userDir,"test_cred.json");
|
||||
|
||||
localfilesystem.init({userDir:userDir, flowFile:flowFilePath}).then(function() {
|
||||
localfilesystem.init({userDir:userDir, flowFile:flowFilePath}, mockRuntime).then(function() {
|
||||
|
||||
fs.existsSync(credFile).should.be.false();
|
||||
|
||||
@@ -374,7 +380,7 @@ describe('storage/localfilesystem', function() {
|
||||
var credFile = path.join(userDir,"test_cred.json");
|
||||
var credFileBackup = path.join(userDir,".test_cred.json.backup");
|
||||
|
||||
localfilesystem.init({userDir:userDir, flowFile:flowFilePath}).then(function() {
|
||||
localfilesystem.init({userDir:userDir, flowFile:flowFilePath}, mockRuntime).then(function() {
|
||||
|
||||
fs.writeFileSync(credFile,"{}","utf8");
|
||||
|
||||
@@ -400,7 +406,7 @@ describe('storage/localfilesystem', function() {
|
||||
var flowFilePath = path.join(userDir,flowFile);
|
||||
var credFile = path.join(userDir,"test_cred.json");
|
||||
|
||||
localfilesystem.init({userDir:userDir, flowFile:flowFilePath, flowFilePretty:true}).then(function() {
|
||||
localfilesystem.init({userDir:userDir, flowFile:flowFilePath, flowFilePretty:true}, mockRuntime).then(function() {
|
||||
|
||||
fs.existsSync(credFile).should.be.false();
|
||||
|
||||
|
Reference in New Issue
Block a user