'use strict'; var should = require('should'), app = require('../../server-test'), simpleDI = require('config/simpleDI'), sinon = require('sinon'); var authorizationMiddleware = simpleDI.resolve('base/authorizationMiddleware'), authorizationService = simpleDI.resolve('base/authorizationService'); var sinonSandbox; describe('Base#AuthorizationService', function() { before(function () { sinonSandbox = sinon.sandbox.create(); }); after(function () { sinonSandbox.restore(); }); describe('#checkAuthorization', function() { var authSrvStub, authFn; beforeEach(function () { authSrvStub = sinonSandbox.stub(authorizationService, 'isAuthorized'); }); afterEach(function () {
'use strict'; var should = require('should'), app = require('../../server-test'), simpleDI = require('config/simpleDI'); var authorizationService = simpleDI.resolve('base/authorizationService'); describe('Base#AuthorizationService', function () { describe('#isAuthorized', function () { it('should return false when no roles are passed', function (done) { authorizationService.isAuthorized([], 'resource1', 'action1', function (error, isAuthorized) { isAuthorized.should.be.false; done(); }); }); it('should return false when no known roles are passed', function (done) { authorizationService.isAuthorized(['dummy1', 'dummy2'], 'resource1', 'action1', function (error, isAuthorized) { isAuthorized.should.be.false; done(); }); }); it('should return true when the role is allowed to perform action', function (done) {