Skip to content

Commit

Permalink
Added a couple of unit tests for security service
Browse files Browse the repository at this point in the history
  • Loading branch information
brianhyder committed Apr 18, 2015
1 parent 5911fd0 commit 4fdc750
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
55 changes: 55 additions & 0 deletions test/include/access_management_tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//depedencies
var should = require('should');
var Configuration = require('../../include/config.js');
var Lib = require('../../lib');

describe('SecurityService', function() {

var pb = null;
var SecurityService = null;
before('Initialize the Environment with the default configuration', function() {

pb = new Lib(Configuration.getBaseConfig());
SecurityService = pb.SecurityService;
});

describe('SecurityService.getRoleToDisplayNameMap', function() {

it('should provide the 5 basic roles', function() {

var ls = new pb.Localization('en_US');
var result = SecurityService.getRoleToDisplayNameMap(ls);

result.ACCESS_ADMINISTRATOR.should.eql('ACCESS_ADMINISTRATOR');
result.ACCESS_MANAGING_EDITOR.should.eql('ACCESS_MANAGING_EDITOR');
result.ACCESS_EDITOR.should.eql('ACCESS_EDITOR');
result.ACCESS_WRITER.should.eql('ACCESS_WRITER');
result.ACCESS_USER.should.eql('ACCESS_USER');
});

it('should throw when no localization instance is provided', function() {
SecurityService.getRoleToDisplayNameMap.bind(null).should.throwError();
});
});

describe('SecurityService.getRoleNames', function() {

it('should provide the 5 basic roles', function() {

var ls = new pb.Localization('en_US');
var result = SecurityService.getRoleNames(ls);

result.should.be.instanceof(Array);
should(result.length === 5).be.ok;
should(result.indexOf('ACCESS_ADMINISTRATOR') >= 0).be.ok;
should(result.indexOf('ACCESS_MANAGING_EDITOR') >= 0).be.ok;
should(result.indexOf('ACCESS_EDITOR') >= 0).be.ok;
should(result.indexOf('ACCESS_WRITER') >= 0).be.ok;
should(result.indexOf('ACCESS_USER') >= 0).be.ok;
});

it('should throw when no localization instance is provided', function() {
SecurityService.getRoleNames.bind(null).should.throwError();
});
});
});
1 change: 0 additions & 1 deletion test/include/config_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//depedencies
var should = require('should');
var Configuration = require('../../include/config.js');
var Lib = require('../../lib');

describe('Configuration', function() {

Expand Down

0 comments on commit 4fdc750

Please sign in to comment.