public void GetAllModulePermissionSetsReturnsAllExpectedPermissionSets() { MockRolesCatalog catalog = new MockRolesCatalog(); MockAuthorizationService authSerivce = new MockAuthorizationService(); IPermissionsCatalog permissionsService = new MockPermissionCatalog(); AdminController controller = new AdminController(authSerivce, permissionsService, catalog); ModulePermissionSet[] allSets = controller.GetModulePermissionSets(); Assert.AreEqual(permissionsService.RegisteredPermissions["TestModule"].ModuleName, allSets[0].ModuleName); Assert.AreEqual(permissionsService.RegisteredPermissions.Keys.Count, allSets.Length); }
public void GetModulePermissionSetReturnsSingleActionAndSingleRolePermission() { MockRolesCatalog catalog = new MockRolesCatalog(); MockAuthorizationService authSerivce = new MockAuthorizationService(); IPermissionsCatalog permissionsService = new MockPermissionCatalog(); AdminController controller = new AdminController(authSerivce, permissionsService, catalog); ModulePermissionSet set = controller.GetModulePermissionSet("TestModule"); ModulePermission singleModulePermission = set.ModulePermissions[0]; Assert.AreEqual("TestModule", singleModulePermission.ModuleName); Assert.AreEqual("Friendly", singleModulePermission.ActionName); Assert.IsTrue(singleModulePermission.Permissions is Dictionary<string, bool>); Assert.IsFalse(singleModulePermission.Permissions["Mock01"]); }
public void GetModulePermissionSetWorksForSingleModule() { MockRolesCatalog catalog = new MockRolesCatalog(); MockAuthorizationService authSerivce = new MockAuthorizationService(); IPermissionsCatalog permissionsService = new MockPermissionCatalog(); AdminController controller = new AdminController(authSerivce, permissionsService, catalog); ModulePermissionSet set = controller.GetModulePermissionSet("TestModule02"); ModulePermission[] permissions = set.ModulePermissions.ToArray(); Assert.AreEqual("TestModule02", permissions[0].ModuleName); Assert.AreEqual("Friendly", permissions[0].ActionName); Assert.IsTrue(permissions[0].Permissions is Dictionary<string, bool>); Assert.IsFalse(permissions[0].Permissions["Mock01"]); }
public void GetModulePermissionSetWorksForTwoModules() { MockRolesCatalog catalog = new MockRolesCatalog(); MockAuthorizationService authSerivce = new MockAuthorizationService(); IPermissionsCatalog permissionsService = new MockPermissionCatalog(); AdminController controller = new AdminController(authSerivce, permissionsService, catalog); ModulePermissionSet testModuleSet = controller.GetModulePermissionSet("TestModule"); ModulePermission testModulePermission = testModuleSet.ModulePermissions[0]; Assert.AreEqual("TestModule", testModulePermission.ModuleName); Assert.AreEqual("Friendly", testModulePermission.ActionName); Assert.IsTrue(testModulePermission.Permissions is Dictionary<string, bool>); Assert.IsFalse(testModulePermission.Permissions["Mock01"]); ModulePermissionSet testModule02Set = controller.GetModulePermissionSet("TestModule"); ModulePermission testModule02Permission = testModule02Set.ModulePermissions[0]; Assert.AreEqual("TestModule", testModule02Permission.ModuleName); Assert.AreEqual("Friendly", testModule02Permission.ActionName); Assert.IsTrue(testModule02Permission.Permissions is Dictionary<string, bool>); Assert.IsFalse(testModule02Permission.Permissions["Mock01"]); }