1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

add extra tests to user_spec to test some else conditions.

This commit is contained in:
dceejay 2015-03-19 19:57:41 +00:00
parent a9789697e7
commit df065e94b7

View File

@ -25,12 +25,12 @@ describe("Users", function() {
before(function() { before(function() {
Users.init({ Users.init({
type:"credentials", type:"credentials",
users:[{ users:{
username:"fred", username:"fred",
password:'$2a$08$LpYMefvGZ3MjAfZGzcoyR.1BcfHh4wy4NpbN.cEny5aHnWOqjKOXK', password:'$2a$08$LpYMefvGZ3MjAfZGzcoyR.1BcfHh4wy4NpbN.cEny5aHnWOqjKOXK',
// 'password' -> require('bcryptjs').hashSync('password', 8); // 'password' -> require('bcryptjs').hashSync('password', 8);
permissions:"*" permissions:"*"
}] }
}); });
}); });
describe('#get',function() { describe('#get',function() {
@ -73,7 +73,6 @@ describe("Users", function() {
}); });
describe('#authenticate',function() { describe('#authenticate',function() {
it('authenticates a known user', function(done) { it('authenticates a known user', function(done) {
Users.authenticate('fred','password').then(function(user) { Users.authenticate('fred','password').then(function(user) {
try { try {
@ -110,7 +109,6 @@ describe("Users", function() {
}); });
}); });
describe('Initalised with a credentials object including anon',function() { describe('Initalised with a credentials object including anon',function() {
before(function() { before(function() {
Users.init({ Users.init({
@ -179,8 +177,47 @@ describe("Users", function() {
}); });
}); });
}); });
});
describe('Initialised with bad settings to test else cases',function() {
before(function() {
Users.init({
type:"foo",
users:{
username:"fred",
password:'$2a$08$LpYMefvGZ3MjAfZGzcoyR.1BcfHh4wy4NpbN.cEny5aHnWOqjKOXK',
permissions:"*"
}
});
});
describe('#get',function() {
it('should fail to return user fred',function(done) {
Users.get("fred").then(function(userf) {
try {
userf.should.not.have.a.property("username","fred");
userf.should.not.have.a.property("permissions","*");
done();
} catch(err) {
done(err);
}
});
});
});
});
describe('Initialised with default set as function',function() {
before(function() {
Users.init({
type:"credentials",
default: function() { return("Done"); }
});
});
describe('#default',function() {
it('handles api.default being a function',function(done) {
Users.should.have.property('default').which.is.a.Function;
(Users.default()).should.equal("Done");
done();
});
});
}); });
}); });