Merge branch 'dev' into diagnostics

This commit is contained in:
Stephen McLaughlin
2022-04-27 12:08:32 +01:00
committed by GitHub
210 changed files with 26309 additions and 21234 deletions

View File

@@ -92,7 +92,23 @@ describe("api/auth/strategies", function() {
tokenCreate.restore();
}
});
});
it('Uses provided token on authentication success and token provided',function(done) {
userAuthentication = sinon.stub(Users,"authenticate").callsFake(function(username,password) {
return Promise.resolve({username:"user",permissions:"*",token:"123456"});
});
strategies.passwordTokenExchange({id:"myclient"},"user","password","read",function(err,token) {
try {
should.not.exist(err);
token.should.equal("123456");
done();
} catch(e) {
done(e);
}
});
});
});

View File

@@ -379,7 +379,6 @@ describe('red/runtime/nodes/credentials', function() {
credentials.export().then(function(result) {
result.should.have.a.property("$");
settings.should.not.have.a.property("_credentialSecret");
// reset everything - but with _credentialSecret still set
credentials.init(runtime);
// load the freshly encrypted version
@@ -445,6 +444,21 @@ describe('red/runtime/nodes/credentials', function() {
});
});
it('handles bad credentials object - resets credentials', function(done) {
settings = {
credentialSecret: "e3a36f47f005bf2aaa51ce3fc6fcaafd79da8d03f2b1a9281f8fb0a285e6255a"
};
// {"node":{user1:"abc",password1:"123"}}
var cryptedFlows = {"BADKEY":"5b89d8209b5158a3c313675561b1a5b5phN1gDBe81Zv98KqS/hVDmc9EKvaKqRIvcyXYvBlFNzzzJtvN7qfw06i"};
credentials.init(runtime);
credentials.load(cryptedFlows).then(function() {
done();
}).catch(function(err) {
err.should.have.property('code','credentials_load_failed');
done();
});
});
it('handles unavailable settings - leaves creds unencrypted', function(done) {
var runtime = {
log: log,

View File

@@ -63,7 +63,7 @@ describe("red/nodes/index", function() {
var runtime = {
settings: settings,
storage: storage,
log: {debug:function() {}, warn:function() {}},
log: {debug:function() {}, warn:function() {}, _: function() {}},
events: new EventEmitter()
};