mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Update to latest sinon
This commit is contained in:
@@ -58,7 +58,7 @@ describe("api/auth/index",function() {
|
||||
|
||||
describe("revoke", function() {
|
||||
it("revokes a token", function(done) {
|
||||
var revokeToken = sinon.stub(Tokens,"revoke",function() {
|
||||
var revokeToken = sinon.stub(Tokens,"revoke").callsFake(function() {
|
||||
return Promise.resolve();
|
||||
});
|
||||
|
||||
@@ -79,8 +79,8 @@ describe("api/auth/index",function() {
|
||||
|
||||
describe("login", function() {
|
||||
beforeEach(function() {
|
||||
sinon.stub(Tokens,"init",function(){});
|
||||
sinon.stub(Users,"init",function(){});
|
||||
sinon.stub(Tokens,"init").callsFake(function(){});
|
||||
sinon.stub(Users,"init").callsFake(function(){});
|
||||
});
|
||||
afterEach(function() {
|
||||
Tokens.init.restore();
|
||||
@@ -119,8 +119,8 @@ describe("api/auth/index",function() {
|
||||
});
|
||||
describe("needsPermission", function() {
|
||||
beforeEach(function() {
|
||||
sinon.stub(Tokens,"init",function(){});
|
||||
sinon.stub(Users,"init",function(){});
|
||||
sinon.stub(Tokens,"init").callsFake(function(){});
|
||||
sinon.stub(Users,"init").callsFake(function(){});
|
||||
});
|
||||
afterEach(function() {
|
||||
Tokens.init.restore();
|
||||
@@ -135,7 +135,7 @@ describe("api/auth/index",function() {
|
||||
|
||||
|
||||
it('no-ops if adminAuth not set', function(done) {
|
||||
sinon.stub(passport,"authenticate",function(scopes,opts) {
|
||||
sinon.stub(passport,"authenticate").callsFake(function(scopes,opts) {
|
||||
return function(req,res,next) {
|
||||
}
|
||||
});
|
||||
@@ -147,12 +147,12 @@ describe("api/auth/index",function() {
|
||||
})
|
||||
});
|
||||
it('skips auth if req.user undefined', function(done) {
|
||||
sinon.stub(passport,"authenticate",function(scopes,opts) {
|
||||
sinon.stub(passport,"authenticate").callsFake(function(scopes,opts) {
|
||||
return function(req,res,next) {
|
||||
next();
|
||||
}
|
||||
});
|
||||
sinon.stub(Permissions,"hasPermission",function(perm) { return true });
|
||||
sinon.stub(Permissions,"hasPermission").callsFake(function(perm) { return true });
|
||||
auth.init({adminAuth:{}});
|
||||
var func = auth.needsPermission("foo");
|
||||
func({user:null},{},function() {
|
||||
@@ -167,12 +167,12 @@ describe("api/auth/index",function() {
|
||||
});
|
||||
|
||||
it('passes for valid user permission', function(done) {
|
||||
sinon.stub(passport,"authenticate",function(scopes,opts) {
|
||||
sinon.stub(passport,"authenticate").callsFake(function(scopes,opts) {
|
||||
return function(req,res,next) {
|
||||
next();
|
||||
}
|
||||
});
|
||||
sinon.stub(Permissions,"hasPermission",function(perm) { return true });
|
||||
sinon.stub(Permissions,"hasPermission").callsFake(function(perm) { return true });
|
||||
auth.init({adminAuth:{}});
|
||||
var func = auth.needsPermission("foo");
|
||||
func({user:true,authInfo: { scope: "read"}},{},function() {
|
||||
@@ -189,12 +189,12 @@ describe("api/auth/index",function() {
|
||||
});
|
||||
|
||||
it('rejects for invalid user permission', function(done) {
|
||||
sinon.stub(passport,"authenticate",function(scopes,opts) {
|
||||
sinon.stub(passport,"authenticate").callsFake(function(scopes,opts) {
|
||||
return function(req,res,next) {
|
||||
next();
|
||||
}
|
||||
});
|
||||
sinon.stub(Permissions,"hasPermission",function(perm) { return false });
|
||||
sinon.stub(Permissions,"hasPermission").callsFake(function(perm) { return false });
|
||||
auth.init({adminAuth:{}});
|
||||
var func = auth.needsPermission("foo");
|
||||
func({user:true,authInfo: { scope: "read"}},{
|
||||
|
Reference in New Issue
Block a user