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:
parent
a9789697e7
commit
df065e94b7
@ -25,12 +25,12 @@ describe("Users", function() {
|
||||
before(function() {
|
||||
Users.init({
|
||||
type:"credentials",
|
||||
users:[{
|
||||
users:{
|
||||
username:"fred",
|
||||
password:'$2a$08$LpYMefvGZ3MjAfZGzcoyR.1BcfHh4wy4NpbN.cEny5aHnWOqjKOXK',
|
||||
// 'password' -> require('bcryptjs').hashSync('password', 8);
|
||||
permissions:"*"
|
||||
}]
|
||||
}
|
||||
});
|
||||
});
|
||||
describe('#get',function() {
|
||||
@ -73,7 +73,6 @@ describe("Users", function() {
|
||||
});
|
||||
|
||||
describe('#authenticate',function() {
|
||||
|
||||
it('authenticates a known user', function(done) {
|
||||
Users.authenticate('fred','password').then(function(user) {
|
||||
try {
|
||||
@ -110,7 +109,6 @@ describe("Users", function() {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('Initalised with a credentials object including anon',function() {
|
||||
before(function() {
|
||||
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();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user