Merge branch '0.14.0'

This commit is contained in:
Nick O'Leary
2016-06-17 21:30:09 +01:00
167 changed files with 6903 additions and 4341 deletions

View File

@@ -1,5 +1,5 @@
/**
* Copyright 2015 IBM Corp.
* Copyright 2015, 2016 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,14 +31,22 @@ describe("Auth permissions", function() {
permissions.hasPermission(["read"],"node.read").should.be.true;
permissions.hasPermission(["read"],"write").should.be.false;
permissions.hasPermission(["read"],"node.write").should.be.false;
permissions.hasPermission(["*.read"],"read").should.be.true;
permissions.hasPermission(["*.read"],"node.read").should.be.true;
permissions.hasPermission(["*.read"],"write").should.be.false;
permissions.hasPermission(["*.read"],"node.write").should.be.false;
});
it('a user with foo permissions',function() {
permissions.hasPermission("foo","foo").should.be.false;
permissions.hasPermission("foo","foo").should.be.true;
});
it('an array of permissions', function() {
permissions.hasPermission(["*"],["foo.read","foo.write"]).should.be.true;
permissions.hasPermission("read",["foo.read","foo.write"]).should.be.false;
permissions.hasPermission("read",["foo.read","bar.read"]).should.be.true;
permissions.hasPermission(["flows.read"],["flows.read"]).should.be.true;
permissions.hasPermission(["flows.read"],["flows.write"]).should.be.false;
permissions.hasPermission(["flows.read","nodes.write"],["flows.write"]).should.be.false;
permissions.hasPermission(["flows.read","nodes.write"],["nodes.write"]).should.be.true;
});
it('permits an empty permission', function() {
permissions.hasPermission("*","").should.be.true;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
var should = require("should");
var when = require("when");
var sinon = require("sinon");
@@ -24,16 +24,11 @@ var Tokens = require("../../../../red/api/auth/tokens");
describe("Tokens", function() {
describe("#init",function() {
it('loads sessions', function(done) {
Tokens.init({},{
getSessions:function() {
done();
return when.resolve();
}
});
Tokens.init({}).then(done);
});
});
describe("#get",function() {
it('returns a valid token', function(done) {
Tokens.init({},{
@@ -51,7 +46,7 @@ describe("Tokens", function() {
});
});
});
it('returns null for an invalid token', function(done) {
Tokens.init({},{
getSessions:function() {
@@ -98,7 +93,7 @@ describe("Tokens", function() {
});
});
});
describe("#create",function() {
it('creates a token', function(done) {
var savedSession;
@@ -112,14 +107,14 @@ describe("Tokens", function() {
}
});
var expectedExpiryTime = Date.now()+10000;
Tokens.create("user","client","scope").then(function(token) {
try {
should.exist(savedSession);
var sessionKeys = Object.keys(savedSession);
sessionKeys.should.have.lengthOf(1);
token.should.have.a.property('accessToken',sessionKeys[0]);
savedSession[sessionKeys[0]].should.have.a.property('user','user');
savedSession[sessionKeys[0]].should.have.a.property('client','client');
@@ -133,7 +128,7 @@ describe("Tokens", function() {
});
});
});
describe("#revoke", function() {
it('revokes a token', function(done) {
var savedSession;
@@ -157,5 +152,5 @@ describe("Tokens", function() {
});
});
});
});
});

View File

@@ -50,7 +50,8 @@ describe("flows api", function() {
if (err) {
return done(err);
}
res.body.should.be.an.Array.and.have.lengthOf(3);
res.body.should.be.an.Array;
res.body.should.have.lengthOf(3);
done();
});
});

View File

@@ -15,5 +15,5 @@
**/
describe("locales api", function() {
it.skip("works",function(){});
it.skip("works",function() {});
});

View File

@@ -44,10 +44,10 @@ describe("nodes api", function() {
app.use(bodyParser.json());
app.get("/nodes",nodes.getAll);
app.post("/nodes",nodes.post);
app.get("/nodes/:mod",nodes.getModule);
app.get("/nodes/:mod/:set",nodes.getSet);
app.put("/nodes/:mod",nodes.putModule);
app.put("/nodes/:mod/:set",nodes.putSet);
app.get(/\/nodes\/((@[^\/]+\/)?[^\/]+)$/,nodes.getModule);
app.get(/\/nodes\/((@[^\/]+\/)?[^\/]+)\/([^\/]+)$/,nodes.getSet);
app.put(/\/nodes\/((@[^\/]+\/)?[^\/]+)$/,nodes.putModule);
app.put(/\/nodes\/((@[^\/]+\/)?[^\/]+)\/([^\/]+)$/,nodes.putSet);
app.delete("/nodes/:id",nodes.delete);
sinon.stub(comms,"publish");
sinon.stub(locales,"determineLangFromHeaders", function() {
@@ -76,7 +76,8 @@ describe("nodes api", function() {
if (err) {
throw err;
}
res.body.should.be.an.Array.and.have.lengthOf(3);
res.body.should.be.an.Array;
res.body.should.have.lengthOf(3);
done();
});
});